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

Side by Side Diff: gm/discard.cpp

Issue 1817383002: switch surface to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/dftext.cpp ('k') | gm/drawatlas.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" 10 #include "SkColorShader.h"
(...skipping 27 matching lines...) Expand all
38 void onDraw(SkCanvas* canvas) override { 38 void onDraw(SkCanvas* canvas) override {
39 GrContext* context = canvas->getGrContext(); 39 GrContext* context = canvas->getGrContext();
40 if (nullptr == context) { 40 if (nullptr == context) {
41 return; 41 return;
42 } 42 }
43 43
44 SkISize size = this->getISize(); 44 SkISize size = this->getISize();
45 size.fWidth /= 10; 45 size.fWidth /= 10;
46 size.fHeight /= 10; 46 size.fHeight /= 10;
47 SkImageInfo info = SkImageInfo::MakeN32Premul(size); 47 SkImageInfo info = SkImageInfo::MakeN32Premul(size);
48 SkSurface* surface = SkSurface::NewRenderTarget(context, SkBudgeted::kNo , info); 48 auto surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, inf o);
49
50 if (nullptr == surface) { 49 if (nullptr == surface) {
51 return; 50 return;
52 } 51 }
53 52
54 canvas->clear(SK_ColorBLACK); 53 canvas->clear(SK_ColorBLACK);
55 54
56 SkRandom rand; 55 SkRandom rand;
57 for (int x = 0; x < 10; ++x) { 56 for (int x = 0; x < 10; ++x) {
58 for (int y = 0; y < 10; ++y) { 57 for (int y = 0; y < 10; ++y) {
59 surface->getCanvas()->discard(); 58 surface->getCanvas()->discard();
(...skipping 11 matching lines...) Expand all
71 SkPaint paint; 70 SkPaint paint;
72 paint.setShader(&shader); 71 paint.setShader(&shader);
73 surface->getCanvas()->drawPaint(paint); 72 surface->getCanvas()->drawPaint(paint);
74 break; 73 break;
75 } 74 }
76 surface->draw(canvas, 10.f*x, 10.f*y, nullptr); 75 surface->draw(canvas, 10.f*x, 10.f*y, nullptr);
77 } 76 }
78 } 77 }
79 78
80 surface->getCanvas()->discard(); 79 surface->getCanvas()->discard();
81 surface->unref();
82 } 80 }
83 81
84 private: 82 private:
85 typedef GM INHERITED; 83 typedef GM INHERITED;
86 }; 84 };
87 85
88 ////////////////////////////////////////////////////////////////////////////// 86 //////////////////////////////////////////////////////////////////////////////
89 87
90 DEF_GM(return new DiscardGM;) 88 DEF_GM(return new DiscardGM;)
91 89
92 } // end namespace 90 } // end namespace
93 91
94 #endif 92 #endif
OLDNEW
« no previous file with comments | « gm/dftext.cpp ('k') | gm/drawatlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698