| 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkBitmapCache.h" | 9 #include "SkBitmapCache.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 case kRGB_565_SkColorType: | 191 case kRGB_565_SkColorType: |
| 192 return true; | 192 return true; |
| 193 case kAlpha_8_SkColorType: | 193 case kAlpha_8_SkColorType: |
| 194 return true; | 194 return true; |
| 195 default: | 195 default: |
| 196 break; | 196 break; |
| 197 } | 197 } |
| 198 return false; | 198 return false; |
| 199 } | 199 } |
| 200 | 200 |
| 201 static SkSurfaceProps copy_or_safe_defaults(const SkSurfaceProps* props) { | 201 SkImage_Base::SkImage_Base(int width, int height, uint32_t uniqueID) |
| 202 return props ? *props : SkSurfaceProps(0, kUnknown_SkPixelGeometry); | |
| 203 } | |
| 204 | |
| 205 SkImage_Base::SkImage_Base(int width, int height, uint32_t uniqueID, const SkSur
faceProps* props) | |
| 206 : INHERITED(width, height, uniqueID) | 202 : INHERITED(width, height, uniqueID) |
| 207 , fProps(copy_or_safe_defaults(props)) | |
| 208 , fAddedToCache(false) | 203 , fAddedToCache(false) |
| 209 { } | 204 {} |
| 210 | 205 |
| 211 SkImage_Base::~SkImage_Base() { | 206 SkImage_Base::~SkImage_Base() { |
| 212 if (fAddedToCache.load()) { | 207 if (fAddedToCache.load()) { |
| 213 SkNotifyBitmapGenIDIsStale(this->uniqueID()); | 208 SkNotifyBitmapGenIDIsStale(this->uniqueID()); |
| 214 } | 209 } |
| 215 } | 210 } |
| 216 | 211 |
| 217 bool SkImage_Base::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, siz
e_t dstRowBytes, | 212 bool SkImage_Base::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, siz
e_t dstRowBytes, |
| 218 int srcX, int srcY) const { | 213 int srcX, int srcY) const { |
| 219 if (!raster_canvas_supports(dstInfo)) { | 214 if (!raster_canvas_supports(dstInfo)) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 264 } |
| 270 unrefCopy.reset(tex); | 265 unrefCopy.reset(tex); |
| 271 } | 266 } |
| 272 const SkImageInfo info = bm.info(); | 267 const SkImageInfo info = bm.info(); |
| 273 return new SkImage_Gpu(info.width(), info.height(), bm.getGenerationID()
, info.alphaType(), | 268 return new SkImage_Gpu(info.width(), info.height(), bm.getGenerationID()
, info.alphaType(), |
| 274 tex, SkSurface::kNo_Budgeted); | 269 tex, SkSurface::kNo_Budgeted); |
| 275 } | 270 } |
| 276 #endif | 271 #endif |
| 277 | 272 |
| 278 // This will check for immutable (share or copy) | 273 // This will check for immutable (share or copy) |
| 279 return SkNewImageFromRasterBitmap(bm, nullptr); | 274 return SkNewImageFromRasterBitmap(bm); |
| 280 } | 275 } |
| 281 | 276 |
| 282 bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { | 277 bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { |
| 283 return as_IB(this)->onAsLegacyBitmap(bitmap, mode); | 278 return as_IB(this)->onAsLegacyBitmap(bitmap, mode); |
| 284 } | 279 } |
| 285 | 280 |
| 286 bool SkImage_Base::onAsLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) con
st { | 281 bool SkImage_Base::onAsLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) con
st { |
| 287 // As the base-class, all we can do is make a copy (regardless of mode). | 282 // As the base-class, all we can do is make a copy (regardless of mode). |
| 288 // Subclasses that want to be more optimal should override. | 283 // Subclasses that want to be more optimal should override. |
| 289 SkImageInfo info = SkImageInfo::MakeN32(this->width(), this->height(), | 284 SkImageInfo info = SkImageInfo::MakeN32(this->width(), this->height(), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 320 |
| 326 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&,
SkAlphaType) { | 321 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&,
SkAlphaType) { |
| 327 return nullptr; | 322 return nullptr; |
| 328 } | 323 } |
| 329 | 324 |
| 330 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk
AlphaType) { | 325 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk
AlphaType) { |
| 331 return nullptr; | 326 return nullptr; |
| 332 } | 327 } |
| 333 | 328 |
| 334 #endif | 329 #endif |
| OLD | NEW |