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

Side by Side Diff: gm/drawatlas.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/discard.cpp ('k') | gm/drawatlascolor.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 2015 Google Inc. 2 * Copyright 2015 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 "SkRSXform.h" 10 #include "SkRSXform.h"
11 #include "SkSurface.h" 11 #include "SkSurface.h"
12 12
13 class DrawAtlasGM : public skiagm::GM { 13 class DrawAtlasGM : public skiagm::GM {
14 static sk_sp<SkImage> MakeAtlas(SkCanvas* caller, const SkRect& target) { 14 static sk_sp<SkImage> MakeAtlas(SkCanvas* caller, const SkRect& target) {
15 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); 15 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
16 SkAutoTUnref<SkSurface> surface(caller->newSurface(info)); 16 auto surface(caller->makeSurface(info));
17 if (nullptr == surface) { 17 if (nullptr == surface) {
18 surface.reset(SkSurface::NewRaster(info)); 18 surface = SkSurface::MakeRaster(info);
19 } 19 }
20 SkCanvas* canvas = surface->getCanvas(); 20 SkCanvas* canvas = surface->getCanvas();
21 // draw red everywhere, but we don't expect to see it in the draw, testi ng the notion 21 // draw red everywhere, but we don't expect to see it in the draw, testi ng the notion
22 // that drawAtlas draws a subset-region of the atlas. 22 // that drawAtlas draws a subset-region of the atlas.
23 canvas->clear(SK_ColorRED); 23 canvas->clear(SK_ColorRED);
24 24
25 SkPaint paint; 25 SkPaint paint;
26 paint.setXfermodeMode(SkXfermode::kClear_Mode); 26 paint.setXfermodeMode(SkXfermode::kClear_Mode);
27 SkRect r(target); 27 SkRect r(target);
28 r.inset(-1, -1); 28 r.inset(-1, -1);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 canvas->drawAtlas(fAtlas.get(), xform, tex, N, nullptr, &paint); 94 canvas->drawAtlas(fAtlas.get(), xform, tex, N, nullptr, &paint);
95 canvas->translate(0, 100); 95 canvas->translate(0, 100);
96 canvas->drawAtlas(fAtlas.get(), xform, tex, colors, N, SkXfermode::kSrcI n_Mode, nullptr, &paint); 96 canvas->drawAtlas(fAtlas.get(), xform, tex, colors, N, SkXfermode::kSrcI n_Mode, nullptr, &paint);
97 } 97 }
98 98
99 private: 99 private:
100 typedef GM INHERITED; 100 typedef GM INHERITED;
101 }; 101 };
102 DEF_GM( return new DrawAtlasGM; ) 102 DEF_GM( return new DrawAtlasGM; )
103 103
OLDNEW
« no previous file with comments | « gm/discard.cpp ('k') | gm/drawatlascolor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698