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

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

Issue 1372153006: SkImage doesn't use props, so don't need to store it (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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_Base.h » ('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*);
19 18
20 /** 19 /**
21 * Examines the bitmap to decide if it can share the existing pixelRef, or 20 * 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. 21 * if it needs to make a deep-copy of the pixels.
23 * 22 *
24 * The bitmap's pixelref will be shared if either the bitmap is marked as 23 * 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 24 * immutable, or forceSharePixelRef is true. Shared pixel refs are also
26 * locked when kLocked_SharedPixelRefMode is specified. 25 * locked when kLocked_SharedPixelRefMode is specified.
27 * 26 *
28 * Passing kLocked_SharedPixelRefMode allows the image's peekPixels() method 27 * Passing kLocked_SharedPixelRefMode allows the image's peekPixels() method
29 * to succeed, but it will force any lazy decodes/generators to execute if 28 * to succeed, but it will force any lazy decodes/generators to execute if
30 * they exist on the pixelref. 29 * they exist on the pixelref.
31 * 30 *
32 * It is illegal to call this with a texture-backed bitmap. 31 * It is illegal to call this with a texture-backed bitmap.
33 * 32 *
34 * If the bitmap's colortype cannot be converted into a corresponding 33 * If the bitmap's colortype cannot be converted into a corresponding
35 * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return 34 * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return
36 * nullptr. 35 * nullptr.
37 */ 36 */
38 enum ForceCopyMode { 37 enum ForceCopyMode {
39 kNo_ForceCopyMode, 38 kNo_ForceCopyMode,
40 kYes_ForceCopyMode, // must copy the pixels even if the bitmap is immutable 39 kYes_ForceCopyMode, // must copy the pixels even if the bitmap is immutable
41 }; 40 };
42 extern SkImage* SkNewImageFromRasterBitmap(const SkBitmap&, const SkSurfaceProps *, 41 extern SkImage* SkNewImageFromRasterBitmap(const SkBitmap&, ForceCopyMode = kNo_ ForceCopyMode);
43 ForceCopyMode = kNo_ForceCopyMode);
44 42
45 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { 43 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) {
46 size_t minRB = info.minRowBytes(); 44 size_t minRB = info.minRowBytes();
47 if (kIndex_8_SkColorType != info.colorType()) { 45 if (kIndex_8_SkColorType != info.colorType()) {
48 minRB = SkAlign4(minRB); 46 minRB = SkAlign4(minRB);
49 } 47 }
50 return minRB; 48 return minRB;
51 } 49 }
52 50
53 // Given an image created from SkNewImageFromBitmap, return its pixelref. This 51 // 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, 52 // 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. 53 // in which case the surface may need to perform a copy-on-write.
56 extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage); 54 extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage);
57 55
58 // When a texture is shared by a surface and an image its budgeted status is tha t of the 56 // 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 57 // 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 58 // for the orphaned image to determine whether the original texture counts again st the
61 // budget or not. 59 // budget or not.
62 extern void SkTextureImageApplyBudgetedDecision(SkImage* textureImage); 60 extern void SkTextureImageApplyBudgetedDecision(SkImage* textureImage);
63 61
64 // Update the texture wrapped by an image created with NewTexture. This 62 // 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 63 // is called when a surface and image share the same GrTexture and the
66 // surface needs to perform a copy-on-write 64 // surface needs to perform a copy-on-write
67 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); 65 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture);
68 66
69 GrTexture* GrDeepCopyTexture(GrTexture* src, bool isBudgeted); 67 GrTexture* GrDeepCopyTexture(GrTexture* src, bool isBudgeted);
70 68
71 #endif 69 #endif
OLDNEW
« no previous file with comments | « src/image/SkImage.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698