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 | 136 /** Info struct returned by getReadPixelsInfo about performing intermediate draws before |
137 reading pixels for performance or correctness. */ | 137 reading pixels for performance or correctness. */ |
138 struct ReadPixelTempDrawInfo { | 138 struct ReadPixelTempDrawInfo { |
139 /** If the GrGpu is requesting that the caller do a draw to an intermedi ate surface then | 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 | 140 this is descriptor for the temp surface. The draw should always be a rect with |
141 dst 0,0,w,h. */ | 141 dst 0,0,w,h. */ |
142 GrSurfaceDesc fTempSurfaceDesc; | 142 GrSurfaceDesc fTempSurfaceDesc; |
143 /** Indicates whether there is a performance advantage to using an exact match texture | 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. */ | 144 (in terms of width and height) for the intermediate texture instead of approximate. */ |
145 bool fUseExactScratch; | 145 bool fUseExactScratch; |
146 /** The caller should swap the R and B channel in the temp draw and then instead of reading | 146 /** The caller should swap the R and B channel in the temp draw and then instead of reading |
(...skipping 19 matching lines...) Expand all Loading... | |
166 caller of getReadPixelsInfo should never specify this on intput. */ | 166 caller of getReadPixelsInfo should never specify this on intput. */ |
167 kGpuPrefersDraw_DrawPreference, | 167 kGpuPrefersDraw_DrawPreference, |
168 /** On input means that the caller requires a draw to do a transformatio n and there is no | 168 /** On input means that the caller requires a draw to do a transformatio n and there is no |
169 CPU fallback. | 169 CPU fallback. |
170 On output means that GrGpu can only satisfy the readPixels request i f the intermediate | 170 On output means that GrGpu can only satisfy the readPixels request i f the intermediate |
171 draw is performed. | 171 draw is performed. |
172 */ | 172 */ |
173 kRequireDraw_DrawPreference | 173 kRequireDraw_DrawPreference |
174 }; | 174 }; |
175 | 175 |
176 /** Used to negotiates whether and how an intermediate draw should or must b e performed before | 176 /** |
177 a readPixels call. If this returns false then GrGpu could not deduce an intermediate draw | 177 * Used to negotiate whether and how an intermediate draw should or must be performed before |
178 that would allow a successful readPixels call. */ | 178 * a readPixels call. If this returns false then GrGpu could not deduce an i ntermediate draw |
179 virtual bool getReadPixelsInfo(GrSurface* srcSurface, int readWidth, int rea dHeight, | 179 * that would allow a successful readPixels call. The passed width, height, and rowBytes, |
180 size_t rowBytes, GrPixelConfig readConfig, Dr awPreference*, | 180 * must be non-zero and already reflect clipping to the src bounds. |
181 ReadPixelTempDrawInfo *) = 0; | 181 */ |
182 bool getReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeight, size_t rowBytes, | |
183 GrPixelConfig readConfig, DrawPreference*, ReadPixelT empDrawInfo*); | |
184 | |
185 /** Info struct returned by getWritePixelsInfo about performing an intermedi ate draw in order | |
186 to write pixels to a GrSurface for either performance or correctness rea sons. */ | |
187 struct WritePixelTempDrawInfo { | |
188 /** If the GrGpu is requesting that the caller upload to an intermediate surface and draw | |
189 that to the dst then this is the descriptor for the intermediate sur face. The caller | |
190 should upload the pixels such that the upper left pixel of the uploa d rect is at 0,0 in | |
191 the intermediate surface.*/ | |
192 GrSurfaceDesc fTempSurfaceDesc; | |
robertphillips
2015/07/28 13:15:23
If set, ?
bsalomon
2015/07/28 14:58:17
Done.
| |
193 /** If set fTempSurfaceDesc's config will be a R/B swap of the src pixel config. The caller | |
194 should upload the pixels as is such that R and B will be swapped in the intermediate | |
195 surface. When the intermediate is drawn to the dst the shader should swap R/B again | |
196 such that the correct swizzle results in the dst. This is done to wo rk around either | |
197 performance or API restrictions in the backend 3D API implementation . */ | |
198 bool fSwapRAndB; | |
199 }; | |
182 | 200 |
183 /** | 201 /** |
184 * Gets a preferred 8888 config to use for writing pixel data to a surface w ith | 202 * Used to negotiate whether and how an intermediate surface should be used to write pixels to |
185 * config surfaceConfig. The returned config must have at least as many bits per channel as the | 203 * a GrSurface. If this returns false then GrGpu could not deduce an interme diate draw |
186 * writeConfig param. | 204 * that would allow a successful transfer of the src pixels to the dst. The passed width, |
205 * height, and rowBytes, must be non-zero and already reflect clipping to th e dst bounds. | |
187 */ | 206 */ |
188 virtual GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig, | 207 bool getWritePixelsInfo(GrSurface* dstSurface, int width, int height, size_t rowBytes, |
189 GrPixelConfig surfaceConfig ) const { | 208 GrPixelConfig srcConfig, DrawPreference*, WritePixel TempDrawInfo*); |
190 return writeConfig; | |
191 } | |
192 | |
193 /** | |
194 * Called before uploading writing pixels to a GrTexture when the src pixel config doesn't | |
195 * match the texture's config. | |
196 */ | |
197 virtual bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig ) const = 0; | |
198 | 209 |
199 /** | 210 /** |
200 * Reads a rectangle of pixels from a render target. | 211 * Reads a rectangle of pixels from a render target. |
201 * | 212 * |
202 * @param renderTarget the render target to read from. NULL means the | 213 * @param renderTarget the render target to read from. NULL means the |
203 * current render target. | 214 * current render target. |
204 * @param left left edge of the rectangle to read (inclusive) | 215 * @param left left edge of the rectangle to read (inclusive) |
205 * @param top top edge of the rectangle to read (inclusive) | 216 * @param top top edge of the rectangle to read (inclusive) |
206 * @param width width of rectangle to read in pixels. | 217 * @param width width of rectangle to read in pixels. |
207 * @param height height of rectangle to read in pixels. | 218 * @param height height of rectangle to read in pixels. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 // stencil funcs supported by GPUs. | 405 // stencil funcs supported by GPUs. |
395 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, | 406 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, |
396 GrStencilFunc func); | 407 GrStencilFunc func); |
397 static void ConvertStencilFuncAndMask(GrStencilFunc func, | 408 static void ConvertStencilFuncAndMask(GrStencilFunc func, |
398 bool clipInStencil, | 409 bool clipInStencil, |
399 unsigned int clipBit, | 410 unsigned int clipBit, |
400 unsigned int userBits, | 411 unsigned int userBits, |
401 unsigned int* ref, | 412 unsigned int* ref, |
402 unsigned int* mask); | 413 unsigned int* mask); |
403 | 414 |
415 static void ElevateDrawPreference(GrGpu::DrawPreference* preference, | |
416 GrGpu::DrawPreference elevation) { | |
417 GR_STATIC_ASSERT(GrGpu::kCallerPrefersDraw_DrawPreference > GrGpu::kNoDr aw_DrawPreference); | |
418 GR_STATIC_ASSERT(GrGpu::kGpuPrefersDraw_DrawPreference > | |
419 GrGpu::kCallerPrefersDraw_DrawPreference); | |
420 GR_STATIC_ASSERT(GrGpu::kRequireDraw_DrawPreference > | |
421 GrGpu::kGpuPrefersDraw_DrawPreference); | |
422 *preference = SkTMax(*preference, elevation); | |
423 } | |
424 | |
404 const GrTraceMarkerSet& getActiveTraceMarkers() const { return fActiveTraceM arkers; } | 425 const GrTraceMarkerSet& getActiveTraceMarkers() const { return fActiveTraceM arkers; } |
405 | 426 |
406 Stats fStats; | 427 Stats fStats; |
407 SkAutoTDelete<GrPathRendering> fPathRendering; | 428 SkAutoTDelete<GrPathRendering> fPathRendering; |
408 // Subclass must initialize this in its constructor. | 429 // Subclass must initialize this in its constructor. |
409 SkAutoTUnref<const GrCaps> fCaps; | 430 SkAutoTUnref<const GrCaps> fCaps; |
410 | 431 |
411 private: | 432 private: |
412 // called when the 3D context state is unknown. Subclass should emit any | 433 // called when the 3D context state is unknown. Subclass should emit any |
413 // assumed 3D context state and dirty any state cache. | 434 // assumed 3D context state and dirty any state cache. |
(...skipping 19 matching lines...) Expand all Loading... | |
433 bool canIgnoreRect) = 0; | 454 bool canIgnoreRect) = 0; |
434 | 455 |
435 | 456 |
436 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is | 457 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is |
437 // ONLY used by the the clip target | 458 // ONLY used by the the clip target |
438 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0; | 459 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0; |
439 | 460 |
440 // overridden by backend-specific derived class to perform the draw call. | 461 // overridden by backend-specific derived class to perform the draw call. |
441 virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0; | 462 virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0; |
442 | 463 |
464 virtual bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int r eadHeight, | |
465 size_t rowBytes, GrPixelConfig readConfig, DrawPreference*, | |
466 ReadPixelTempDrawInfo*) = 0; | |
467 virtual bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int heig ht, size_t rowBytes, | |
468 GrPixelConfig srcConfig, DrawPreference*, | |
469 WritePixelTempDrawInfo*) = 0; | |
470 | |
443 virtual bool onReadPixels(GrRenderTarget* target, | 471 virtual bool onReadPixels(GrRenderTarget* target, |
444 int left, int top, int width, int height, | 472 int left, int top, int width, int height, |
445 GrPixelConfig, | 473 GrPixelConfig, |
446 void* buffer, | 474 void* buffer, |
447 size_t rowBytes) = 0; | 475 size_t rowBytes) = 0; |
448 | 476 |
449 // overridden by backend-specific derived class to perform the texture updat e | 477 // overridden by backend-specific derived class to perform the texture updat e |
450 virtual bool onWriteTexturePixels(GrTexture* texture, | 478 virtual bool onWriteTexturePixels(GrTexture* texture, |
451 int left, int top, int width, int height, | 479 int left, int top, int width, int height, |
452 GrPixelConfig config, const void* buffer, | 480 GrPixelConfig config, const void* buffer, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 GrTraceMarkerSet fActiveT raceMarkers; | 516 GrTraceMarkerSet fActiveT raceMarkers; |
489 GrTraceMarkerSet fStoredT raceMarkers; | 517 GrTraceMarkerSet fStoredT raceMarkers; |
490 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 518 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
491 GrContext* fContext ; | 519 GrContext* fContext ; |
492 | 520 |
493 friend class GrPathRendering; | 521 friend class GrPathRendering; |
494 typedef SkRefCnt INHERITED; | 522 typedef SkRefCnt INHERITED; |
495 }; | 523 }; |
496 | 524 |
497 #endif | 525 #endif |
OLD | NEW |