OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 return GrRefCachedBitmapTexture(ctx, fBitmap, params); | 169 return GrRefCachedBitmapTexture(ctx, fBitmap, params); |
170 #endif | 170 #endif |
171 | 171 |
172 return nullptr; | 172 return nullptr; |
173 } | 173 } |
174 | 174 |
175 sk_sp<SkImage> SkImage_Raster::onMakeSubset(const SkIRect& subset) const { | 175 sk_sp<SkImage> SkImage_Raster::onMakeSubset(const SkIRect& subset) const { |
176 // TODO : could consider heurist of sharing pixels, if subset is pretty clos
e to complete | 176 // TODO : could consider heurist of sharing pixels, if subset is pretty clos
e to complete |
177 | 177 |
178 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi
tmap.alphaType()); | 178 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi
tmap.alphaType()); |
179 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); | 179 auto surface(SkSurface::MakeRaster(info)); |
180 if (!surface) { | 180 if (!surface) { |
181 return nullptr; | 181 return nullptr; |
182 } | 182 } |
183 surface->getCanvas()->clear(0); | 183 surface->getCanvas()->clear(0); |
184 surface->getCanvas()->drawImage(this, SkIntToScalar(-subset.x()), SkIntToSca
lar(-subset.y()), | 184 surface->getCanvas()->drawImage(this, SkIntToScalar(-subset.x()), SkIntToSca
lar(-subset.y()), |
185 nullptr); | 185 nullptr); |
186 return surface->makeImageSnapshot(); | 186 return surface->makeImageSnapshot(); |
187 } | 187 } |
188 | 188 |
189 /////////////////////////////////////////////////////////////////////////////// | 189 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // pixelref since the caller might call setImmutable() themselves | 278 // pixelref since the caller might call setImmutable() themselves |
279 // (thus changing our state). | 279 // (thus changing our state). |
280 if (fBitmap.isImmutable()) { | 280 if (fBitmap.isImmutable()) { |
281 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); | 281 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); |
282 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); | 282 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); |
283 return true; | 283 return true; |
284 } | 284 } |
285 } | 285 } |
286 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); | 286 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); |
287 } | 287 } |
OLD | NEW |