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

Side by Side Diff: samplecode/SampleAtlas.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 | « samplecode/SampleApp.cpp ('k') | samplecode/SampleFatBits.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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkAnimTimer.h" 9 #include "SkAnimTimer.h"
10 #include "SkView.h" 10 #include "SkView.h"
(...skipping 23 matching lines...) Expand all
34 canvas->save(); 34 canvas->save();
35 canvas->concat(matrix); 35 canvas->concat(matrix);
36 canvas->drawImageRect(atlas, tex[i], tex[i].makeOffset(-tex[i].x(), -tex [i].y()), paint, 36 canvas->drawImageRect(atlas, tex[i], tex[i].makeOffset(-tex[i].x(), -tex [i].y()), paint,
37 SkCanvas::kFast_SrcRectConstraint); 37 SkCanvas::kFast_SrcRectConstraint);
38 canvas->restore(); 38 canvas->restore();
39 } 39 }
40 } 40 }
41 41
42 static sk_sp<SkImage> make_atlas(int atlasSize, int cellSize) { 42 static sk_sp<SkImage> make_atlas(int atlasSize, int cellSize) {
43 SkImageInfo info = SkImageInfo::MakeN32Premul(atlasSize, atlasSize); 43 SkImageInfo info = SkImageInfo::MakeN32Premul(atlasSize, atlasSize);
44 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); 44 auto surface(SkSurface::MakeRaster(info));
45 SkCanvas* canvas = surface->getCanvas(); 45 SkCanvas* canvas = surface->getCanvas();
46 46
47 SkPaint paint; 47 SkPaint paint;
48 paint.setAntiAlias(true); 48 paint.setAntiAlias(true);
49 SkRandom rand; 49 SkRandom rand;
50 50
51 const SkScalar half = cellSize * SK_ScalarHalf; 51 const SkScalar half = cellSize * SK_ScalarHalf;
52 const char* s = "01234567890!@#$%^&*=+<>?abcdefghijklmnopqrstuvwxyzABCDEFGHI JKLMNOPQRSTUVWXYZ"; 52 const char* s = "01234567890!@#$%^&*=+<>?abcdefghijklmnopqrstuvwxyzABCDEFGHI JKLMNOPQRSTUVWXYZ";
53 paint.setTextSize(28); 53 paint.setTextSize(28);
54 paint.setTextAlign(SkPaint::kCenter_Align); 54 paint.setTextAlign(SkPaint::kCenter_Align);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 #endif 245 #endif
246 246
247 private: 247 private:
248 typedef SampleView INHERITED; 248 typedef SampleView INHERITED;
249 }; 249 };
250 250
251 ////////////////////////////////////////////////////////////////////////////// 251 //////////////////////////////////////////////////////////////////////////////
252 252
253 DEF_SAMPLE( return new DrawAtlasView("DrawAtlas", draw_atlas); ) 253 DEF_SAMPLE( return new DrawAtlasView("DrawAtlas", draw_atlas); )
254 DEF_SAMPLE( return new DrawAtlasView("DrawAtlasSim", draw_atlas_sim); ) 254 DEF_SAMPLE( return new DrawAtlasView("DrawAtlasSim", draw_atlas_sim); )
OLDNEW
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | samplecode/SampleFatBits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698