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 15 matching lines...) Expand all Loading... |
26 | 26 |
27 static void draw_atlas_sim(SkCanvas* canvas, SkImage* atlas, const SkRSXform xfo
rm[], | 27 static void draw_atlas_sim(SkCanvas* canvas, SkImage* atlas, const SkRSXform xfo
rm[], |
28 const SkRect tex[], const SkColor colors[], int count
, const SkRect* cull, | 28 const SkRect tex[], const SkColor colors[], int count
, const SkRect* cull, |
29 const SkPaint* paint) { | 29 const SkPaint* paint) { |
30 for (int i = 0; i < count; ++i) { | 30 for (int i = 0; i < count; ++i) { |
31 SkMatrix matrix; | 31 SkMatrix matrix; |
32 matrix.setRSXform(xform[i]); | 32 matrix.setRSXform(xform[i]); |
33 | 33 |
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(), -te
x[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 SkImage* make_atlas(int atlasSize, int cellSize) { | 42 static 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 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); |
45 SkCanvas* canvas = surface->getCanvas(); | 45 SkCanvas* canvas = surface->getCanvas(); |
46 | 46 |
(...skipping 198 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 |