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

Side by Side Diff: gm/discard.cpp

Issue 1829303002: move setshader to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: addressing comments from #8 Created 4 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/dcshader.cpp ('k') | gm/image.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 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorShader.h"
11 #include "SkPaint.h" 10 #include "SkPaint.h"
12 #include "SkRandom.h" 11 #include "SkRandom.h"
13 #include "SkSurface.h" 12 #include "SkSurface.h"
14 13
15 #if SK_SUPPORT_GPU 14 #if SK_SUPPORT_GPU
16 15
17 namespace skiagm { 16 namespace skiagm {
18 17
19 /* 18 /*
20 * This GM exercises SkCanvas::discard() by creating an offscreen SkSurface and repeatedly 19 * This GM exercises SkCanvas::discard() by creating an offscreen SkSurface and repeatedly
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // Make something that isn't too close to the background color, bl ack. 58 // Make something that isn't too close to the background color, bl ack.
60 SkColor color = sk_tool_utils::color_to_565(rand.nextU() | 0xFF404 040); 59 SkColor color = sk_tool_utils::color_to_565(rand.nextU() | 0xFF404 040);
61 switch (rand.nextULessThan(3)) { 60 switch (rand.nextULessThan(3)) {
62 case 0: 61 case 0:
63 surface->getCanvas()->drawColor(color); 62 surface->getCanvas()->drawColor(color);
64 break; 63 break;
65 case 1: 64 case 1:
66 surface->getCanvas()->clear(color); 65 surface->getCanvas()->clear(color);
67 break; 66 break;
68 case 2: 67 case 2:
69 SkColorShader shader(color);
70 SkPaint paint; 68 SkPaint paint;
71 paint.setShader(&shader); 69 paint.setShader(SkShader::MakeColorShader(color));
72 surface->getCanvas()->drawPaint(paint); 70 surface->getCanvas()->drawPaint(paint);
73 break; 71 break;
74 } 72 }
75 surface->draw(canvas, 10.f*x, 10.f*y, nullptr); 73 surface->draw(canvas, 10.f*x, 10.f*y, nullptr);
76 } 74 }
77 } 75 }
78 76
79 surface->getCanvas()->discard(); 77 surface->getCanvas()->discard();
80 } 78 }
81 79
82 private: 80 private:
83 typedef GM INHERITED; 81 typedef GM INHERITED;
84 }; 82 };
85 83
86 ////////////////////////////////////////////////////////////////////////////// 84 //////////////////////////////////////////////////////////////////////////////
87 85
88 DEF_GM(return new DiscardGM;) 86 DEF_GM(return new DiscardGM;)
89 87
90 } // end namespace 88 } // end namespace
91 89
92 #endif 90 #endif
OLDNEW
« no previous file with comments | « gm/dcshader.cpp ('k') | gm/image.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698