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 12 matching lines...) Expand all Loading... |
23 * 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 |
24 * is true. | 24 * is true. |
25 * | 25 * |
26 * If the bitmap's colortype cannot be converted into a corresponding | 26 * If the bitmap's colortype cannot be converted into a corresponding |
27 * 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 |
28 * NULL. | 28 * NULL. |
29 */ | 29 */ |
30 extern SkImage* SkNewImageFromBitmap(const SkBitmap&, bool canSharePixelRef, con
st SkSurfaceProps*); | 30 extern SkImage* SkNewImageFromBitmap(const SkBitmap&, bool canSharePixelRef, con
st SkSurfaceProps*); |
31 | 31 |
32 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { | 32 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { |
33 return SkAlign4(info.minRowBytes()); | 33 size_t minRB = info.minRowBytes(); |
| 34 if (kIndex_8_SkColorType != info.colorType()) { |
| 35 minRB = SkAlign4(minRB); |
| 36 } |
| 37 return minRB; |
34 } | 38 } |
35 | 39 |
36 // Given an image created from SkNewImageFromBitmap, return its pixelref. This | 40 // Given an image created from SkNewImageFromBitmap, return its pixelref. This |
37 // may be called to see if the surface and the image share the same pixelref, | 41 // may be called to see if the surface and the image share the same pixelref, |
38 // in which case the surface may need to perform a copy-on-write. | 42 // in which case the surface may need to perform a copy-on-write. |
39 extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage); | 43 extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage); |
40 | 44 |
41 // When a texture is shared by a surface and an image its budgeted status is tha
t of the | 45 // When a texture is shared by a surface and an image its budgeted status is tha
t of the |
42 // surface. This function is used when the surface makes a new texture for itsel
f in order | 46 // surface. This function is used when the surface makes a new texture for itsel
f in order |
43 // for the orphaned image to determine whether the original texture counts again
st the | 47 // for the orphaned image to determine whether the original texture counts again
st the |
44 // budget or not. | 48 // budget or not. |
45 extern void SkTextureImageApplyBudgetedDecision(SkImage* textureImage); | 49 extern void SkTextureImageApplyBudgetedDecision(SkImage* textureImage); |
46 | 50 |
47 // Update the texture wrapped by an image created with NewTexture. This | 51 // Update the texture wrapped by an image created with NewTexture. This |
48 // is called when a surface and image share the same GrTexture and the | 52 // is called when a surface and image share the same GrTexture and the |
49 // surface needs to perform a copy-on-write | 53 // surface needs to perform a copy-on-write |
50 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); | 54 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); |
51 | 55 |
52 #endif | 56 #endif |
OLD | NEW |