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

Side by Side Diff: gm/badpaint.cpp

Issue 1089063002: Don't draw if SkShader::asNewFragmentProcessor fails. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix crash in pipe Created 5 years, 8 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 | « no previous file | gm/constcolorprocessor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9 #include "SkCanvas.h"
10 #include "SkShader.h"
11
12
13 /** This GM draws with invalid paints. It should draw nothing other than the bac kground. */
14 class BadPaintGM : public skiagm::GM {
15 public:
16 BadPaintGM() {}
17
18 protected:
19 SkString onShortName() override { return SkString("badpaint"); }
20
21 SkISize onISize() override { return SkISize::Make(100, 100); }
22
23 void onOnceBeforeDraw() override {
24 SkBitmap emptyBmp;
25
26 SkBitmap blueBmp;
27 blueBmp.allocN32Pixels(10, 10);
28 blueBmp.eraseColor(SK_ColorBLUE);
29
30 SkMatrix badMatrix;
31 badMatrix.setAll(0, 0, 0, 0, 0, 0, 0, 0, 0);
32
33 #if 0 // This crashes pipe!
34 // Empty bitmap.
35 fPaints.push_back().setColor(SK_ColorGREEN);
36 fPaints.back().setShader(SkShader::CreateBitmapShader(emptyBmp, SkShader ::kClamp_TileMode,
37 SkShader::kClamp_T ileMode))->unref();
38 #endif
39
40 // Non-invertible local matrix.
41 fPaints.push_back().setColor(SK_ColorGREEN);
42 fPaints.back().setShader(SkShader::CreateBitmapShader(blueBmp, SkShader: :kClamp_TileMode,
43 SkShader::kClamp_T ileMode,
44 &badMatrix))->unre f();
45 }
46
47 void onDraw(SkCanvas* canvas) override {
48 SkRect rect = SkRect::MakeXYWH(10, 10, 80, 80);
49 for (int i = 0; i < fPaints.count(); ++i) {
50 canvas->drawRect(rect, fPaints[i]);
51 }
52 }
53
54 private:
55 SkTArray<SkPaint> fPaints;
56
57 typedef skiagm::GM INHERITED;
58 };
59
60 //////////////////////////////////////////////////////////////////////////////// /////
61
62 DEF_GM( return SkNEW(BadPaintGM); )
OLDNEW
« no previous file with comments | « no previous file | gm/constcolorprocessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698