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

Side by Side Diff: src/core/SkSpecialImage.h

Issue 1787883002: Add SkSpecialImage::extractSubset & NewFromPixmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT Created 4 years, 9 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/core/SkScalerContext.cpp ('k') | src/core/SkSpecialImage.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 2016 Google Inc. 2 * Copyright 2016 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 SkSpecialImage_DEFINED 8 #ifndef SkSpecialImage_DEFINED
9 #define SkSpecialImage_DEFINED 9 #define SkSpecialImage_DEFINED
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const SkIRect& subset, 56 const SkIRect& subset,
57 const SkImage*); 57 const SkImage*);
58 static SkSpecialImage* NewFromRaster(SkImageFilter::Proxy*, 58 static SkSpecialImage* NewFromRaster(SkImageFilter::Proxy*,
59 const SkIRect& subset, 59 const SkIRect& subset,
60 const SkBitmap&); 60 const SkBitmap&);
61 static SkSpecialImage* NewFromGpu(SkImageFilter::Proxy*, 61 static SkSpecialImage* NewFromGpu(SkImageFilter::Proxy*,
62 const SkIRect& subset, 62 const SkIRect& subset,
63 uint32_t uniqueID, 63 uint32_t uniqueID,
64 GrTexture*, 64 GrTexture*,
65 SkAlphaType at = kPremul_SkAlphaType); 65 SkAlphaType at = kPremul_SkAlphaType);
66 static SkSpecialImage* NewFromPixmap(SkImageFilter::Proxy*,
67 const SkIRect& subset,
68 const SkPixmap&,
69 void (*releaseProc)(void* addr, void* c ontext),
70 void* context);
66 71
67 /** 72 /**
68 * Create a new surface with a backend that is compatible with this image. 73 * Create a new surface with a backend that is compatible with this image.
69 */ 74 */
70 SkSpecialSurface* newSurface(const SkImageInfo&) const; 75 SkSpecialSurface* newSurface(const SkImageInfo&) const;
71 76
77 /**
78 * Extract a subset of this special image and return it as a special image.
79 * It may or may not point to the same backing memory.
80 */
81 SkSpecialImage* extractSubset(const SkIRect& subset) const;
82
72 // These three internal methods will go away (see skbug.com/4965) 83 // These three internal methods will go away (see skbug.com/4965)
73 bool internal_getBM(SkBitmap* result); 84 bool internal_getBM(SkBitmap* result);
74 static SkSpecialImage* internal_fromBM(SkImageFilter::Proxy*, const SkBitmap &); 85 static SkSpecialImage* internal_fromBM(SkImageFilter::Proxy*, const SkBitmap &);
75 SkImageFilter::Proxy* internal_getProxy(); 86 SkImageFilter::Proxy* internal_getProxy() const;
76 87
77 // TODO: hide this when GrLayerHoister uses SkSpecialImages more fully (see skbug.com/5063) 88 // TODO: hide this when GrLayerHoister uses SkSpecialImages more fully (see skbug.com/5063)
78 /** 89 /**
79 * If the SpecialImage is backed by a gpu texture, return that texture. 90 * If the SpecialImage is backed by a gpu texture, return that texture.
80 * The active portion of the texture can be retrieved via 'subset'. 91 * The active portion of the texture can be retrieved via 'subset'.
81 */ 92 */
82 GrTexture* peekTexture() const; 93 GrTexture* peekTexture() const;
83 94
95 // TODO: hide this whe the imagefilter all have a consistent draw path (see skbug.com/5063)
96 /**
97 * If the SpecialImage is backed by cpu pixels, return the const address
98 * of those pixels and, if not null, the ImageInfo, rowBytes, and, if prese nt,
99 * the color table. The returned address(es) is/are only valid while the im age object
100 * is in scope.
101 *
102 * The returned ImageInfo represents the backing memory. Use 'subset'
103 * to get the active portion's dimensions.
104 *
105 * On failure, return false and ignore the pixmap parameter.
106 */
107 bool peekPixels(SkPixmap*) const;
108
84 protected: 109 protected:
85 SkSpecialImage(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint32_t uniqueID) 110 SkSpecialImage(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint32_t uniqueID)
86 : fSubset(subset) 111 : fSubset(subset)
87 , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::I mageID() 112 , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::I mageID()
88 : uniqueID) 113 : uniqueID)
89 , fProxy(proxy) { 114 , fProxy(proxy) {
90 } 115 }
91 116
92 // The following 2 are for testing and shouldn't be used. 117 // The following 2 are for testing and shouldn't be used.
93 friend class TestingSpecialImageAccess; 118 friend class TestingSpecialImageAccess;
94 friend class TestingSpecialSurfaceAccess; 119 friend class TestingSpecialSurfaceAccess;
95 120
96 /**
97 * If the SpecialImage is backed by cpu pixels, return the const address
98 * of those pixels and, if not null, return the ImageInfo and rowBytes.
99 * The returned address is only valid while the image object is in scope.
100 *
101 * The returned ImageInfo represents the backing memory. Use 'subset'
102 * to get the active portion's dimensions.
103 *
104 * On failure, return false and ignore the pixmap parameter.
105 */
106 bool testingOnlyPeekPixels(SkPixmap*) const;
107
108 // This entry point is for testing only. It does a readback from VRAM for 121 // This entry point is for testing only. It does a readback from VRAM for
109 // GPU-backed special images. 122 // GPU-backed special images.
110 bool testingOnlyGetROPixels(SkBitmap*) const; 123 bool testingOnlyGetROPixels(SkBitmap*) const;
111 124
112 // TODO: remove this ASAP (see skbug.com/4965) 125 // TODO: remove this ASAP (see skbug.com/4965)
113 SkImageFilter::Proxy* proxy() const { return fProxy; } 126 SkImageFilter::Proxy* proxy() const { return fProxy; }
114 127
115 private: 128 private:
116 const SkIRect fSubset; 129 const SkIRect fSubset;
117 const uint32_t fUniqueID; 130 const uint32_t fUniqueID;
118 131
119 // TODO: remove this ASAP (see skbug.com/4965) 132 // TODO: remove this ASAP (see skbug.com/4965)
120 SkImageFilter::Proxy* fProxy; 133 SkImageFilter::Proxy* fProxy;
121 134
122 typedef SkRefCnt INHERITED; 135 typedef SkRefCnt INHERITED;
123 }; 136 };
124 137
125 #endif 138 #endif
126 139
OLDNEW
« no previous file with comments | « src/core/SkScalerContext.cpp ('k') | src/core/SkSpecialImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698