aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrLayerHoister.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-11-24 09:49:17 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-24 09:49:17 -0800
commit30d7841f906116c3945ec8125a816a5c5462fed0 (patch)
tree40fecb4654dc961252b95364d015d8db601c1bce /src/gpu/GrLayerHoister.cpp
parent7ef849d45a4de02697697ea213bfae7c215a0c38 (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/gpu/GrLayerHoister.cpp')
-rw-r--r--src/gpu/GrLayerHoister.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp
index b53c1b80cd..b7653ee295 100644
--- a/src/gpu/GrLayerHoister.cpp
+++ b/src/gpu/GrLayerHoister.cpp
@@ -19,6 +19,7 @@
// required texture/render target resources.
static void prepare_for_hoisting(GrLayerCache* layerCache,
const SkPicture* topLevelPicture,
+ const SkMatrix& matrix,
const SkLayerInfo::BlockInfo& info,
const SkIRect& layerRect,
SkTDArray<GrHoistedLayer>* needRendering,
@@ -27,7 +28,9 @@ static void prepare_for_hoisting(GrLayerCache* layerCache,
int numSamples) {
const SkPicture* pict = info.fPicture ? info.fPicture : topLevelPicture;
- SkMatrix combined = SkMatrix::Concat(info.fPreMat, info.fLocalMat);
+ SkMatrix combined = matrix;
+ combined.preConcat(info.fPreMat);
+ combined.preConcat(info.fLocalMat);
GrCachedLayer* layer = layerCache->findLayerOrCreate(pict->uniqueID(),
info.fSaveLayerOpID,
@@ -73,7 +76,8 @@ static void prepare_for_hoisting(GrLayerCache* layerCache,
hl->fPicture = pict;
hl->fOffset = SkIPoint::Make(layerRect.fLeft, layerRect.fTop);
hl->fLocalMat = info.fLocalMat;
- hl->fPreMat = info.fPreMat;
+ hl->fPreMat = matrix;
+ hl->fPreMat.preConcat(info.fPreMat);
}
// Atlased layers must be small enough to fit in the atlas, not have a
@@ -81,6 +85,7 @@ static void prepare_for_hoisting(GrLayerCache* layerCache,
// TODO: allow leaf nested layers to appear in the atlas.
void GrLayerHoister::FindLayersToAtlas(GrContext* context,
const SkPicture* topLevelPicture,
+ const SkMatrix& initialMat,
const SkRect& query,
SkTDArray<GrHoistedLayer>* atlased,
SkTDArray<GrHoistedLayer>* recycled,
@@ -119,25 +124,27 @@ void GrLayerHoister::FindLayersToAtlas(GrContext* context,
continue;
}
- SkRect layerRect = info.fBounds;
+ SkRect layerRect;
+ initialMat.mapRect(&layerRect, info.fBounds);
if (!layerRect.intersect(query)) {
continue;
}
- SkIRect ir;
- layerRect.roundOut(&ir);
+ const SkIRect ir = layerRect.roundOut();
if (!GrLayerCache::PlausiblyAtlasable(ir.width(), ir.height())) {
continue;
}
- prepare_for_hoisting(layerCache, topLevelPicture, info, ir, atlased, recycled, true, 0);
+ prepare_for_hoisting(layerCache, topLevelPicture, initialMat,
+ info, ir, atlased, recycled, true, 0);
}
}
void GrLayerHoister::FindLayersToHoist(GrContext* context,
const SkPicture* topLevelPicture,
+ const SkMatrix& initialMat,
const SkRect& query,
SkTDArray<GrHoistedLayer>* needRendering,
SkTDArray<GrHoistedLayer>* recycled,
@@ -166,15 +173,15 @@ void GrLayerHoister::FindLayersToHoist(GrContext* context,
continue;
}
- SkRect layerRect = info.fBounds;
+ SkRect layerRect;
+ initialMat.mapRect(&layerRect, info.fBounds);
if (!layerRect.intersect(query)) {
continue;
}
- SkIRect ir;
- layerRect.roundOut(&ir);
+ const SkIRect ir = layerRect.roundOut();
- prepare_for_hoisting(layerCache, topLevelPicture, info, ir,
+ prepare_for_hoisting(layerCache, topLevelPicture, initialMat, info, ir,
needRendering, recycled, false, numSamples);
}
}