OLD | NEW |
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 Loading... |
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 Loading... |
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); ) |
OLD | NEW |