Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: src/image/SkImagePriv.h

Issue 1266143003: lock pixels in image when bitmap is immutable and not-lazy (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
28 * Passing kLocked_SharedPixelRefMode allows the image's peekPixels() method 28 * Passing kLocked_SharedPixelRefMode allows the image's peekPixels() method
29 * to succeed, but it will force any lazy decodes/generators to execute if 29 * to succeed, but it will force any lazy decodes/generators to execute if
30 * they exist on the pixelref. 30 * they exist on the pixelref.
31 * 31 *
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 {
39 kLocked_SharedPixelRefMode,
40 kUnlocked_SharedPixelRefMode
41 };
42 enum ForceCopyMode { 38 enum ForceCopyMode {
43 kNo_ForceCopyMode, 39 kNo_ForceCopyMode,
44 kYes_ForceCopyMode, // must copy the pixels even if the bitmap is immutable 40 kYes_ForceCopyMode, // must copy the pixels even if the bitmap is immutable
45 }; 41 };
46 extern SkImage* SkNewImageFromRasterBitmap(const SkBitmap&, const SkSurfaceProps *, 42 extern SkImage* SkNewImageFromRasterBitmap(const SkBitmap&, const SkSurfaceProps *,
47 SharedPixelRefMode, ForceCopyMode = k No_ForceCopyMode); 43 ForceCopyMode = kNo_ForceCopyMode);
48 44
49 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { 45 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) {
50 size_t minRB = info.minRowBytes(); 46 size_t minRB = info.minRowBytes();
51 if (kIndex_8_SkColorType != info.colorType()) { 47 if (kIndex_8_SkColorType != info.colorType()) {
52 minRB = SkAlign4(minRB); 48 minRB = SkAlign4(minRB);
53 } 49 }
54 return minRB; 50 return minRB;
55 } 51 }
56 52
57 // Given an image created from SkNewImageFromBitmap, return its pixelref. This 53 // Given an image created from SkNewImageFromBitmap, return its pixelref. This
58 // may be called to see if the surface and the image share the same pixelref, 54 // may be called to see if the surface and the image share the same pixelref,
59 // in which case the surface may need to perform a copy-on-write. 55 // in which case the surface may need to perform a copy-on-write.
60 extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage); 56 extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage);
61 57
62 // When a texture is shared by a surface and an image its budgeted status is tha t of the 58 // When a texture is shared by a surface and an image its budgeted status is tha t of the
63 // surface. This function is used when the surface makes a new texture for itsel f in order 59 // surface. This function is used when the surface makes a new texture for itsel f in order
64 // for the orphaned image to determine whether the original texture counts again st the 60 // for the orphaned image to determine whether the original texture counts again st the
65 // budget or not. 61 // budget or not.
66 extern void SkTextureImageApplyBudgetedDecision(SkImage* textureImage); 62 extern void SkTextureImageApplyBudgetedDecision(SkImage* textureImage);
67 63
68 // Update the texture wrapped by an image created with NewTexture. This 64 // Update the texture wrapped by an image created with NewTexture. This
69 // is called when a surface and image share the same GrTexture and the 65 // is called when a surface and image share the same GrTexture and the
70 // surface needs to perform a copy-on-write 66 // surface needs to perform a copy-on-write
71 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); 67 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture);
72 68
73 GrTexture* GrDeepCopyTexture(GrTexture* src, bool isBudgeted); 69 GrTexture* GrDeepCopyTexture(GrTexture* src, bool isBudgeted);
74 70
75 #endif 71 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698