aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/xfermodes3.cpp
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2018-04-25 14:38:24 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-25 19:25:47 +0000
commitd3c84fff65ef874876db3abe0669923c6e716a00 (patch)
treed6d4ed602294dfb719b299c7261c51aa88e84f8a /gm/xfermodes3.cpp
parent6078776ee58384be3a3cf953cefba9df2892e34d (diff)
Clean up xfermodes3 gm.
Update temporary surface creation so that cpu and gpu are doing the same thing, reducing confusion around what the test is doing. Also clip to the bounds of the saved layer when a temporary surface cannot be created. This prevents the underspecified behavior of drawing outside the bounds of a saved layer. Change-Id: Iad35b394f50b4e1867a8bffdc9f5b3d2ae9c1645 Reviewed-on: https://skia-review.googlesource.com/123741 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'gm/xfermodes3.cpp')
-rw-r--r--gm/xfermodes3.cpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/gm/xfermodes3.cpp b/gm/xfermodes3.cpp
index 9c78658ae7..e1b1c76248 100644
--- a/gm/xfermodes3.cpp
+++ b/gm/xfermodes3.cpp
@@ -60,7 +60,7 @@ protected:
0x80,
};
- auto tempSurface(this->possiblyCreateTempSurface(canvas, kSize, kSize));
+ auto tempSurface(this->makeTempSurface(canvas, kSize, kSize));
int test = 0;
int x = 0, y = 0;
@@ -118,21 +118,13 @@ private:
* We are trying to test those. We could use saveLayer() to create small SkGpuDevices but
* saveLayer() uses the texture cache. This means that the actual render target may be larger
* than the layer. Because the clip will contain the layer's bounds, no draws will be full-RT.
- * So when running on a GPU canvas we explicitly create a temporary canvas using a texture with
- * dimensions exactly matching the layer size.
+ * So explicitly create a temporary canvas with dimensions exactly the layer size.
*/
- sk_sp<SkSurface> possiblyCreateTempSurface(SkCanvas* baseCanvas, int w, int h) {
-#if SK_SUPPORT_GPU
- GrContext* context = baseCanvas->getGrContext();
+ sk_sp<SkSurface> makeTempSurface(SkCanvas* baseCanvas, int w, int h) {
SkImageInfo baseInfo = baseCanvas->imageInfo();
SkImageInfo info = SkImageInfo::Make(w, h, baseInfo.colorType(), baseInfo.alphaType(),
baseInfo.refColorSpace());
- SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
- baseCanvas->getProps(&canvasProps);
- return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0, &canvasProps);
-#else
- return nullptr;
-#endif
+ return baseCanvas->makeSurface(info);
}
void drawMode(SkCanvas* canvas,
@@ -146,6 +138,7 @@ private:
SkCanvas* modeCanvas;
if (nullptr == surface) {
canvas->saveLayer(&r, nullptr);
+ canvas->clipRect(r);
modeCanvas = canvas;
} else {
modeCanvas = surface->getCanvas();