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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 &paint); | 89 &paint); |
90 } | 90 } |
91 | 91 |
92 /////////////////////////////////////////////////////////////////////////////// | 92 /////////////////////////////////////////////////////////////////////////////// |
93 | 93 |
94 class ImageFiltersCroppedGM : public skiagm::GM { | 94 class ImageFiltersCroppedGM : public skiagm::GM { |
95 public: | 95 public: |
96 ImageFiltersCroppedGM () {} | 96 ImageFiltersCroppedGM () {} |
97 | 97 |
98 protected: | 98 protected: |
99 virtual SkString onShortName() SK_OVERRIDE { | 99 virtual SkString onShortName() override { |
100 return SkString("imagefilterscropped"); | 100 return SkString("imagefilterscropped"); |
101 } | 101 } |
102 | 102 |
103 virtual SkISize onISize() SK_OVERRIDE { return SkISize::Make(400, 880); } | 103 virtual SkISize onISize() override { return SkISize::Make(400, 880); } |
104 | 104 |
105 void make_checkerboard() { | 105 void make_checkerboard() { |
106 fCheckerboard.allocN32Pixels(80, 80); | 106 fCheckerboard.allocN32Pixels(80, 80); |
107 SkCanvas canvas(fCheckerboard); | 107 SkCanvas canvas(fCheckerboard); |
108 canvas.clear(SK_ColorTRANSPARENT); | 108 canvas.clear(SK_ColorTRANSPARENT); |
109 SkPaint darkPaint; | 109 SkPaint darkPaint; |
110 darkPaint.setColor(0xFF404040); | 110 darkPaint.setColor(0xFF404040); |
111 SkPaint lightPaint; | 111 SkPaint lightPaint; |
112 lightPaint.setColor(0xFFA0A0A0); | 112 lightPaint.setColor(0xFFA0A0A0); |
113 for (int y = 0; y < 80; y += 16) { | 113 for (int y = 0; y < 80; y += 16) { |
114 for (int x = 0; x < 80; x += 16) { | 114 for (int x = 0; x < 80; x += 16) { |
115 canvas.save(); | 115 canvas.save(); |
116 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); | 116 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); |
117 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); | 117 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); |
118 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint); | 118 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint); |
119 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint); | 119 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint); |
120 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint); | 120 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint); |
121 canvas.restore(); | 121 canvas.restore(); |
122 } | 122 } |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 void draw_frame(SkCanvas* canvas, const SkRect& r) { | 126 void draw_frame(SkCanvas* canvas, const SkRect& r) { |
127 SkPaint paint; | 127 SkPaint paint; |
128 paint.setStyle(SkPaint::kStroke_Style); | 128 paint.setStyle(SkPaint::kStroke_Style); |
129 paint.setColor(SK_ColorRED); | 129 paint.setColor(SK_ColorRED); |
130 canvas->drawRect(r, paint); | 130 canvas->drawRect(r, paint); |
131 } | 131 } |
132 | 132 |
133 virtual void onOnceBeforeDraw() SK_OVERRIDE{ | 133 virtual void onOnceBeforeDraw() override{ |
134 make_checkerboard(); | 134 make_checkerboard(); |
135 } | 135 } |
136 | 136 |
137 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 137 virtual void onDraw(SkCanvas* canvas) override { |
138 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = { | 138 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = { |
139 draw_sprite, draw_bitmap, draw_path, draw_paint, draw_text | 139 draw_sprite, draw_bitmap, draw_path, draw_paint, draw_text |
140 }; | 140 }; |
141 | 141 |
142 SkAutoTUnref<SkColorFilter> cf( | 142 SkAutoTUnref<SkColorFilter> cf( |
143 SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mod
e)); | 143 SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mod
e)); |
144 SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10,
44, 44)), SkImageFilter::CropRect::kHasAll_CropEdge); | 144 SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10,
44, 44)), SkImageFilter::CropRect::kHasAll_CropEdge); |
145 SkImageFilter::CropRect bogusRect(SkRect::Make(SkIRect::MakeXYWH(-100, -
100, 10, 10)), SkImageFilter::CropRect::kHasAll_CropEdge); | 145 SkImageFilter::CropRect bogusRect(SkRect::Make(SkIRect::MakeXYWH(-100, -
100, 10, 10)), SkImageFilter::CropRect::kHasAll_CropEdge); |
146 | 146 |
147 SkAutoTUnref<SkImageFilter> offset(SkOffsetImageFilter::Create( | 147 SkAutoTUnref<SkImageFilter> offset(SkOffsetImageFilter::Create( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 private: | 194 private: |
195 SkBitmap fCheckerboard; | 195 SkBitmap fCheckerboard; |
196 typedef GM INHERITED; | 196 typedef GM INHERITED; |
197 }; | 197 }; |
198 | 198 |
199 /////////////////////////////////////////////////////////////////////////////// | 199 /////////////////////////////////////////////////////////////////////////////// |
200 | 200 |
201 static skiagm::GM* MyFactory(void*) { return new ImageFiltersCroppedGM; } | 201 static skiagm::GM* MyFactory(void*) { return new ImageFiltersCroppedGM; } |
202 static skiagm::GMRegistry reg(MyFactory); | 202 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |