| 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 "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 // Create a square atlas of: | 13 // Create a square atlas of: |
| 14 // opaque white | opaque red | 14 // opaque white | opaque red |
| 15 // ------------------------------------ | 15 // ------------------------------------ |
| 16 // opaque green | transparent black | 16 // opaque green | transparent black |
| 17 // | 17 // |
| 18 static sk_sp<SkImage> make_atlas(SkCanvas* caller, int atlasSize) { | 18 static sk_sp<SkImage> make_atlas(SkCanvas* caller, int atlasSize) { |
| 19 const int kBlockSize = atlasSize/2; | 19 const int kBlockSize = atlasSize/2; |
| 20 | 20 |
| 21 SkImageInfo info = SkImageInfo::MakeN32Premul(atlasSize, atlasSize); | 21 SkImageInfo info = SkImageInfo::MakeN32Premul(atlasSize, atlasSize); |
| 22 SkAutoTUnref<SkSurface> surface(caller->newSurface(info)); | 22 auto surface(caller->makeSurface(info)); |
| 23 if (nullptr == surface) { | 23 if (nullptr == surface) { |
| 24 surface.reset(SkSurface::NewRaster(info)); | 24 surface = SkSurface::MakeRaster(info); |
| 25 } | 25 } |
| 26 SkCanvas* canvas = surface->getCanvas(); | 26 SkCanvas* canvas = surface->getCanvas(); |
| 27 | 27 |
| 28 SkPaint paint; | 28 SkPaint paint; |
| 29 paint.setXfermode(SkXfermode::Create(SkXfermode::kSrc_Mode)); | 29 paint.setXfermode(SkXfermode::Create(SkXfermode::kSrc_Mode)); |
| 30 | 30 |
| 31 paint.setColor(SK_ColorWHITE); | 31 paint.setColor(SK_ColorWHITE); |
| 32 SkRect r = SkRect::MakeXYWH(0, 0, | 32 SkRect r = SkRect::MakeXYWH(0, 0, |
| 33 SkIntToScalar(kBlockSize), SkIntToScalar(kBlockS
ize)); | 33 SkIntToScalar(kBlockSize), SkIntToScalar(kBlockS
ize)); |
| 34 canvas->drawRect(r, paint); | 34 canvas->drawRect(r, paint); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 static const int kPad = 2; | 168 static const int kPad = 2; |
| 169 static const int kTextPad = 8; | 169 static const int kTextPad = 8; |
| 170 | 170 |
| 171 | 171 |
| 172 sk_sp<SkImage> fAtlas; | 172 sk_sp<SkImage> fAtlas; |
| 173 | 173 |
| 174 typedef GM INHERITED; | 174 typedef GM INHERITED; |
| 175 }; | 175 }; |
| 176 DEF_GM( return new DrawAtlasColorsGM; ) | 176 DEF_GM( return new DrawAtlasColorsGM; ) |
| 177 | 177 |
| OLD | NEW |