| OLD | NEW |
| 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 #include "GrUtils.h" |
| 15 #endif | 16 #endif |
| 16 | 17 |
| 17 // Create a black&white checked texture with 2 1-pixel rings | 18 // Create a black&white checked texture with 2 1-pixel rings |
| 18 // around the outside edge. The inner ring is red and the outer ring is blue. | 19 // around the outside edge. The inner ring is red and the outer ring is blue. |
| 19 static void make_ringed_bitmap(SkBitmap* result, int width, int height) { | 20 static void make_ringed_bitmap(SkBitmap* result, int width, int height) { |
| 20 SkASSERT(0 == width % 2 && 0 == height % 2); | 21 SkASSERT(0 == width % 2 && 0 == height % 2); |
| 21 | 22 |
| 22 static const SkPMColor kRed = SkPreMultiplyColor(SK_ColorRED); | 23 static const SkPMColor kRed = SkPreMultiplyColor(SK_ColorRED); |
| 23 static const SkPMColor kBlue = SkPreMultiplyColor(SK_ColorBLUE); | 24 static const SkPMColor kBlue = SkPreMultiplyColor(SK_ColorBLUE); |
| 24 static const SkPMColor kBlack = SkPreMultiplyColor(SK_ColorBLACK); | 25 static const SkPMColor kBlack = SkPreMultiplyColor(SK_ColorBLACK); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 this->drawCase3(canvas, kCol1X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kLow_FilterLevel); | 195 this->drawCase3(canvas, kCol1X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kLow_FilterLevel); |
| 195 this->drawCase4(canvas, kCol1X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kLow_FilterLevel); | 196 this->drawCase4(canvas, kCol1X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kLow_FilterLevel); |
| 196 | 197 |
| 197 // Then draw a column with no bleeding or tiling but with high filtering | 198 // Then draw a column with no bleeding or tiling but with high filtering |
| 198 this->drawCase1(canvas, kCol2X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kHigh_FilterLevel); | 199 this->drawCase1(canvas, kCol2X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kHigh_FilterLevel); |
| 199 this->drawCase2(canvas, kCol2X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kHigh_FilterLevel); | 200 this->drawCase2(canvas, kCol2X, kRow1Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kHigh_FilterLevel); |
| 200 this->drawCase3(canvas, kCol2X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kHigh_FilterLevel); | 201 this->drawCase3(canvas, kCol2X, kRow2Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kHigh_FilterLevel); |
| 201 this->drawCase4(canvas, kCol2X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kHigh_FilterLevel); | 202 this->drawCase4(canvas, kCol2X, kRow3Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kHigh_FilterLevel); |
| 202 | 203 |
| 203 #if SK_SUPPORT_GPU | 204 #if SK_SUPPORT_GPU |
| 204 GrContext* ctx = GM::GetGr(canvas); | 205 GrContext* ctx = GrUtils::GetGr(canvas); |
| 205 int oldMaxTextureSize = 0; | 206 int oldMaxTextureSize = 0; |
| 206 if (NULL != ctx) { | 207 if (NULL != ctx) { |
| 207 // shrink the max texture size so all our textures can be reasonably
sized | 208 // shrink the max texture size so all our textures can be reasonably
sized |
| 208 oldMaxTextureSize = ctx->getMaxTextureSize(); | 209 oldMaxTextureSize = ctx->getMaxTextureSize(); |
| 209 ctx->setMaxTextureSizeOverride(kMaxTextureSize); | 210 ctx->setMaxTextureSizeOverride(kMaxTextureSize); |
| 210 } | 211 } |
| 211 #endif | 212 #endif |
| 212 | 213 |
| 213 // Then draw a column with no bleeding but with tiling and low filtering | 214 // Then draw a column with no bleeding but with tiling and low filtering |
| 214 this->drawCase1(canvas, kCol3X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kLow_FilterLevel); | 215 this->drawCase1(canvas, kCol3X, kRow0Y, SkCanvas::kNone_DrawBitmapRectFl
ag, SkPaint::kLow_FilterLevel); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 static const int kSmallTextureSize = 6; | 264 static const int kSmallTextureSize = 6; |
| 264 static const int kMaxTextureSize = 32; | 265 static const int kMaxTextureSize = 32; |
| 265 | 266 |
| 266 SkBitmap fBitmapSmall; | 267 SkBitmap fBitmapSmall; |
| 267 SkBitmap fBitmapBig; | 268 SkBitmap fBitmapBig; |
| 268 | 269 |
| 269 typedef GM INHERITED; | 270 typedef GM INHERITED; |
| 270 }; | 271 }; |
| 271 | 272 |
| 272 DEF_GM( return new BleedGM(); ) | 273 DEF_GM( return new BleedGM(); ) |
| OLD | NEW |