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

Side by Side Diff: gm/drawatlascolor.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 | « gm/drawatlas.cpp ('k') | no next file » | 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 SkISize onISize() override { 67 SkISize onISize() override {
68 return SkISize::Make(kNumXferModes * (kAtlasSize + kPad) + kPad, 68 return SkISize::Make(kNumXferModes * (kAtlasSize + kPad) + kPad,
69 2 * kNumColors * (kAtlasSize + kPad) + kTextPad + k Pad); 69 2 * kNumColors * (kAtlasSize + kPad) + kTextPad + k Pad);
70 } 70 }
71 71
72 void onDraw(SkCanvas* canvas) override { 72 void onDraw(SkCanvas* canvas) override {
73 const SkRect target = SkRect::MakeWH(SkIntToScalar(kAtlasSize), SkIntToS calar(kAtlasSize)); 73 const SkRect target = SkRect::MakeWH(SkIntToScalar(kAtlasSize), SkIntToS calar(kAtlasSize));
74 74
75 if (nullptr == fAtlas) { 75 auto atlas = make_atlas(canvas, kAtlasSize);
76 fAtlas = make_atlas(canvas, kAtlasSize);
77 }
78 76
79 const struct { 77 const struct {
80 SkXfermode::Mode fMode; 78 SkXfermode::Mode fMode;
81 const char* fLabel; 79 const char* fLabel;
82 } gModes[] = { 80 } gModes[] = {
83 { SkXfermode::kClear_Mode, "Clear" }, 81 { SkXfermode::kClear_Mode, "Clear" },
84 { SkXfermode::kSrc_Mode, "Src" }, 82 { SkXfermode::kSrc_Mode, "Src" },
85 { SkXfermode::kDst_Mode, "Dst" }, 83 { SkXfermode::kDst_Mode, "Dst" },
86 { SkXfermode::kSrcOver_Mode, "SrcOver" }, 84 { SkXfermode::kSrcOver_Mode, "SrcOver" },
87 { SkXfermode::kDstOver_Mode, "DstOver" }, 85 { SkXfermode::kDstOver_Mode, "DstOver" },
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 canvas->drawText(gModes[i].fLabel, strlen(gModes[i].fLabel), 142 canvas->drawText(gModes[i].fLabel, strlen(gModes[i].fLabel),
145 i*(target.width()+kPad)+kPad, SkIntToScalar(kTextPa d), 143 i*(target.width()+kPad)+kPad, SkIntToScalar(kTextPa d),
146 textP); 144 textP);
147 } 145 }
148 146
149 for (int i = 0; i < numModes; ++i) { 147 for (int i = 0; i < numModes; ++i) {
150 canvas->save(); 148 canvas->save();
151 canvas->translate(SkIntToScalar(i*(target.height()+kPad)), 149 canvas->translate(SkIntToScalar(i*(target.height()+kPad)),
152 SkIntToScalar(kTextPad+kPad)); 150 SkIntToScalar(kTextPad+kPad));
153 // w/o a paint 151 // w/o a paint
154 canvas->drawAtlas(fAtlas.get(), xforms, rects, quadColors, numColors , 152 canvas->drawAtlas(atlas.get(), xforms, rects, quadColors, numColors,
155 gModes[i].fMode, nullptr, nullptr); 153 gModes[i].fMode, nullptr, nullptr);
156 canvas->translate(0.0f, numColors*(target.height()+kPad)); 154 canvas->translate(0.0f, numColors*(target.height()+kPad));
157 // w a paint 155 // w a paint
158 canvas->drawAtlas(fAtlas.get(), xforms, rects, quadColors, numColors , 156 canvas->drawAtlas(atlas.get(), xforms, rects, quadColors, numColors,
159 gModes[i].fMode, nullptr, &paint); 157 gModes[i].fMode, nullptr, &paint);
160 canvas->restore(); 158 canvas->restore();
161 } 159 }
162 } 160 }
163 161
164 private: 162 private:
165 static constexpr int kNumXferModes = 29; 163 static constexpr int kNumXferModes = 29;
166 static constexpr int kNumColors = 4; 164 static constexpr int kNumColors = 4;
167 static constexpr int kAtlasSize = 30; 165 static constexpr int kAtlasSize = 30;
168 static constexpr int kPad = 2; 166 static constexpr int kPad = 2;
169 static constexpr int kTextPad = 8; 167 static constexpr int kTextPad = 8;
170 168
171
172 sk_sp<SkImage> fAtlas;
173
174 typedef GM INHERITED; 169 typedef GM INHERITED;
175 }; 170 };
176 DEF_GM( return new DrawAtlasColorsGM; ) 171 DEF_GM( return new DrawAtlasColorsGM; )
OLDNEW
« no previous file with comments | « gm/drawatlas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698