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

Side by Side Diff: gm/bleed.cpp

Issue 23567032: Have GMs read the GrContext via a setter/getter rather than a global. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: use Brian's suggestion Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gm/gm.h » ('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 2013 Google Inc. 2 * Copyright 2013 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 "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 12
13 #if SK_SUPPORT_GPU 13 #if SK_SUPPORT_GPU
14 #include "GrContext.h" 14 #include "GrContext.h"
15
16 namespace skiagm {
17 extern GrContext* GetGr();
18 };
19 #endif 15 #endif
20 16
21 // Create a black&white checked texture with a 1-pixel red ring 17 // Create a black&white checked texture with a 1-pixel red ring
22 // around the outside edge 18 // around the outside edge
23 static void make_red_ringed_bitmap(SkBitmap* result, int width, int height) { 19 static void make_red_ringed_bitmap(SkBitmap* result, int width, int height) {
24 SkASSERT(0 == width % 2 && 0 == width % 2); 20 SkASSERT(0 == width % 2 && 0 == width % 2);
25 21
26 result->setConfig(SkBitmap::kARGB_8888_Config, width, height); 22 result->setConfig(SkBitmap::kARGB_8888_Config, width, height);
27 result->allocPixels(); 23 result->allocPixels();
28 SkAutoLockPixels lock(*result); 24 SkAutoLockPixels lock(*result);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 this->drawCase4(canvas, kCol0X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFl ag, false); 164 this->drawCase4(canvas, kCol0X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFl ag, false);
169 165
170 // Then draw a column with no bleeding or tiling but with filtering 166 // Then draw a column with no bleeding or tiling but with filtering
171 this->drawCase1(canvas, kCol1X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFl ag, true); 167 this->drawCase1(canvas, kCol1X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFl ag, true);
172 this->drawCase2(canvas, kCol1X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFl ag, true); 168 this->drawCase2(canvas, kCol1X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFl ag, true);
173 this->drawCase3(canvas, kCol1X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFl ag, true); 169 this->drawCase3(canvas, kCol1X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFl ag, true);
174 this->drawCase4(canvas, kCol1X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFl ag, true); 170 this->drawCase4(canvas, kCol1X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFl ag, true);
175 171
176 172
177 #if SK_SUPPORT_GPU 173 #if SK_SUPPORT_GPU
178 GrContext* ctx = skiagm::GetGr(); 174 GrContext* ctx = GM::GetGr(canvas);
179 int oldMaxTextureSize = 0; 175 int oldMaxTextureSize = 0;
180 if (NULL != ctx) { 176 if (NULL != ctx) {
181 // shrink the max texture size so all our textures can be reasonably sized 177 // shrink the max texture size so all our textures can be reasonably sized
182 oldMaxTextureSize = ctx->getMaxTextureSize(); 178 oldMaxTextureSize = ctx->getMaxTextureSize();
183 ctx->setMaxTextureSizeOverride(kMaxTextureSize); 179 ctx->setMaxTextureSizeOverride(kMaxTextureSize);
184 } 180 }
185 #endif 181 #endif
186 182
187 // Then draw a column with no bleeding but with tiling and filtering 183 // Then draw a column with no bleeding but with tiling and filtering
188 this->drawCase1(canvas, kCol2X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFl ag, true); 184 this->drawCase1(canvas, kCol2X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFl ag, true);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 static const int kSmallTextureSize = 4; 218 static const int kSmallTextureSize = 4;
223 static const int kMaxTextureSize = 32; 219 static const int kMaxTextureSize = 32;
224 220
225 SkBitmap fBitmapSmall; 221 SkBitmap fBitmapSmall;
226 SkBitmap fBitmapBig; 222 SkBitmap fBitmapBig;
227 223
228 typedef GM INHERITED; 224 typedef GM INHERITED;
229 }; 225 };
230 226
231 DEF_GM( return new BleedGM(); ) 227 DEF_GM( return new BleedGM(); )
OLDNEW
« no previous file with comments | « no previous file | gm/gm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698