OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrGpu_DEFINED | 8 #ifndef GrGpu_DEFINED |
9 #define GrGpu_DEFINED | 9 #define GrGpu_DEFINED |
10 | 10 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 * | 126 * |
127 * @return The index buffer if successful, otherwise NULL. | 127 * @return The index buffer if successful, otherwise NULL. |
128 */ | 128 */ |
129 GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic); | 129 GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic); |
130 | 130 |
131 /** | 131 /** |
132 * Resolves MSAA. | 132 * Resolves MSAA. |
133 */ | 133 */ |
134 void resolveRenderTarget(GrRenderTarget* target); | 134 void resolveRenderTarget(GrRenderTarget* target); |
135 | 135 |
| 136 /** Info struct returned by getReadPixelsInfo about performing intermediate
draws before |
| 137 reading pixels for performance or correctness. */ |
| 138 struct ReadPixelTempDrawInfo { |
| 139 /** If the GrGpu is requesting that the caller do a draw to an intermedi
ate surface then |
| 140 this is descriptor for the temp surface. The draw should always be a
rect with |
| 141 dst 0,0,w,h. */ |
| 142 GrSurfaceDesc fTempSurfaceDesc; |
| 143 /** Indicates whether there is a performance advantage to using an exact
match texture |
| 144 (in terms of width and height) for the intermediate texture instead
of approximate. */ |
| 145 bool fUseExactScratch; |
| 146 /** The caller should swap the R and B channel in the temp draw and then
instead of reading |
| 147 the desired config back it should read GrPixelConfigSwapRAndB(readCo
nfig). The swap |
| 148 during the draw and the swap at readback time cancel and the client
gets the correct |
| 149 data. The swapped read back is either faster for or required by the
underlying backend |
| 150 3D API. */ |
| 151 bool fSwapRAndB; |
| 152 }; |
| 153 /** Describes why an intermediate draw must/should be performed before readP
ixels. */ |
| 154 enum DrawPreference { |
| 155 /** On input means that the caller would proceed without draw if the GrG
pu doesn't request |
| 156 one. |
| 157 On output means that the GrGpu is not requesting a draw. */ |
| 158 kNoDraw_DrawPreference, |
| 159 /** Means that the client would prefer a draw for performance of the rea
dback but |
| 160 can satisfy a straight readPixels call on the inputs without an inte
rmediate draw. |
| 161 getReadPixelsInfo will never set the draw preference to this value b
ut may leave |
| 162 it set. */ |
| 163 kCallerPrefersDraw_DrawPreference, |
| 164 /** On output means that GrGpu would prefer a draw for performance of th
e readback but |
| 165 can satisfy a straight readPixels call on the inputs without an inte
rmediate draw. The |
| 166 caller of getReadPixelsInfo should never specify this on intput. */ |
| 167 kGpuPrefersDraw_DrawPreference, |
| 168 /** On input means that the caller requires a draw to do a transformatio
n and there is no |
| 169 CPU fallback. |
| 170 On output means that GrGpu can only satisfy the readPixels request i
f the intermediate |
| 171 draw is performed. |
| 172 */ |
| 173 kRequireDraw_DrawPreference |
| 174 }; |
| 175 |
| 176 /** Used to negotiates whether and how an intermediate draw should or must b
e performed before |
| 177 a readPixels call. If this returns false then GrGpu could not deduce an
intermediate draw |
| 178 that would allow a successful readPixels call. */ |
| 179 virtual bool getReadPixelsInfo(GrSurface* srcSurface, int readWidth, int rea
dHeight, |
| 180 size_t rowBytes, GrPixelConfig readConfig, Dr
awPreference*, |
| 181 ReadPixelTempDrawInfo *) = 0; |
| 182 |
136 /** | 183 /** |
137 * Gets a preferred 8888 config to use for writing/reading pixel data to/fro
m a surface with | 184 * Gets a preferred 8888 config to use for writing pixel data to a surface w
ith |
138 * config surfaceConfig. The returned config must have at least as many bits
per channel as the | 185 * config surfaceConfig. The returned config must have at least as many bits
per channel as the |
139 * readConfig or writeConfig param. | 186 * writeConfig param. |
140 */ | 187 */ |
141 virtual GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig, | |
142 GrPixelConfig surfaceConfig)
const { | |
143 return readConfig; | |
144 } | |
145 virtual GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig, | 188 virtual GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig, |
146 GrPixelConfig surfaceConfig
) const { | 189 GrPixelConfig surfaceConfig
) const { |
147 return writeConfig; | 190 return writeConfig; |
148 } | 191 } |
149 | 192 |
150 /** | 193 /** |
151 * Called before uploading writing pixels to a GrTexture when the src pixel
config doesn't | 194 * Called before uploading writing pixels to a GrTexture when the src pixel
config doesn't |
152 * match the texture's config. | 195 * match the texture's config. |
153 */ | 196 */ |
154 virtual bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig
) const = 0; | 197 virtual bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig
) const = 0; |
155 | 198 |
156 /** | 199 /** |
157 * OpenGL's readPixels returns the result bottom-to-top while the skia | |
158 * API is top-to-bottom. Thus we have to do a y-axis flip. The obvious | |
159 * solution is to have the subclass do the flip using either the CPU or GPU. | |
160 * However, the caller (GrContext) may have transformations to apply and can | |
161 * simply fold in the y-flip for free. On the other hand, the subclass may | |
162 * be able to do it for free itself. For example, the subclass may have to | |
163 * do memcpys to handle rowBytes that aren't tight. It could do the y-flip | |
164 * concurrently. | |
165 * | |
166 * This function returns true if a y-flip is required to put the pixels in | |
167 * top-to-bottom order and the subclass cannot do it for free. | |
168 * | |
169 * See read pixels for the params | |
170 * @return true if calling readPixels with the same set of params will | |
171 * produce bottom-to-top data | |
172 */ | |
173 virtual bool readPixelsWillPayForYFlip(GrRenderTarget* renderTarget, | |
174 int left, int top, | |
175 int width, int height, | |
176 GrPixelConfig config, | |
177 size_t rowBytes) const = 0; | |
178 /** | |
179 * This should return true if reading a NxM rectangle of pixels from a | |
180 * render target is faster if the target has dimensons N and M and the read | |
181 * rectangle has its top-left at 0,0. | |
182 */ | |
183 virtual bool fullReadPixelsIsFasterThanPartial() const { return false; }; | |
184 | |
185 /** | |
186 * Reads a rectangle of pixels from a render target. | 200 * Reads a rectangle of pixels from a render target. |
187 * | 201 * |
188 * @param renderTarget the render target to read from. NULL means the | 202 * @param renderTarget the render target to read from. NULL means the |
189 * current render target. | 203 * current render target. |
190 * @param left left edge of the rectangle to read (inclusive) | 204 * @param left left edge of the rectangle to read (inclusive) |
191 * @param top top edge of the rectangle to read (inclusive) | 205 * @param top top edge of the rectangle to read (inclusive) |
192 * @param width width of rectangle to read in pixels. | 206 * @param width width of rectangle to read in pixels. |
193 * @param height height of rectangle to read in pixels. | 207 * @param height height of rectangle to read in pixels. |
194 * @param config the pixel config of the destination buffer | 208 * @param config the pixel config of the destination buffer |
195 * @param buffer memory to read the rectangle into. | 209 * @param buffer memory to read the rectangle into. |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 GrTraceMarkerSet fActiveT
raceMarkers; | 488 GrTraceMarkerSet fActiveT
raceMarkers; |
475 GrTraceMarkerSet fStoredT
raceMarkers; | 489 GrTraceMarkerSet fStoredT
raceMarkers; |
476 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 490 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
477 GrContext* fContext
; | 491 GrContext* fContext
; |
478 | 492 |
479 friend class GrPathRendering; | 493 friend class GrPathRendering; |
480 typedef SkRefCnt INHERITED; | 494 typedef SkRefCnt INHERITED; |
481 }; | 495 }; |
482 | 496 |
483 #endif | 497 #endif |
OLD | NEW |