diff options
author | robertphillips <robertphillips@google.com> | 2014-11-24 09:49:17 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-24 09:49:17 -0800 |
commit | 30d7841f906116c3945ec8125a816a5c5462fed0 (patch) | |
tree | 40fecb4654dc961252b95364d015d8db601c1bce /src/core/SkMultiPictureDraw.cpp | |
parent | 7ef849d45a4de02697697ea213bfae7c215a0c38 (diff) |
Add support for hoisting layers in pictures drawn with a matrix
Although Chromium doesn't use the drawPicture matrix parameter for their tiling, our local code does. Without such drawPicture calls break layer hoisting.
BUG=skia:2315
Review URL: https://codereview.chromium.org/748853002
Diffstat (limited to 'src/core/SkMultiPictureDraw.cpp')
-rw-r--r-- | src/core/SkMultiPictureDraw.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/core/SkMultiPictureDraw.cpp b/src/core/SkMultiPictureDraw.cpp index 0285598413..51feae55d8 100644 --- a/src/core/SkMultiPictureDraw.cpp +++ b/src/core/SkMultiPictureDraw.cpp @@ -9,6 +9,7 @@ // framework build, which gets its defines from SkTypes rather than a makefile, // has the definition before checking it. #include "SkCanvas.h" +#include "SkCanvasPriv.h" #include "SkMultiPictureDraw.h" #include "SkPicture.h" #include "SkTaskGroup.h" @@ -111,12 +112,15 @@ void SkMultiPictureDraw::draw() { // we only expect 1 context for all the canvases SkASSERT(data.fCanvas->getGrContext() == context); - if (!data.fPaint && data.fMatrix.isIdentity()) { + if (!data.fPaint) { SkRect clipBounds; if (!data.fCanvas->getClipBounds(&clipBounds)) { continue; } + SkMatrix initialMatrix = data.fCanvas->getTotalMatrix(); + initialMatrix.preConcat(data.fMatrix); + GrRenderTarget* rt = data.fCanvas->internal_private_accessTopLayerRenderTarget(); SkASSERT(rt); @@ -124,7 +128,7 @@ void SkMultiPictureDraw::draw() { // would improve the packing and reduce the number of swaps // TODO: another optimization would be to make a first pass to // lock any required layer that is already in the atlas - GrLayerHoister::FindLayersToAtlas(context, data.fPicture, + GrLayerHoister::FindLayersToAtlas(context, data.fPicture, initialMatrix, clipBounds, &atlasedNeedRendering, &atlasedRecycled, rt->numSamples()); @@ -142,19 +146,23 @@ void SkMultiPictureDraw::draw() { const SkPicture* picture = data.fPicture; #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU - if (!data.fPaint && data.fMatrix.isIdentity()) { + if (!data.fPaint) { SkRect clipBounds; if (!canvas->getClipBounds(&clipBounds)) { continue; } + SkAutoCanvasMatrixPaint acmp(canvas, &data.fMatrix, data.fPaint, picture->cullRect()); + + const SkMatrix initialMatrix = canvas->getTotalMatrix(); + GrRenderTarget* rt = data.fCanvas->internal_private_accessTopLayerRenderTarget(); SkASSERT(rt); // Find the layers required by this canvas. It will return atlased // layers in the 'recycled' list since they have already been drawn. - GrLayerHoister::FindLayersToHoist(context, picture, + GrLayerHoister::FindLayersToHoist(context, picture, initialMatrix, clipBounds, &needRendering, &recycled, rt->numSamples()); @@ -165,8 +173,6 @@ void SkMultiPictureDraw::draw() { GrLayerHoister::ConvertLayersToReplacements(needRendering, &replacements); GrLayerHoister::ConvertLayersToReplacements(recycled, &replacements); - const SkMatrix initialMatrix = canvas->getTotalMatrix(); - // Render the entire picture using new layers GrRecordReplaceDraw(picture, canvas, &replacements, initialMatrix, NULL); |