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

Side by Side Diff: gm/imagealphathreshold.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/image_shader.cpp ('k') | gm/imagefilters.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 2013 Google Inc. 2 * Copyright 2013 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 "SkAlphaThresholdFilter.h" 9 #include "SkAlphaThresholdFilter.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 SkString onShortName() override { 88 SkString onShortName() override {
89 return SkString("imagealphathreshold_surface"); 89 return SkString("imagealphathreshold_surface");
90 } 90 }
91 91
92 SkISize onISize() override { 92 SkISize onISize() override {
93 return SkISize::Make(WIDTH, HEIGHT); 93 return SkISize::Make(WIDTH, HEIGHT);
94 } 94 }
95 95
96 void onDraw(SkCanvas* canvas) override { 96 void onDraw(SkCanvas* canvas) override {
97 SkImageInfo info = SkImageInfo::MakeN32(WIDTH, HEIGHT, kOpaque_SkAlphaTy pe); 97 SkImageInfo info = SkImageInfo::MakeN32(WIDTH, HEIGHT, kOpaque_SkAlphaTy pe);
98 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); 98 auto surface(canvas->makeSurface(info));
99 if (nullptr == surface) { 99 if (nullptr == surface) {
100 surface.reset(SkSurface::NewRaster(info)); 100 surface = SkSurface::MakeRaster(info);
101 } 101 }
102 surface->getCanvas()->clear(SK_ColorWHITE); 102 surface->getCanvas()->clear(SK_ColorWHITE);
103 draw_rects(surface->getCanvas()); 103 draw_rects(surface->getCanvas());
104 104
105 SkPaint paint = create_filter_paint(); 105 SkPaint paint = create_filter_paint();
106 canvas->clipRect(SkRect::MakeLTRB(100, 100, WIDTH - 100, HEIGHT - 100)); 106 canvas->clipRect(SkRect::MakeLTRB(100, 100, WIDTH - 100, HEIGHT - 100));
107 canvas->drawImage(surface->makeImageSnapshot().get(), 0, 0, &paint); 107 canvas->drawImage(surface->makeImageSnapshot().get(), 0, 0, &paint);
108 } 108 }
109 109
110 private: 110 private:
111 typedef GM INHERITED; 111 typedef GM INHERITED;
112 }; 112 };
113 113
114 ////////////////////////////////////////////////////////////////////////////// 114 //////////////////////////////////////////////////////////////////////////////
115 115
116 DEF_GM(return new ImageAlphaThresholdGM();) 116 DEF_GM(return new ImageAlphaThresholdGM();)
117 DEF_GM(return new ImageAlphaThresholdSurfaceGM();) 117 DEF_GM(return new ImageAlphaThresholdSurfaceGM();)
118 118
119 } 119 }
OLDNEW
« no previous file with comments | « gm/image_shader.cpp ('k') | gm/imagefilters.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698