| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBlurDrawLooper.h" | 9 #include "SkBlurDrawLooper.h" |
| 10 #include "SkBlurMask.h" | 10 #include "SkBlurMask.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } else { | 21 } else { |
| 22 paint->setStyle(SkPaint::kStroke_Style); | 22 paint->setStyle(SkPaint::kStroke_Style); |
| 23 paint->setStrokeWidth(strokeWidth); | 23 paint->setStrokeWidth(strokeWidth); |
| 24 } | 24 } |
| 25 } | 25 } |
| 26 | 26 |
| 27 class ShadowsGM : public GM { | 27 class ShadowsGM : public GM { |
| 28 public: | 28 public: |
| 29 SkPath fCirclePath; | 29 SkPath fCirclePath; |
| 30 SkRect fRect; | 30 SkRect fRect; |
| 31 SkBitmap fBitmap; |
| 31 | 32 |
| 32 protected: | 33 protected: |
| 33 void onOnceBeforeDraw() override { | 34 void onOnceBeforeDraw() override { |
| 34 this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); | 35 this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); |
| 35 fCirclePath.addCircle(SkIntToScalar(20), SkIntToScalar(20), SkIntToScala
r(10) ); | 36 fCirclePath.addCircle(SkIntToScalar(20), SkIntToScalar(20), SkIntToScala
r(10) ); |
| 36 fRect.set(SkIntToScalar(10), SkIntToScalar(10), | 37 fRect.set(SkIntToScalar(10), SkIntToScalar(10), |
| 37 SkIntToScalar(30), SkIntToScalar(30)); | 38 SkIntToScalar(30), SkIntToScalar(30)); |
| 39 fBitmap.allocPixels(SkImageInfo::Make(20, 20, SkColorType::kAlpha_8_SkCo
lorType, |
| 40 kPremul_SkAlphaType)); |
| 41 SkCanvas canvas(fBitmap); |
| 42 canvas.clear(0x0); |
| 43 SkPaint p; |
| 44 canvas.drawRect(SkRect::MakeXYWH(10, 0, 10, 10), p); |
| 45 canvas.drawRect(SkRect::MakeXYWH(0, 10, 10, 10), p); |
| 38 } | 46 } |
| 39 | 47 |
| 40 SkString onShortName() override { | 48 SkString onShortName() override { |
| 41 return SkString("shadows"); | 49 return SkString("shadows"); |
| 42 } | 50 } |
| 43 | 51 |
| 44 SkISize onISize() override { | 52 SkISize onISize() override { |
| 45 return SkISize::Make(200, 120); | 53 return SkISize::Make(200, 120); |
| 46 } | 54 } |
| 47 | 55 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 setup(&paint, gRec[0].fColor, gRec[0].fStrokeWidth); | 114 setup(&paint, gRec[0].fColor, gRec[0].fStrokeWidth); |
| 107 canvas->drawRect(fRect, paint); | 115 canvas->drawRect(fRect, paint); |
| 108 | 116 |
| 109 canvas->translate(SkIntToScalar(0), SkIntToScalar(40)); | 117 canvas->translate(SkIntToScalar(0), SkIntToScalar(40)); |
| 110 setup(&paint, gRec[1].fColor, gRec[1].fStrokeWidth); | 118 setup(&paint, gRec[1].fColor, gRec[1].fStrokeWidth); |
| 111 canvas->drawPath(fCirclePath, paint); | 119 canvas->drawPath(fCirclePath, paint); |
| 112 | 120 |
| 113 canvas->translate(SkIntToScalar(0), SkIntToScalar(40)); | 121 canvas->translate(SkIntToScalar(0), SkIntToScalar(40)); |
| 114 setup(&paint, gRec[2].fColor, gRec[2].fStrokeWidth); | 122 setup(&paint, gRec[2].fColor, gRec[2].fStrokeWidth); |
| 115 canvas->drawPath(fCirclePath, paint); | 123 canvas->drawPath(fCirclePath, paint); |
| 124 |
| 125 // see bug.skia.org/562 (reference, draws correct) |
| 126 canvas->translate(0, 40); |
| 127 paint.setColor(SK_ColorBLACK); |
| 128 canvas->drawBitmap(fBitmap, 10, 10, &paint); |
| 129 |
| 130 canvas->translate(0, 40); |
| 131 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader( |
| 132 fBitmap, SkShader::kRepeat_TileMode, |
| 133 SkShader::kRepeat_TileMode)); |
| 134 |
| 135 // see bug.skia.org/562 (shows bug as reported) |
| 136 paint.setShader(shader); |
| 137 paint.setStyle(SkPaint::kFill_Style); |
| 138 canvas->drawRect(SkRect::MakeXYWH(10, 10, 20, 20), paint); |
| 139 paint.setShader(nullptr); |
| 116 } | 140 } |
| 117 } | 141 } |
| 118 | 142 |
| 119 private: | 143 private: |
| 120 typedef GM INHERITED; | 144 typedef GM INHERITED; |
| 121 }; | 145 }; |
| 122 | 146 |
| 123 /////////////////////////////////////////////////////////////////////////////// | 147 /////////////////////////////////////////////////////////////////////////////// |
| 124 | 148 |
| 125 static GM* MyFactory(void*) { return new ShadowsGM; } | 149 static GM* MyFactory(void*) { return new ShadowsGM; } |
| 126 static GMRegistry reg(MyFactory); | 150 static GMRegistry reg(MyFactory); |
| 127 | 151 |
| 128 } | 152 } |
| OLD | NEW |