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 "SkImage.h" | 11 #include "SkImage.h" |
12 #include "SkSurface.h" | 12 #include "SkSurface.h" |
13 | 13 |
14 // Call this if you explicitly want to use/share this pixelRef in the image | 14 // Call this if you explicitly want to use/share this pixelRef in the image |
15 extern SkImage* SkNewImageFromPixelRef(const SkImageInfo&, SkPixelRef*, | 15 extern SkImage* SkNewImageFromPixelRef(const SkImageInfo&, SkPixelRef*, |
16 const SkIPoint& pixelRefOrigin, | 16 const SkIPoint& pixelRefOrigin, |
17 size_t rowBytes, | 17 size_t rowBytes, |
18 const SkSurfaceProps*); | 18 const SkSurfaceProps*); |
19 | 19 |
20 /** | 20 /** |
21 * 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 |
22 * 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. |
23 * be shared if either the bitmap is marked as immutable, or canSharePixelRef | 23 * |
24 * is true. | 24 * The bitmap's pixelref will be shared if either the bitmap is marked as |
25 * immutable, or forceSharePixelRef is true. Shared pixel refs are also | |
26 * locked if lockSharedPixelRef is true. | |
25 * | 27 * |
reed1
2015/07/27 16:07:56
Perhaps a note about why one might pass true or fa
f(malita)
2015/07/27 16:53:39
Done.
| |
26 * It is illegal to call this with a texture-backed bitmap. | 28 * It is illegal to call this with a texture-backed bitmap. |
27 * | 29 * |
28 * If the bitmap's colortype cannot be converted into a corresponding | 30 * If the bitmap's colortype cannot be converted into a corresponding |
29 * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return | 31 * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return |
30 * NULL. | 32 * NULL. |
31 */ | 33 */ |
32 extern SkImage* SkNewImageFromRasterBitmap(const SkBitmap&, bool forceSharePixel Ref, | 34 extern SkImage* SkNewImageFromRasterBitmap(const SkBitmap&, bool forceSharePixel Ref, |
33 const SkSurfaceProps*); | 35 const SkSurfaceProps*, bool lockShare dPixelRef = false); |
34 | 36 |
35 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { | 37 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { |
36 size_t minRB = info.minRowBytes(); | 38 size_t minRB = info.minRowBytes(); |
37 if (kIndex_8_SkColorType != info.colorType()) { | 39 if (kIndex_8_SkColorType != info.colorType()) { |
38 minRB = SkAlign4(minRB); | 40 minRB = SkAlign4(minRB); |
39 } | 41 } |
40 return minRB; | 42 return minRB; |
41 } | 43 } |
42 | 44 |
43 // Given an image created from SkNewImageFromBitmap, return its pixelref. This | 45 // Given an image created from SkNewImageFromBitmap, return its pixelref. This |
44 // may be called to see if the surface and the image share the same pixelref, | 46 // may be called to see if the surface and the image share the same pixelref, |
45 // in which case the surface may need to perform a copy-on-write. | 47 // in which case the surface may need to perform a copy-on-write. |
46 extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage); | 48 extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage); |
47 | 49 |
48 // When a texture is shared by a surface and an image its budgeted status is tha t of the | 50 // When a texture is shared by a surface and an image its budgeted status is tha t of the |
49 // surface. This function is used when the surface makes a new texture for itsel f in order | 51 // surface. This function is used when the surface makes a new texture for itsel f in order |
50 // for the orphaned image to determine whether the original texture counts again st the | 52 // for the orphaned image to determine whether the original texture counts again st the |
51 // budget or not. | 53 // budget or not. |
52 extern void SkTextureImageApplyBudgetedDecision(SkImage* textureImage); | 54 extern void SkTextureImageApplyBudgetedDecision(SkImage* textureImage); |
53 | 55 |
54 // Update the texture wrapped by an image created with NewTexture. This | 56 // Update the texture wrapped by an image created with NewTexture. This |
55 // is called when a surface and image share the same GrTexture and the | 57 // is called when a surface and image share the same GrTexture and the |
56 // surface needs to perform a copy-on-write | 58 // surface needs to perform a copy-on-write |
57 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); | 59 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); |
58 | 60 |
59 GrTexture* GrDeepCopyTexture(GrTexture* src, bool isBudgeted); | 61 GrTexture* GrDeepCopyTexture(GrTexture* src, bool isBudgeted); |
60 | 62 |
61 #endif | 63 #endif |
OLD | NEW |