Skip to content

Commit 582c54c

Browse files
committed
* DoClipChileLayer加个边界宽高减一,这是为了解决kodexplorer点感叹号出现白线的bug。但没找到具体原因,猜测是精度误差
* 同意是修复kodexplorer(dns.toaone.com)的出现黑块的bug。原因是layer的alpha和纯色分析出来的alpha值,应该是乘积关系,之前没考虑到,结果纯色alpha把layer的alpha覆盖了 * WebLayerImpl::invalidateRect增加脏矩形外阔一个像素。这是为了修复www.marriott.com.cn选择复制有残留线条的bug,具体原因还不清楚,先用这个绕过方案
1 parent 59a252d commit 582c54c

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

cc/blink/WebLayerImpl.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ using blink::IntRect;
4040
using blink::WebDoublePoint;
4141
using blink::WebFloatPoint3D;
4242

43+
extern bool g_alwaysInflateDirtyRect;
44+
4345
namespace cc_blink {
4446
namespace {
4547

@@ -1298,6 +1300,10 @@ void WebLayerImpl::requestBoundRepaint(bool directOrPending)
12981300
void WebLayerImpl::invalidateRect(const blink::WebRect& rect)
12991301
{
13001302
blink::IntRect dirtyRect(rect);
1303+
1304+
if (g_alwaysInflateDirtyRect)
1305+
dirtyRect.inflate(1);
1306+
13011307
if (m_tileGrid)
13021308
m_tileGrid->invalidate(dirtyRect, false);
13031309
setNeedsCommit(false);

cc/layers/CompositingLayer.cpp

+25-7
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,10 @@ class DoClipChileLayer {
354354
m_isClipChild = false;
355355

356356
if (1 != child->tilesSize() && 0 != child->tilesSize()) {
357-
m_isClipChild = true;
357+
m_isClipChild = true;
358358
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));
360361
}
361362
}
362363

@@ -421,8 +422,8 @@ void CompositingLayer::drawToCanvasChildren(LayerTreeHost* host, SkCanvas* canva
421422

422423
void CompositingLayer::drawToCanvas(LayerTreeHost* host, blink::WebCanvas* canvas, const blink::IntRect& clip)
423424
{
424-
int alpha = (int)(255 * opacity());
425-
if (!drawsContent())
425+
U8CPU alphaVal = (int)ceil(opacity() * 255);
426+
if (!drawsContent() || 0 == alphaVal)
426427
return;
427428

428429
for (TilesAddr::iterator it = m_tilesAddr->begin(); it != m_tilesAddr->end(); ++it) {
@@ -438,18 +439,35 @@ void CompositingLayer::drawToCanvas(LayerTreeHost* host, blink::WebCanvas* canva
438439

439440
SkPaint paint;
440441
paint.setAntiAlias(true);
441-
paint.setAlpha(alpha);
442442
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
443-
444443
paint.setFilterQuality(kHigh_SkFilterQuality);
445444

446445
SkColor* color = tile->getSolidColor();
447446
if (color) {
448447
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);
450467
} else {
451468
if (!tile->bitmap() || !tile->bitmap()->getPixels())
452469
DebugBreak();
470+
paint.setAlpha(alphaVal);
453471
canvas->drawBitmapRect(*tile->bitmap(), nullptr, dst, &paint);
454472
}
455473
}

0 commit comments

Comments
 (0)