diff options
Diffstat (limited to 'libs/hwui')
| -rw-r--r-- | libs/hwui/pipeline/skia/RenderNodeDrawable.cpp | 8 | ||||
| -rw-r--r-- | libs/hwui/pipeline/skia/SkiaPipeline.cpp | 10 | ||||
| -rw-r--r-- | libs/hwui/tests/unit/RenderNodeDrawableTests.cpp | 4 |
3 files changed, 16 insertions, 6 deletions
diff --git a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp index 845acc0fc0b2..e2f02df62b30 100644 --- a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp +++ b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp @@ -205,7 +205,13 @@ void RenderNodeDrawable::drawContent(SkCanvas* canvas) const { if (layerNeedsPaint(layerProperties, alphaMultiplier, &tmpPaint)) { paint = &tmpPaint; } - renderNode->getLayerSurface()->draw(canvas, 0, 0, paint); + + // surfaces for layers are created on LAYER_SIZE boundaries (which are >= layer size) so + // we need to restrict the portion of the surface drawn to the size of the renderNode. + SkASSERT(renderNode->getLayerSurface()->width() >= bounds.width()); + SkASSERT(renderNode->getLayerSurface()->height() >= bounds.height()); + canvas->drawImageRect(renderNode->getLayerSurface()->makeImageSnapshot().get(), + bounds, bounds, paint); if (!renderNode->getSkiaLayer()->hasRenderedSinceRepaint) { renderNode->getSkiaLayer()->hasRenderedSinceRepaint = true; diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.cpp b/libs/hwui/pipeline/skia/SkiaPipeline.cpp index d5fe7f4fa6aa..4ba368f35bfd 100644 --- a/libs/hwui/pipeline/skia/SkiaPipeline.cpp +++ b/libs/hwui/pipeline/skia/SkiaPipeline.cpp @@ -161,14 +161,18 @@ void SkiaPipeline::renderLayersImpl(const LayerUpdateQueue& layers, bool opaque, bool SkiaPipeline::createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator, bool wideColorGamut) { + // compute the size of the surface (i.e. texture) to be allocated for this layer + const int surfaceWidth = ceilf(node->getWidth() / float(LAYER_SIZE)) * LAYER_SIZE; + const int surfaceHeight = ceilf(node->getHeight() / float(LAYER_SIZE)) * LAYER_SIZE; + SkSurface* layer = node->getLayerSurface(); - if (!layer || layer->width() != node->getWidth() || layer->height() != node->getHeight()) { + if (!layer || layer->width() != surfaceWidth || layer->height() != surfaceHeight) { SkImageInfo info; if (wideColorGamut) { - info = SkImageInfo::Make(node->getWidth(), node->getHeight(), kRGBA_F16_SkColorType, + info = SkImageInfo::Make(surfaceWidth, surfaceHeight, kRGBA_F16_SkColorType, kPremul_SkAlphaType); } else { - info = SkImageInfo::MakeN32Premul(node->getWidth(), node->getHeight()); + info = SkImageInfo::MakeN32Premul(surfaceWidth, surfaceHeight); } SkSurfaceProps props(0, kUnknown_SkPixelGeometry); SkASSERT(mRenderThread.getGrContext() != nullptr); diff --git a/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp b/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp index 7dd271f5daf4..c7f57fee1d5a 100644 --- a/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp +++ b/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp @@ -460,15 +460,15 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(RenderNodeDrawable, projectionHwLayer) { ProjectionLayer(int* drawCounter) : SkSurface_Base(SkImageInfo::MakeN32Premul(LAYER_WIDTH, LAYER_HEIGHT), nullptr) , mDrawCounter(drawCounter) {} - void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) override { + virtual sk_sp<SkImage> onNewImageSnapshot() override { EXPECT_EQ(3, (*mDrawCounter)++); EXPECT_EQ(SkRect::MakeLTRB(100 - SCROLL_X, 100 - SCROLL_Y, 300 - SCROLL_X, 300 - SCROLL_Y), TestUtils::getClipBounds(this->getCanvas())); + return nullptr; } SkCanvas* onNewCanvas() override { return new ProjectionTestCanvas(mDrawCounter); } sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override { return nullptr; } - sk_sp<SkImage> onNewImageSnapshot() override { return nullptr; } void onCopyOnWrite(ContentChangeMode) override {} int* mDrawCounter; }; |