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

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

Issue 1256993002: Make peekPixels() usable with raster surface snapshots (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review comments 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
« no previous file with comments | « src/image/SkImage.cpp ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
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 when kLocked_SharedPixelRefMode is specified.
27 *
28 * Passing kLocked_SharedPixelRefMode allows the image's peekPixels() method
29 * to succeed, but it will force any lazy decodes/generators to execute if
30 * they exist on the pixelref.
25 * 31 *
26 * It is illegal to call this with a texture-backed bitmap. 32 * It is illegal to call this with a texture-backed bitmap.
27 * 33 *
28 * If the bitmap's colortype cannot be converted into a corresponding 34 * If the bitmap's colortype cannot be converted into a corresponding
29 * 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
30 * NULL. 36 * NULL.
31 */ 37 */
38 enum SharedPixelRefMode {
39 kLocked_SharedPixelRefMode,
40 kUnlocked_SharedPixelRefMode
41 };
32 extern SkImage* SkNewImageFromRasterBitmap(const SkBitmap&, bool forceSharePixel Ref, 42 extern SkImage* SkNewImageFromRasterBitmap(const SkBitmap&, bool forceSharePixel Ref,
33 const SkSurfaceProps*); 43 const SkSurfaceProps*, SharedPixelRef Mode);
34 44
35 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { 45 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) {
36 size_t minRB = info.minRowBytes(); 46 size_t minRB = info.minRowBytes();
37 if (kIndex_8_SkColorType != info.colorType()) { 47 if (kIndex_8_SkColorType != info.colorType()) {
38 minRB = SkAlign4(minRB); 48 minRB = SkAlign4(minRB);
39 } 49 }
40 return minRB; 50 return minRB;
41 } 51 }
42 52
43 // Given an image created from SkNewImageFromBitmap, return its pixelref. This 53 // 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, 54 // 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. 55 // in which case the surface may need to perform a copy-on-write.
46 extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage); 56 extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage);
47 57
48 // 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
49 // 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
50 // 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
51 // budget or not. 61 // budget or not.
52 extern void SkTextureImageApplyBudgetedDecision(SkImage* textureImage); 62 extern void SkTextureImageApplyBudgetedDecision(SkImage* textureImage);
53 63
54 // Update the texture wrapped by an image created with NewTexture. This 64 // 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 65 // is called when a surface and image share the same GrTexture and the
56 // surface needs to perform a copy-on-write 66 // surface needs to perform a copy-on-write
57 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); 67 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture);
58 68
59 GrTexture* GrDeepCopyTexture(GrTexture* src, bool isBudgeted); 69 GrTexture* GrDeepCopyTexture(GrTexture* src, bool isBudgeted);
60 70
61 #endif 71 #endif
OLDNEW
« no previous file with comments | « src/image/SkImage.cpp ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698