From d3c84fff65ef874876db3abe0669923c6e716a00 Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Wed, 25 Apr 2018 14:38:24 -0400 Subject: 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 Commit-Queue: Ben Wagner --- gm/xfermodes3.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'gm/xfermodes3.cpp') 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 possiblyCreateTempSurface(SkCanvas* baseCanvas, int w, int h) { -#if SK_SUPPORT_GPU - GrContext* context = baseCanvas->getGrContext(); + sk_sp 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(); -- cgit v1.2.3