Loading libs/hwui/pipeline/skia/RenderNodeDrawable.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -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; Loading libs/hwui/pipeline/skia/SkiaPipeline.cpp +7 −3 Original line number Diff line number Diff line Loading @@ -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); Loading libs/hwui/tests/unit/RenderNodeDrawableTests.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -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; }; Loading Loading
libs/hwui/pipeline/skia/RenderNodeDrawable.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -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; Loading
libs/hwui/pipeline/skia/SkiaPipeline.cpp +7 −3 Original line number Diff line number Diff line Loading @@ -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); Loading
libs/hwui/tests/unit/RenderNodeDrawableTests.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -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; }; Loading