From: Matt Sarett Date: Wed, 12 Apr 2017 15:49:44 +0000 (+0000) Subject: Revert "Fix SkLocalMatrixShader::isAImage() to respect local matrix and image local... X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~46^2~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e5fec217878e954483e023098e044cbe11ef0175;p=platform%2Fupstream%2FlibSkiaSharp.git Revert "Fix SkLocalMatrixShader::isAImage() to respect local matrix and image local matrix" This reverts commit e5efa51b2acc86d1993132348d5b465855a653cc. Reason for revert: MSAN Original change's description: > Fix SkLocalMatrixShader::isAImage() to respect local matrix and image local matrix > > Fixes cts tests. > > b/37161109 > b/37237678 > > Bug: skia: > Change-Id: Ida9ac5e4261e8a6b22e8cdc0e585e0e7929dbbfd > Reviewed-on: https://skia-review.googlesource.com/13249 > Commit-Queue: Mike Klein > Reviewed-by: Mike Klein > TBR=mtklein@chromium.org,mtklein@google.com,msarett@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I2b78c7b32997344136c784dc77675dafca37565e Reviewed-on: https://skia-review.googlesource.com/13259 Reviewed-by: Matt Sarett Commit-Queue: Matt Sarett --- diff --git a/gm/localmatriximageshader.cpp b/gm/localmatriximageshader.cpp deleted file mode 100644 index 2c9fcd2..0000000 --- a/gm/localmatriximageshader.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "gm.h" -#include "SkCanvas.h" -#include "SkSurface.h" - -static sk_sp make_image(SkCanvas* rootCanvas, SkColor color) { - SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); - auto surface(rootCanvas->makeSurface(info)); - if (!surface) { - surface = SkSurface::MakeRaster(info); - } - - SkPaint paint; - paint.setAntiAlias(true); - paint.setColor(color); - surface->getCanvas()->drawIRect(SkIRect::MakeXYWH(25, 25, 50, 50), paint); - return surface->makeImageSnapshot(); -} - -DEF_SIMPLE_GM(localmatriximageshader, canvas, 250, 250) { - sk_sp redImage = make_image(canvas, SK_ColorRED); - SkMatrix translate = SkMatrix::MakeTrans(100.0f, 0.0f); - SkMatrix rotate; - rotate.setRotate(45.0f); - sk_sp redImageShader = redImage->makeShader(SkShader::TileMode::kClamp_TileMode, - SkShader::TileMode::kClamp_TileMode, &translate); - sk_sp redLocalMatrixShader = redImageShader->makeWithLocalMatrix(rotate); - - // Rotate about the origin will happen first. - SkPaint paint; - paint.setShader(redLocalMatrixShader); - canvas->drawIRect(SkIRect::MakeWH(250, 250), paint); - - sk_sp blueImage = make_image(canvas, SK_ColorBLUE); - sk_sp blueImageShader = blueImage->makeShader(SkShader::TileMode::kClamp_TileMode, - SkShader::TileMode::kClamp_TileMode, &rotate); - sk_sp blueLocalMatrixShader = blueImageShader->makeWithLocalMatrix(translate); - - // Translate will happen first. - paint.setShader(blueLocalMatrixShader); - canvas->drawIRect(SkIRect::MakeWH(250, 250), paint); - - canvas->translate(100.0f, 0.0f); - - // Use isAImage() and confirm that the shaders will draw exactly the same (to the right by 100). - SkShader::TileMode mode[2]; - SkMatrix matrix; - SkImage* image = redLocalMatrixShader->isAImage(&matrix, mode); - paint.setShader(image->makeShader(mode[0], mode[1], &matrix)); - canvas->drawIRect(SkIRect::MakeWH(250, 250), paint); - image = blueLocalMatrixShader->isAImage(&matrix, mode); - paint.setShader(image->makeShader(mode[0], mode[1], &matrix)); - canvas->drawIRect(SkIRect::MakeWH(250, 250), paint); -} diff --git a/gn/gm.gni b/gn/gm.gni index 67d2ced..65c6766 100644 --- a/gn/gm.gni +++ b/gn/gm.gni @@ -188,7 +188,6 @@ gm_sources = [ "$_gm/lightingshaderbevel.cpp", "$_gm/linepaths.cpp", "$_gm/localmatriximagefilter.cpp", - "$_gm/localmatriximageshader.cpp", "$_gm/lumafilter.cpp", "$_gm/manypaths.cpp", "$_gm/matrixconvolution.cpp", diff --git a/src/core/SkLocalMatrixShader.cpp b/src/core/SkLocalMatrixShader.cpp index 22eb0fe..9d9e109 100644 --- a/src/core/SkLocalMatrixShader.cpp +++ b/src/core/SkLocalMatrixShader.cpp @@ -51,17 +51,6 @@ SkShader::Context* SkLocalMatrixShader::onMakeContext( return fProxyShader->makeContext(newRec, alloc); } -SkImage* SkLocalMatrixShader::onIsAImage(SkMatrix* outMatrix, enum TileMode* mode) const { - SkMatrix imageMatrix; - SkImage* image = fProxyShader->isAImage(&imageMatrix, mode); - if (outMatrix) { - // Local matrix must be applied first so it is on the right side of the concat. - *outMatrix = SkMatrix::Concat(imageMatrix, this->getLocalMatrix()); - } - - return image; -} - bool SkLocalMatrixShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dst, SkArenaAlloc* scratch, diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h index cba1409..5c04240 100644 --- a/src/core/SkLocalMatrixShader.h +++ b/src/core/SkLocalMatrixShader.h @@ -45,7 +45,9 @@ protected: Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override; - SkImage* onIsAImage(SkMatrix* matrix, TileMode* mode) const override; + SkImage* onIsAImage(SkMatrix* matrix, TileMode* mode) const override { + return fProxyShader->isAImage(matrix, mode); + } bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*, const SkMatrix&, const SkPaint&, const SkMatrix*) const override;