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 |
(...skipping 21 matching lines...) Expand all Loading... |
32 * It is illegal to call this with a texture-backed bitmap. | 32 * It is illegal to call this with a texture-backed bitmap. |
33 * | 33 * |
34 * If the bitmap's colortype cannot be converted into a corresponding | 34 * If the bitmap's colortype cannot be converted into a corresponding |
35 * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return | 35 * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return |
36 * NULL. | 36 * NULL. |
37 */ | 37 */ |
38 enum SharedPixelRefMode { | 38 enum SharedPixelRefMode { |
39 kLocked_SharedPixelRefMode, | 39 kLocked_SharedPixelRefMode, |
40 kUnlocked_SharedPixelRefMode | 40 kUnlocked_SharedPixelRefMode |
41 }; | 41 }; |
42 extern SkImage* SkNewImageFromRasterBitmap(const SkBitmap&, bool forceSharePixel
Ref, | 42 enum ForceCopyMode { |
43 const SkSurfaceProps*, SharedPixelRef
Mode); | 43 kNo_ForceCopyMode, |
| 44 kYes_ForceCopyMode, // must copy the pixels even if the bitmap is immutable |
| 45 }; |
| 46 extern SkImage* SkNewImageFromRasterBitmap(const SkBitmap&, const SkSurfaceProps
*, |
| 47 SharedPixelRefMode, ForceCopyMode = k
No_ForceCopyMode); |
44 | 48 |
45 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { | 49 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { |
46 size_t minRB = info.minRowBytes(); | 50 size_t minRB = info.minRowBytes(); |
47 if (kIndex_8_SkColorType != info.colorType()) { | 51 if (kIndex_8_SkColorType != info.colorType()) { |
48 minRB = SkAlign4(minRB); | 52 minRB = SkAlign4(minRB); |
49 } | 53 } |
50 return minRB; | 54 return minRB; |
51 } | 55 } |
52 | 56 |
53 // Given an image created from SkNewImageFromBitmap, return its pixelref. This | 57 // Given an image created from SkNewImageFromBitmap, return its pixelref. This |
54 // may be called to see if the surface and the image share the same pixelref, | 58 // may be called to see if the surface and the image share the same pixelref, |
55 // in which case the surface may need to perform a copy-on-write. | 59 // in which case the surface may need to perform a copy-on-write. |
56 extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage); | 60 extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage); |
57 | 61 |
58 // When a texture is shared by a surface and an image its budgeted status is tha
t of the | 62 // When a texture is shared by a surface and an image its budgeted status is tha
t of the |
59 // surface. This function is used when the surface makes a new texture for itsel
f in order | 63 // surface. This function is used when the surface makes a new texture for itsel
f in order |
60 // for the orphaned image to determine whether the original texture counts again
st the | 64 // for the orphaned image to determine whether the original texture counts again
st the |
61 // budget or not. | 65 // budget or not. |
62 extern void SkTextureImageApplyBudgetedDecision(SkImage* textureImage); | 66 extern void SkTextureImageApplyBudgetedDecision(SkImage* textureImage); |
63 | 67 |
64 // Update the texture wrapped by an image created with NewTexture. This | 68 // Update the texture wrapped by an image created with NewTexture. This |
65 // is called when a surface and image share the same GrTexture and the | 69 // is called when a surface and image share the same GrTexture and the |
66 // surface needs to perform a copy-on-write | 70 // surface needs to perform a copy-on-write |
67 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); | 71 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); |
68 | 72 |
69 GrTexture* GrDeepCopyTexture(GrTexture* src, bool isBudgeted); | 73 GrTexture* GrDeepCopyTexture(GrTexture* src, bool isBudgeted); |
70 | 74 |
71 #endif | 75 #endif |
OLD | NEW |