From bdc3afa577718c657da6eaffba6ae90ec1c26ca2 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Mon, 7 Aug 2017 22:12:05 -0400 Subject: simplify gm matrices rm gm that appears to have been there solely for pdf, but we don't use it for that now. Bug: skia: Change-Id: I3cf88db923c2445b7c95dda14da679a594117643 Reviewed-on: https://skia-review.googlesource.com/31760 Reviewed-by: Derek Sollenberger Reviewed-by: Mike Klein Commit-Queue: Mike Klein --- gm/gm.cpp | 1 - gm/gm.h | 17 --------- gm/shaderbounds.cpp | 106 ---------------------------------------------------- 3 files changed, 124 deletions(-) delete mode 100644 gm/shaderbounds.cpp (limited to 'gm') diff --git a/gm/gm.cpp b/gm/gm.cpp index 1c787826c2..17b220a191 100644 --- a/gm/gm.cpp +++ b/gm/gm.cpp @@ -16,7 +16,6 @@ GM::GM() { fBGColor = SK_ColorWHITE; fCanvasIsDeferred = false; fHaveCalledOnceBeforeDraw = false; - fStarterMatrix.reset(); } GM::~GM() {} diff --git a/gm/gm.h b/gm/gm.h index d293d40e4c..0447f09528 100644 --- a/gm/gm.h +++ b/gm/gm.h @@ -72,16 +72,6 @@ namespace skiagm { return SkIntToScalar(this->getISize().height()); } - // TODO(vandebo) Instead of exposing this, we should run all the GMs - // with and without an initial transform. - // Most GMs will return the identity matrix, but some PDFs tests - // require setting the initial transform. - SkMatrix getInitialTransform() const { - SkMatrix matrix = fStarterMatrix; - matrix.preConcat(this->onGetInitialTransform()); - return matrix; - } - SkColor getBGColor() const { return fBGColor; } void setBGColor(SkColor); @@ -94,11 +84,6 @@ namespace skiagm { fCanvasIsDeferred = isDeferred; } - const SkMatrix& getStarterMatrix() { return fStarterMatrix; } - void setStarterMatrix(const SkMatrix& matrix) { - fStarterMatrix = matrix; - } - bool animate(const SkAnimTimer&); bool handleKey(SkUnichar uni) { return this->onHandleKey(uni); @@ -118,7 +103,6 @@ namespace skiagm { virtual bool onAnimate(const SkAnimTimer&) { return false; } virtual bool onHandleKey(SkUnichar uni) { return false; } - virtual SkMatrix onGetInitialTransform() const { return SkMatrix::I(); } private: Mode fMode; @@ -126,7 +110,6 @@ namespace skiagm { SkColor fBGColor; bool fCanvasIsDeferred; // work-around problem in srcmode.cpp bool fHaveCalledOnceBeforeDraw; - SkMatrix fStarterMatrix; }; typedef sk_tools::Registry GMRegistry; diff --git a/gm/shaderbounds.cpp b/gm/shaderbounds.cpp deleted file mode 100644 index 503f8f5b1e..0000000000 --- a/gm/shaderbounds.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2012 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 "SkGradientShader.h" - -namespace skiagm { - -static sk_sp MakeLinear(SkScalar width, SkScalar height, bool alternate, - const SkMatrix& localMatrix) { - SkPoint pts[2] = { {0, 0}, {width, height}}; - SkColor colors[2] = {SK_ColorRED, SK_ColorGREEN}; - if (alternate) { - pts[1].fY = 0; - colors[0] = SK_ColorBLUE; - colors[1] = SK_ColorYELLOW; - } - return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode, - 0, &localMatrix); -} - -/////////////////////////////////////////////////////////////////////////////// - -class ShaderBoundsGM : public GM { -public: - typedef sk_sp (*ShaderGenFunc)(SkScalar width, SkScalar height, - bool alternate, const SkMatrix& localMatrix); - ShaderBoundsGM(ShaderGenFunc maker, const SkString& name) - : fShaderMaker(maker), - fName(name) { - } - -protected: - - SkString onShortName() override { - return fName; - } - - SkISize onISize() override { return SkISize::Make(320, 240); } - - SkMatrix onGetInitialTransform() const override { - SkMatrix result; - SkScalar scale = 0.8f; - result.setScale(scale, scale); - result.postTranslate(SkIntToScalar(7), SkIntToScalar(23)); - return result; - } - - void onDraw(SkCanvas* canvas) override { - // The PDF device has already clipped to the content area, but we - // do it again here so that the raster and pdf results are consistent. - canvas->clipRect(SkRect::MakeWH(SkIntToScalar(320), - SkIntToScalar(240))); - - SkMatrix canvasScale; - SkScalar scale = 0.7f; - canvasScale.setScale(scale, scale); - canvas->concat(canvasScale); - - // Background shader. - SkPaint paint; - paint.setShader(MakeShader(559, 387, false)); - SkRect r = SkRect::MakeXYWH(SkIntToScalar(-12), SkIntToScalar(-41), - SkIntToScalar(571), SkIntToScalar(428)); - canvas->drawRect(r, paint); - - // Constrained shader. - paint.setShader(MakeShader(101, 151, true)); - r = SkRect::MakeXYWH(SkIntToScalar(43), SkIntToScalar(71), - SkIntToScalar(101), SkIntToScalar(151)); - canvas->clipRect(r); - canvas->drawRect(r, paint); - } - - sk_sp MakeShader(int width, int height, bool background) { - SkScalar scale = 0.5f; - if (background) { - scale = 0.6f; - } - SkScalar shaderWidth = width / scale; - SkScalar shaderHeight = height / scale; - SkMatrix shaderScale = SkMatrix::MakeScale(scale); - return fShaderMaker(shaderWidth, shaderHeight, background, shaderScale); - } - -private: - typedef GM INHERITED; - - ShaderGenFunc fShaderMaker; - SkString fName; - - sk_sp MakeShader(bool background); -}; - -/////////////////////////////////////////////////////////////////////////////// - -static GM* MyFactory(void*) { - return new ShaderBoundsGM(MakeLinear, SkString("shaderbounds_linear")); -} -static GMRegistry reg(MyFactory); - -} -- cgit v1.2.3