Minor refactor of GrLayerHoister

The main point of this CL is to make sure using the rect bounds (rather than the underlying texture's bounds) is acceptable in GrLayerHoister::FilterLayer.

This is split out of https://codereview.chromium.org/1943913002/ (Retract GrRenderTarget from GrLayerHoister)

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1947593002

Review-Url: https://codereview.chromium.org/1947593002
This commit is contained in:
robertphillips 2016-05-03 09:37:08 -07:00 committed by Commit bot
parent 46db22f1cf
commit b4511344b6
2 changed files with 8 additions and 6 deletions

View File

@ -232,7 +232,7 @@ void GrLayerHoister::DrawLayersToAtlas(GrContext* context,
if (atlased.count() > 0) {
// All the atlased layers are rendered into the same GrTexture
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
auto surface(SkSurface::MakeRenderTargetDirect(
sk_sp<SkSurface> surface(SkSurface::MakeRenderTargetDirect(
atlased[0].fLayer->texture()->asRenderTarget(), &props));
SkCanvas* atlasCanvas = surface->getCanvas();
@ -301,7 +301,9 @@ void GrLayerHoister::FilterLayer(GrContext* context,
SkImageFilter::Context filterContext(totMat, clipBounds, cache);
// TODO: should the layer hoister store stand alone layers as SkSpecialImages internally?
const SkIRect subset = SkIRect::MakeWH(layer->texture()->width(), layer->texture()->height());
SkASSERT(layer->rect().width() == layer->texture()->width() &&
layer->rect().height() == layer->texture()->height());
const SkIRect subset = SkIRect::MakeWH(layer->rect().width(), layer->rect().height());
sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromGpu(subset,
kNeedNewImageUniqueID_SpecialImage,
sk_ref_sp(layer->texture()),

View File

@ -69,8 +69,8 @@ static void create_layers(skiatest::Reporter* reporter,
REPORTER_ASSERT(reporter, picture.uniqueID() == layer->pictureID());
REPORTER_ASSERT(reporter, layer->start() == idOffset + i + 1);
REPORTER_ASSERT(reporter, layer->stop() == idOffset + i + 2);
REPORTER_ASSERT(reporter, nullptr == layer->texture());
REPORTER_ASSERT(reporter, nullptr == layer->paint());
REPORTER_ASSERT(reporter, !layer->texture());
REPORTER_ASSERT(reporter, !layer->paint());
REPORTER_ASSERT(reporter, !layer->isAtlased());
}
}
@ -197,7 +197,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GpuLayerCache, reporter, ctxInfo) {
} else {
#endif
// The final layer should not be atlased.
REPORTER_ASSERT(reporter, nullptr == layer->texture());
REPORTER_ASSERT(reporter, !layer->texture());
REPORTER_ASSERT(reporter, !layer->isAtlased());
#if GR_CACHE_HOISTED_LAYERS
}
@ -258,7 +258,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GpuLayerCache, reporter, ctxInfo) {
// The one that was never atlased should still be around
REPORTER_ASSERT(reporter, layer);
REPORTER_ASSERT(reporter, nullptr == layer->texture());
REPORTER_ASSERT(reporter, !layer->texture());
REPORTER_ASSERT(reporter, !layer->isAtlased());
#if GR_CACHE_HOISTED_LAYERS
} else {