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

Side by Side Diff: gm/pictureshader.cpp

Issue 852213002: SkPictureShader should handle negative scaling gracefully. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: rerebased Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | src/core/SkPictureShader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 protected: 44 protected:
45 uint32_t onGetFlags() const SK_OVERRIDE { 45 uint32_t onGetFlags() const SK_OVERRIDE {
46 return kSkipTiled_Flag; 46 return kSkipTiled_Flag;
47 } 47 }
48 48
49 SkString onShortName() SK_OVERRIDE { 49 SkString onShortName() SK_OVERRIDE {
50 return SkString("pictureshader"); 50 return SkString("pictureshader");
51 } 51 }
52 52
53 SkISize onISize() SK_OVERRIDE { 53 SkISize onISize() SK_OVERRIDE {
54 return SkISize::Make(1400, 1250); 54 return SkISize::Make(1400, 1450);
55 } 55 }
56 56
57 void onDraw(SkCanvas* canvas) SK_OVERRIDE { 57 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
58 this->drawSceneColumn(canvas, SkPoint::Make(0, 0), 1, 1, 0); 58 this->drawSceneColumn(canvas, SkPoint::Make(0, 0), 1, 1, 0);
59 this->drawSceneColumn(canvas, SkPoint::Make(0, fSceneSize * 6.4f), 1, 2, 0); 59 this->drawSceneColumn(canvas, SkPoint::Make(0, fSceneSize * 6.4f), 1, 2, 0);
60 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, 0), 1, 1, 1); 60 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, 0), 1, 1, 1);
61 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, fSceneSiz e * 6.4f), 1, 1, 2); 61 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, fSceneSiz e * 6.4f), 1, 1, 2);
62 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 4.8f, 0), 2, 1, 0); 62 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 4.8f, 0), 2, 1, 0);
63 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 9.6f, 0), 2, 2, 0); 63 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 9.6f, 0), 2, 2, 0);
64
65 // One last custom row to exercise negative scaling
66 SkMatrix ctm, localMatrix;
67 ctm.setTranslate(fSceneSize * 2.1f, fSceneSize * 13.8f);
68 ctm.preScale(-1, -1);
69 localMatrix.setScale(2, 2);
70 this->drawScene(canvas, ctm, localMatrix, 0);
71
72 ctm.setTranslate(fSceneSize * 2.4f, fSceneSize * 12.8f);
73 localMatrix.setScale(-1, -1);
74 this->drawScene(canvas, ctm, localMatrix, 0);
75
76 ctm.setTranslate(fSceneSize * 4.8f, fSceneSize * 12.3f);
77 ctm.preScale(2, 2);
78 this->drawScene(canvas, ctm, localMatrix, 0);
79
80 ctm.setTranslate(fSceneSize * 13.8f, fSceneSize * 14.3f);
81 ctm.preScale(-2, -2);
82 localMatrix.setTranslate(fTileSize / 4, fTileSize / 4);
83 localMatrix.preRotate(45);
84 localMatrix.preScale(-2, -2);
85 this->drawScene(canvas, ctm, localMatrix, 0);
64 } 86 }
65 87
66 private: 88 private:
67 void drawSceneColumn(SkCanvas* canvas, const SkPoint& pos, SkScalar scale, S kScalar localScale, 89 void drawSceneColumn(SkCanvas* canvas, const SkPoint& pos, SkScalar scale, S kScalar localScale,
68 unsigned tileMode) { 90 unsigned tileMode) {
69 SkMatrix ctm, localMatrix; 91 SkMatrix ctm, localMatrix;
70 92
71 ctm.setTranslate(pos.x(), pos.y()); 93 ctm.setTranslate(pos.x(), pos.y());
72 ctm.preScale(scale, scale); 94 ctm.preScale(scale, scale);
73 localMatrix.setScale(localScale, localScale); 95 localMatrix.setScale(localScale, localScale);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 SkScalar fTileSize; 176 SkScalar fTileSize;
155 SkScalar fSceneSize; 177 SkScalar fSceneSize;
156 178
157 SkAutoTUnref<SkPicture> fPicture; 179 SkAutoTUnref<SkPicture> fPicture;
158 SkBitmap fBitmap; 180 SkBitmap fBitmap;
159 181
160 typedef GM INHERITED; 182 typedef GM INHERITED;
161 }; 183 };
162 184
163 DEF_GM( return SkNEW_ARGS(PictureShaderGM, (50, 100)); ) 185 DEF_GM( return SkNEW_ARGS(PictureShaderGM, (50, 100)); )
OLDNEW
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | src/core/SkPictureShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698