@@ -354,9 +354,10 @@ class DoClipChileLayer {
354
354
m_isClipChild = false ;
355
355
356
356
if (1 != child->tilesSize () && 0 != child->tilesSize ()) {
357
- m_isClipChild = true ;
357
+ m_isClipChild = true ;
358
358
canvas->save ();
359
- canvas->clipRect (SkRect::MakeIWH (child->drawToCanvasProperties ()->bounds .width () - 1 , child->drawToCanvasProperties ()->bounds .height () - 1 ));
359
+ int bugFixMagicNum = child->drawToCanvasProperties ()->currentTransform .isTranslate () ? 0 : 1 ;
360
+ canvas->clipRect (SkRect::MakeIWH (child->drawToCanvasProperties ()->bounds .width () - bugFixMagicNum, child->drawToCanvasProperties ()->bounds .height () - bugFixMagicNum));
360
361
}
361
362
}
362
363
@@ -421,8 +422,8 @@ void CompositingLayer::drawToCanvasChildren(LayerTreeHost* host, SkCanvas* canva
421
422
422
423
void CompositingLayer::drawToCanvas (LayerTreeHost* host, blink::WebCanvas* canvas, const blink::IntRect& clip)
423
424
{
424
- int alpha = (int )( 255 * opacity ());
425
- if (!drawsContent ())
425
+ U8CPU alphaVal = (int )ceil ( opacity () * 255 );
426
+ if (!drawsContent () || 0 == alphaVal )
426
427
return ;
427
428
428
429
for (TilesAddr::iterator it = m_tilesAddr->begin (); it != m_tilesAddr->end (); ++it) {
@@ -438,18 +439,35 @@ void CompositingLayer::drawToCanvas(LayerTreeHost* host, blink::WebCanvas* canva
438
439
439
440
SkPaint paint;
440
441
paint.setAntiAlias (true );
441
- paint.setAlpha (alpha);
442
442
paint.setXfermodeMode (SkXfermode::kSrcOver_Mode );
443
-
444
443
paint.setFilterQuality (kHigh_SkFilterQuality );
445
444
446
445
SkColor* color = tile->getSolidColor ();
447
446
if (color) {
448
447
paint.setColor (*color);
449
- canvas->drawRect (dst, paint);
448
+ paint.setAlpha ((int )ceil ((alphaVal * SkColorGetA (*color)) / 255.0 ));
449
+ canvas->drawRect (dst, paint);
450
+
451
+ // SkPaint paintTest;
452
+ // const SkColor color2 = 0xff000000 | (rand() % 3) * (rand() % 7) * GetTickCount();
453
+ // paintTest.setColor(color2);
454
+ // paintTest.setStrokeWidth(4);
455
+ // paintTest.setTextSize(13);
456
+ // paintTest.setTextEncoding(SkPaint::kUTF8_TextEncoding);
457
+ //
458
+ // static SkTypeface* typeface = nullptr;
459
+ // if (!typeface)
460
+ // typeface = SkTypeface::RefDefault(SkTypeface::kNormal);
461
+ // paintTest.setTypeface(typeface);
462
+ //
463
+ // paintTest.setStrokeWidth(1);
464
+ // String textTest = String::format("%d %d %x", m_id, alpha, *color);
465
+ // CString cText = textTest.utf8();
466
+ // canvas->drawText(cText.data(), cText.length(), 5 + (int)tilePostion.x(), 15 + (int)tilePostion.y(), paintTest);
450
467
} else {
451
468
if (!tile->bitmap () || !tile->bitmap ()->getPixels ())
452
469
DebugBreak ();
470
+ paint.setAlpha (alphaVal);
453
471
canvas->drawBitmapRect (*tile->bitmap (), nullptr , dst, &paint);
454
472
}
455
473
}
0 commit comments