| 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 #endif | 15 #endif |
| 16 | 16 |
| 17 // 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 |
| 18 // around the outside edge | 18 // around the outside edge |
| 19 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) { |
| 20 SkASSERT(0 == width % 2 && 0 == width % 2); | 20 SkASSERT(0 == width % 2 && 0 == width % 2); |
| 21 | 21 |
| 22 result->setConfig(SkBitmap::kARGB_8888_Config, width, height); | 22 result->setConfig(SkBitmap::kARGB_8888_Config, width, height, 0, |
| 23 kOpaque_SkAlphaType); |
| 23 result->allocPixels(); | 24 result->allocPixels(); |
| 24 SkAutoLockPixels lock(*result); | 25 SkAutoLockPixels lock(*result); |
| 25 | 26 |
| 26 SkPMColor* scanline = result->getAddr32(0, 0); | 27 SkPMColor* scanline = result->getAddr32(0, 0); |
| 27 for (int x = 0; x < width; ++x) { | 28 for (int x = 0; x < width; ++x) { |
| 28 scanline[x] = SK_ColorRED; | 29 scanline[x] = SK_ColorRED; |
| 29 } | 30 } |
| 30 | 31 |
| 31 for (int y = 1; y < height/2; ++y) { | 32 for (int y = 1; y < height/2; ++y) { |
| 32 scanline = result->getAddr32(0, y); | 33 scanline = result->getAddr32(0, y); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 49 for (int x = width/2; x < width-1; ++x) { | 50 for (int x = width/2; x < width-1; ++x) { |
| 50 scanline[x] = SK_ColorBLACK; | 51 scanline[x] = SK_ColorBLACK; |
| 51 } | 52 } |
| 52 scanline[width-1] = SK_ColorRED; | 53 scanline[width-1] = SK_ColorRED; |
| 53 } | 54 } |
| 54 | 55 |
| 55 scanline = result->getAddr32(0, height-1); | 56 scanline = result->getAddr32(0, height-1); |
| 56 for (int x = 0; x < width; ++x) { | 57 for (int x = 0; x < width; ++x) { |
| 57 scanline[x] = SK_ColorRED; | 58 scanline[x] = SK_ColorRED; |
| 58 } | 59 } |
| 59 result->setIsOpaque(true); | |
| 60 result->setImmutable(); | 60 result->setImmutable(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // This GM exercises the drawBitmapRectToRect "bleed" flag | 63 // This GM exercises the drawBitmapRectToRect "bleed" flag |
| 64 class BleedGM : public skiagm::GM { | 64 class BleedGM : public skiagm::GM { |
| 65 public: | 65 public: |
| 66 BleedGM() {} | 66 BleedGM() {} |
| 67 | 67 |
| 68 protected: | 68 protected: |
| 69 virtual SkString onShortName() SK_OVERRIDE { | 69 virtual SkString onShortName() SK_OVERRIDE { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 static const int kSmallTextureSize = 4; | 218 static const int kSmallTextureSize = 4; |
| 219 static const int kMaxTextureSize = 32; | 219 static const int kMaxTextureSize = 32; |
| 220 | 220 |
| 221 SkBitmap fBitmapSmall; | 221 SkBitmap fBitmapSmall; |
| 222 SkBitmap fBitmapBig; | 222 SkBitmap fBitmapBig; |
| 223 | 223 |
| 224 typedef GM INHERITED; | 224 typedef GM INHERITED; |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 DEF_GM( return new BleedGM(); ) | 227 DEF_GM( return new BleedGM(); ) |
| OLD | NEW |