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 "SkImage_Base.h" | 8 #include "SkImage_Base.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 const SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(
), | 80 const SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(
), |
81 this->isOpaque() ? kOpaque_SkAlphaType : k
Premul_SkAlphaType); | 81 this->isOpaque() ? kOpaque_SkAlphaType : k
Premul_SkAlphaType); |
82 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); | 82 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); |
83 if (!surface) { | 83 if (!surface) { |
84 return nullptr; | 84 return nullptr; |
85 } | 85 } |
86 surface->getCanvas()->clear(0); | 86 surface->getCanvas()->clear(0); |
87 surface->getCanvas()->drawImage(this, SkIntToScalar(-subset.x()), SkIntToSca
lar(-subset.y()), | 87 surface->getCanvas()->drawImage(this, SkIntToScalar(-subset.x()), SkIntToSca
lar(-subset.y()), |
88 nullptr); | 88 nullptr); |
89 return sk_sp<SkImage>(surface->newImageSnapshot()); | 89 return surface->makeImageSnapshot(); |
90 } | 90 } |
91 | 91 |
92 sk_sp<SkImage> SkImage::MakeFromGenerator(SkImageGenerator* generator, const SkI
Rect* subset) { | 92 sk_sp<SkImage> SkImage::MakeFromGenerator(SkImageGenerator* generator, const SkI
Rect* subset) { |
93 if (!generator) { | 93 if (!generator) { |
94 return nullptr; | 94 return nullptr; |
95 } | 95 } |
96 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su
bset); | 96 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su
bset); |
97 if (!cache) { | 97 if (!cache) { |
98 return nullptr; | 98 return nullptr; |
99 } | 99 } |
100 return sk_make_sp<SkImage_Generator>(cache); | 100 return sk_make_sp<SkImage_Generator>(cache); |
101 } | 101 } |
OLD | NEW |