| 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" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 result->setImmutable(); | 79 result->setImmutable(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // This GM exercises the drawBitmapRectToRect "bleed" flag | 82 // This GM exercises the drawBitmapRectToRect "bleed" flag |
| 83 class BleedGM : public skiagm::GM { | 83 class BleedGM : public skiagm::GM { |
| 84 public: | 84 public: |
| 85 BleedGM() {} | 85 BleedGM() {} |
| 86 | 86 |
| 87 protected: | 87 protected: |
| 88 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 88 uint32_t onGetFlags() const SK_OVERRIDE { |
| 89 return kSkipTiled_Flag; | 89 return kSkipTiled_Flag; |
| 90 } | 90 } |
| 91 | 91 |
| 92 virtual SkString onShortName() SK_OVERRIDE { | 92 SkString onShortName() SK_OVERRIDE { |
| 93 return SkString("bleed"); | 93 return SkString("bleed"); |
| 94 } | 94 } |
| 95 | 95 |
| 96 virtual SkISize onISize() SK_OVERRIDE { | 96 SkISize onISize() SK_OVERRIDE { |
| 97 return SkISize::Make(kWidth, 780); | 97 return SkISize::Make(kWidth, 780); |
| 98 } | 98 } |
| 99 | 99 |
| 100 virtual void onOnceBeforeDraw() SK_OVERRIDE { | 100 void onOnceBeforeDraw() SK_OVERRIDE { |
| 101 make_ringed_bitmap(&fBitmapSmall, kSmallTextureSize, kSmallTextureSize); | 101 make_ringed_bitmap(&fBitmapSmall, kSmallTextureSize, kSmallTextureSize); |
| 102 | 102 |
| 103 // To exercise the GPU's tiling path we need a texture | 103 // To exercise the GPU's tiling path we need a texture |
| 104 // too big for the GPU to handle in one go | 104 // too big for the GPU to handle in one go |
| 105 make_ringed_bitmap(&fBitmapBig, 2*kMaxTextureSize, 2*kMaxTextureSize); | 105 make_ringed_bitmap(&fBitmapBig, 2*kMaxTextureSize, 2*kMaxTextureSize); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Draw only the center of the small bitmap | 108 // Draw only the center of the small bitmap |
| 109 void drawCase1(SkCanvas* canvas, int transX, int transY, | 109 void drawCase1(SkCanvas* canvas, int transX, int transY, |
| 110 SkCanvas::DrawBitmapRectFlags flags, SkPaint::FilterLevel fil
ter) { | 110 SkCanvas::DrawBitmapRectFlags flags, SkPaint::FilterLevel fil
ter) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, | 169 SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, |
| 170 SkBlurMask::ConvertRadiusToSigma(SkIntT
oScalar(3))); | 170 SkBlurMask::ConvertRadiusToSigma(SkIntT
oScalar(3))); |
| 171 paint.setMaskFilter(mf)->unref(); | 171 paint.setMaskFilter(mf)->unref(); |
| 172 | 172 |
| 173 canvas->save(); | 173 canvas->save(); |
| 174 canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY)); | 174 canvas->translate(SkIntToScalar(transX), SkIntToScalar(transY)); |
| 175 canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint, flags); | 175 canvas->drawBitmapRectToRect(fBitmapSmall, &src, dst, &paint, flags); |
| 176 canvas->restore(); | 176 canvas->restore(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 179 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 180 | 180 |
| 181 canvas->clear(SK_ColorGRAY); | 181 canvas->clear(SK_ColorGRAY); |
| 182 | 182 |
| 183 for (int m = 0; m < 2; ++m) { | 183 for (int m = 0; m < 2; ++m) { |
| 184 canvas->save(); | 184 canvas->save(); |
| 185 if (m) { | 185 if (m) { |
| 186 static const SkScalar kBottom = SkIntToScalar(kRow3Y + kBlockSiz
e + kBlockSpacing); | 186 static const SkScalar kBottom = SkIntToScalar(kRow3Y + kBlockSiz
e + kBlockSpacing); |
| 187 canvas->translate(0, kBottom); | 187 canvas->translate(0, kBottom); |
| 188 SkMatrix rotate; | 188 SkMatrix rotate; |
| 189 rotate.setRotate(15.f, 0, kBottom + kBlockSpacing); | 189 rotate.setRotate(15.f, 0, kBottom + kBlockSpacing); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 static const int kSmallTextureSize = 6; | 273 static const int kSmallTextureSize = 6; |
| 274 static const int kMaxTextureSize = 32; | 274 static const int kMaxTextureSize = 32; |
| 275 | 275 |
| 276 SkBitmap fBitmapSmall; | 276 SkBitmap fBitmapSmall; |
| 277 SkBitmap fBitmapBig; | 277 SkBitmap fBitmapBig; |
| 278 | 278 |
| 279 typedef GM INHERITED; | 279 typedef GM INHERITED; |
| 280 }; | 280 }; |
| 281 | 281 |
| 282 DEF_GM( return new BleedGM(); ) | 282 DEF_GM( return new BleedGM(); ) |
| OLD | NEW |