| 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 #ifndef SkImagePriv_DEFINED | 8 #ifndef SkImagePriv_DEFINED |
| 9 #define SkImagePriv_DEFINED | 9 #define SkImagePriv_DEFINED |
| 10 | 10 |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkImage.h" | 12 #include "SkImage.h" |
| 13 | 13 |
| 14 extern SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo&); |
| 15 |
| 14 // Call this if you explicitly want to use/share this pixelRef in the image | 16 // Call this if you explicitly want to use/share this pixelRef in the image |
| 15 extern SkImage* SkNewImageFromPixelRef(const SkImageInfo&, SkPixelRef*, | 17 extern SkImage* SkNewImageFromPixelRef(const SkImageInfo&, SkPixelRef*, |
| 16 size_t rowBytes); | 18 size_t rowBytes); |
| 17 | 19 |
| 18 /** | 20 /** |
| 19 * Examines the bitmap to decide if it can share the existing pixelRef, or | 21 * Examines the bitmap to decide if it can share the existing pixelRef, or |
| 20 * if it needs to make a deep-copy of the pixels. The bitmap's pixelref will | 22 * if it needs to make a deep-copy of the pixels. The bitmap's pixelref will |
| 21 * be shared if either the bitmap is marked as immutable, or canSharePixelRef | 23 * be shared if either the bitmap is marked as immutable, or canSharePixelRef |
| 22 * is true. | 24 * is true. |
| 23 * | 25 * |
| 24 * If the bitmap's colortype cannot be converted into a corresponding | 26 * If the bitmap's config cannot be converted into a corresponding |
| 25 * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return | 27 * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return |
| 26 * NULL. | 28 * NULL. |
| 27 */ | 29 */ |
| 28 extern SkImage* SkNewImageFromBitmap(const SkBitmap&, bool canSharePixelRef); | 30 extern SkImage* SkNewImageFromBitmap(const SkBitmap&, bool canSharePixelRef); |
| 29 | 31 |
| 30 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { | 32 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { |
| 31 return SkAlign4(info.minRowBytes()); | 33 return SkAlign4(info.minRowBytes()); |
| 32 } | 34 } |
| 33 | 35 |
| 34 // Given an image created from SkNewImageFromBitmap, return its pixelref. This | 36 // Given an image created from SkNewImageFromBitmap, return its pixelref. This |
| 35 // may be called to see if the surface and the image share the same pixelref, | 37 // may be called to see if the surface and the image share the same pixelref, |
| 36 // in which case the surface may need to perform a copy-on-write. | 38 // in which case the surface may need to perform a copy-on-write. |
| 37 extern SkPixelRef* SkBitmapImageGetPixelRef(SkImage* rasterImage); | 39 extern SkPixelRef* SkBitmapImageGetPixelRef(SkImage* rasterImage); |
| 38 | 40 |
| 39 // Given an image created with NewTexture, return its GrTexture. This | 41 // Given an image created with NewTexture, return its GrTexture. This |
| 40 // may be called to see if the surface and the image share the same GrTexture, | 42 // may be called to see if the surface and the image share the same GrTexture, |
| 41 // in which case the surface may need to perform a copy-on-write. | 43 // in which case the surface may need to perform a copy-on-write. |
| 42 extern GrTexture* SkTextureImageGetTexture(SkImage* textureImage); | 44 extern GrTexture* SkTextureImageGetTexture(SkImage* textureImage); |
| 43 | 45 |
| 44 // Update the texture wrapped by an image created with NewTexture. This | 46 // Update the texture wrapped by an image created with NewTexture. This |
| 45 // is called when a surface and image share the same GrTexture and the | 47 // is called when a surface and image share the same GrTexture and the |
| 46 // surface needs to perform a copy-on-write | 48 // surface needs to perform a copy-on-write |
| 47 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); | 49 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); |
| 48 | 50 |
| 49 #endif | 51 #endif |
| OLD | NEW |