Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 384233002: Always have GrLayer's rect be valid (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix use of deprecated function Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrLayerCache.cpp ('k') | tests/GpuLayerCacheTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGpuDevice.cpp
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 3f1908be20f9d3dc191082369af97a064f50118c..3a9acb265d22b9c7d26bf8a245d2b7b6cb766e3b 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1963,21 +1963,18 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pi
layerInfo->fBM = SkNEW(SkBitmap); // fBM is allocated so ReplacementInfo can be POD
wrap_texture(layer->texture(),
- layer->rect().isEmpty() ? desc.fWidth : layer->texture()->width(),
- layer->rect().isEmpty() ? desc.fHeight : layer->texture()->height(),
+ !layer->isAtlased() ? desc.fWidth : layer->texture()->width(),
+ !layer->isAtlased() ? desc.fHeight : layer->texture()->height(),
layerInfo->fBM);
SkASSERT(info.fPaint);
layerInfo->fPaint = info.fPaint;
- if (layer->rect().isEmpty()) {
- layerInfo->fSrcRect = SkIRect::MakeWH(desc.fWidth, desc.fHeight);
- } else {
- layerInfo->fSrcRect = SkIRect::MakeXYWH(layer->rect().fLeft,
- layer->rect().fTop,
- layer->rect().width(),
- layer->rect().height());
- }
+ layerInfo->fSrcRect = SkIRect::MakeXYWH(layer->rect().fLeft,
+ layer->rect().fTop,
+ layer->rect().width(),
+ layer->rect().height());
+
if (needsRendering) {
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
@@ -1987,14 +1984,12 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pi
SkCanvas* canvas = surface->getCanvas();
- if (!layer->rect().isEmpty()) {
- // Add a rect clip to make sure the rendering doesn't
- // extend beyond the boundaries of the atlased sub-rect
- SkRect bound = SkRect::MakeXYWH(SkIntToScalar(layer->rect().fLeft),
- SkIntToScalar(layer->rect().fTop),
- SkIntToScalar(layer->rect().width()),
- SkIntToScalar(layer->rect().height()));
- canvas->clipRect(bound);
+ // Add a rect clip to make sure the rendering doesn't
+ // extend beyond the boundaries of the atlased sub-rect
+ SkRect bound = SkRect::Make(layerInfo->fSrcRect);
+ canvas->clipRect(bound);
+
+ if (layer->isAtlased()) {
// Since 'clear' doesn't respect the clip we need to draw a rect
// TODO: ensure none of the atlased layers contain a clear call!
SkPaint paint;
@@ -2004,16 +1999,12 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pi
canvas->clear(SK_ColorTRANSPARENT);
}
- canvas->setMatrix(info.fCTM);
-
- if (!layer->rect().isEmpty()) {
- // info.fCTM maps the layer's top/left to the origin.
- // Since this layer is atlased the top/left corner needs
- // to be offset to some arbitrary location in the backing
- // texture.
- canvas->translate(SkIntToScalar(layer->rect().fLeft),
- SkIntToScalar(layer->rect().fTop));
- }
+ // info.fCTM maps the layer's top/left to the origin.
+ // If this layer is atlased the top/left corner needs
+ // to be offset to some arbitrary location in the backing
+ // texture.
+ canvas->translate(bound.fLeft, bound.fTop);
+ canvas->concat(info.fCTM);
SkPictureRangePlayback rangePlayback(picture,
info.fSaveLayerOpID,
« no previous file with comments | « src/gpu/GrLayerCache.cpp ('k') | tests/GpuLayerCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698