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

Side by Side Diff: gm/drawatlas.cpp

Issue 2381893004: Remove caching from the draw-atlas GMs. Fixes bugs cycling backends. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | gm/drawatlascolor.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 2015 Google Inc. 2 * Copyright 2015 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 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkRSXform.h" 10 #include "SkRSXform.h"
(...skipping 17 matching lines...) Expand all
28 r.inset(-1, -1); 28 r.inset(-1, -1);
29 // zero out a place (with a 1-pixel border) to land our drawing. 29 // zero out a place (with a 1-pixel border) to land our drawing.
30 canvas->drawRect(r, paint); 30 canvas->drawRect(r, paint);
31 paint.setXfermode(nullptr); 31 paint.setXfermode(nullptr);
32 paint.setColor(SK_ColorBLUE); 32 paint.setColor(SK_ColorBLUE);
33 paint.setAntiAlias(true); 33 paint.setAntiAlias(true);
34 canvas->drawOval(target, paint); 34 canvas->drawOval(target, paint);
35 return surface->makeImageSnapshot(); 35 return surface->makeImageSnapshot();
36 } 36 }
37 37
38 sk_sp<SkImage> fAtlas;
39
40 public: 38 public:
41 DrawAtlasGM() {} 39 DrawAtlasGM() {}
42 40
43 protected: 41 protected:
44 42
45 SkString onShortName() override { 43 SkString onShortName() override {
46 return SkString("draw-atlas"); 44 return SkString("draw-atlas");
47 } 45 }
48 46
49 SkISize onISize() override { 47 SkISize onISize() override {
50 return SkISize::Make(640, 480); 48 return SkISize::Make(640, 480);
51 } 49 }
52 50
53 void onDraw(SkCanvas* canvas) override { 51 void onDraw(SkCanvas* canvas) override {
54 const SkRect target = { 50, 50, 80, 90 }; 52 const SkRect target = { 50, 50, 80, 90 };
55 if (nullptr == fAtlas) { 53 auto atlas = MakeAtlas(canvas, target);
56 fAtlas = MakeAtlas(canvas, target);
57 }
58 54
59 const struct { 55 const struct {
60 SkScalar fScale; 56 SkScalar fScale;
61 SkScalar fDegrees; 57 SkScalar fDegrees;
62 SkScalar fTx; 58 SkScalar fTx;
63 SkScalar fTy; 59 SkScalar fTy;
64 60
65 void apply(SkRSXform* xform) const { 61 void apply(SkRSXform* xform) const {
66 const SkScalar rad = SkDegreesToRadians(fDegrees); 62 const SkScalar rad = SkDegreesToRadians(fDegrees);
67 xform->fSCos = fScale * SkScalarCos(rad); 63 xform->fSCos = fScale * SkScalarCos(rad);
(...skipping 16 matching lines...) Expand all
84 for (int i = 0; i < N; ++i) { 80 for (int i = 0; i < N; ++i) {
85 rec[i].apply(&xform[i]); 81 rec[i].apply(&xform[i]);
86 tex[i] = target; 82 tex[i] = target;
87 colors[i] = 0x80FF0000 + (i * 40 * 256); 83 colors[i] = 0x80FF0000 + (i * 40 * 256);
88 } 84 }
89 85
90 SkPaint paint; 86 SkPaint paint;
91 paint.setFilterQuality(kLow_SkFilterQuality); 87 paint.setFilterQuality(kLow_SkFilterQuality);
92 paint.setAntiAlias(true); 88 paint.setAntiAlias(true);
93 89
94 canvas->drawAtlas(fAtlas.get(), xform, tex, N, nullptr, &paint); 90 canvas->drawAtlas(atlas.get(), xform, tex, N, nullptr, &paint);
95 canvas->translate(0, 100); 91 canvas->translate(0, 100);
96 canvas->drawAtlas(fAtlas.get(), xform, tex, colors, N, SkXfermode::kSrcI n_Mode, nullptr, &paint); 92 canvas->drawAtlas(atlas.get(), xform, tex, colors, N, SkXfermode::kSrcIn _Mode, nullptr, &paint);
97 } 93 }
98 94
99 private: 95 private:
100 typedef GM INHERITED; 96 typedef GM INHERITED;
101 }; 97 };
102 DEF_GM( return new DrawAtlasGM; ) 98 DEF_GM( return new DrawAtlasGM; )
103 99
104 //////////////////////////////////////////////////////////////////////////////// /////////////////// 100 //////////////////////////////////////////////////////////////////////////////// ///////////////////
105 #include "SkPath.h" 101 #include "SkPath.h"
106 #include "SkPathMeasure.h" 102 #include "SkPathMeasure.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 SkPath path; 161 SkPath path;
166 path.addOval(SkRect::MakeXYWH(160, 160, 540, 540)); 162 path.addOval(SkRect::MakeXYWH(160, 160, 540, 540));
167 163
168 draw_text_on_path_rigid(canvas, text0, N, pos, path, paint); 164 draw_text_on_path_rigid(canvas, text0, N, pos, path, paint);
169 165
170 paint.setStyle(SkPaint::kStroke_Style); 166 paint.setStyle(SkPaint::kStroke_Style);
171 canvas->drawPath(path, paint); 167 canvas->drawPath(path, paint);
172 } 168 }
173 169
174 170
OLDNEW
« no previous file with comments | « no previous file | gm/drawatlascolor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698