Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: gm/pictureshader.cpp

Issue 953383002: fuzzer fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix up width and height in initializer Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/picture.cpp ('k') | gm/shadows.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkPaint.h" 11 #include "SkPaint.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkPictureRecorder.h" 13 #include "SkPictureRecorder.h"
14 #include "SkShader.h" 14 #include "SkShader.h"
15 15
16 static struct { 16 static struct {
17 SkShader::TileMode tmx; 17 SkShader::TileMode tmx;
18 SkShader::TileMode tmy; 18 SkShader::TileMode tmy;
19 } kTileConfigs[] = { 19 } kTileConfigs[] = {
20 { SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode }, 20 { SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode },
21 { SkShader::kRepeat_TileMode, SkShader::kClamp_TileMode }, 21 { SkShader::kRepeat_TileMode, SkShader::kClamp_TileMode },
22 { SkShader::kMirror_TileMode, SkShader::kRepeat_TileMode }, 22 { SkShader::kMirror_TileMode, SkShader::kRepeat_TileMode },
23 }; 23 };
24 24
25 class PictureShaderGM : public skiagm::GM { 25 class PictureShaderGM : public skiagm::GM {
26 public: 26 public:
27 PictureShaderGM(SkScalar tileSize, SkScalar sceneSize) 27 PictureShaderGM(SkScalar tileSize, SkScalar sceneSize)
28 : fTileSize(tileSize) 28 : fTileSize(tileSize)
29 , fSceneSize(sceneSize) { 29 , fSceneSize(sceneSize) {
30 }
30 31
31 // Build the picture. 32 protected:
33 void onOnceBeforeDraw() SK_OVERRIDE {
34 // Build the picture.
32 SkPictureRecorder recorder; 35 SkPictureRecorder recorder;
33 SkCanvas* pictureCanvas = recorder.beginRecording(tileSize, tileSize, NU LL, 0); 36 SkCanvas* pictureCanvas = recorder.beginRecording(fTileSize, fTileSize, NULL, 0);
34 this->drawTile(pictureCanvas); 37 this->drawTile(pictureCanvas);
35 fPicture.reset(recorder.endRecording()); 38 fPicture.reset(recorder.endRecording());
36 39
37 // Build a reference bitmap. 40 // Build a reference bitmap.
38 fBitmap.allocN32Pixels(SkScalarCeilToInt(tileSize), SkScalarCeilToInt(ti leSize)); 41 fBitmap.allocN32Pixels(SkScalarCeilToInt(fTileSize), SkScalarCeilToInt(f TileSize));
39 fBitmap.eraseColor(SK_ColorTRANSPARENT); 42 fBitmap.eraseColor(SK_ColorTRANSPARENT);
40 SkCanvas bitmapCanvas(fBitmap); 43 SkCanvas bitmapCanvas(fBitmap);
41 this->drawTile(&bitmapCanvas); 44 this->drawTile(&bitmapCanvas);
42 } 45 }
43 46
44 protected:
45 47
46 SkString onShortName() SK_OVERRIDE { 48 SkString onShortName() SK_OVERRIDE {
47 return SkString("pictureshader"); 49 return SkString("pictureshader");
48 } 50 }
49 51
50 SkISize onISize() SK_OVERRIDE { 52 SkISize onISize() SK_OVERRIDE {
51 return SkISize::Make(1400, 1450); 53 return SkISize::Make(1400, 1450);
52 } 54 }
53 55
54 void onDraw(SkCanvas* canvas) SK_OVERRIDE { 56 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 p.setColor(0xFF8BC34A); // green 210 p.setColor(0xFF8BC34A); // green
209 canvas->drawPaint(p); 211 canvas->drawPaint(p);
210 212
211 canvas->clipRect(SkRect::MakeXYWH(0, 0, 400, 350)); 213 canvas->clipRect(SkRect::MakeXYWH(0, 0, 400, 350));
212 p.setColor(0xFFB6B6B6); // gray 214 p.setColor(0xFFB6B6B6); // gray
213 canvas->drawPaint(p); 215 canvas->drawPaint(p);
214 p.setShader(shader.get()); 216 p.setShader(shader.get());
215 217
216 canvas->drawPaint(p); 218 canvas->drawPaint(p);
217 } 219 }
OLDNEW
« no previous file with comments | « gm/picture.cpp ('k') | gm/shadows.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698