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 GrGLGpu_DEFINED | 8 #ifndef GrGLGpu_DEFINED |
9 #define GrGLGpu_DEFINED | 9 #define GrGLGpu_DEFINED |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 GrGLStandard glStandard() const { return fGLContext.standard(); } | 43 GrGLStandard glStandard() const { return fGLContext.standard(); } |
44 GrGLVersion glVersion() const { return fGLContext.version(); } | 44 GrGLVersion glVersion() const { return fGLContext.version(); } |
45 GrGLSLGeneration glslGeneration() const { return fGLContext.glslGeneration() ; } | 45 GrGLSLGeneration glslGeneration() const { return fGLContext.glslGeneration() ; } |
46 const GrGLCaps& glCaps() const { return *fGLContext.caps(); } | 46 const GrGLCaps& glCaps() const { return *fGLContext.caps(); } |
47 | 47 |
48 GrGLPathRendering* glPathRendering() { | 48 GrGLPathRendering* glPathRendering() { |
49 SkASSERT(glCaps().pathRenderingSupport()); | 49 SkASSERT(glCaps().pathRenderingSupport()); |
50 return static_cast<GrGLPathRendering*>(pathRendering()); | 50 return static_cast<GrGLPathRendering*>(pathRendering()); |
51 } | 51 } |
52 | 52 |
53 void willDeleteOrAbandonFramebuffer(GrGLFBO* fbo); | |
egdaniel
2015/02/25 16:21:34
comment on when and why this needs to be called.
| |
54 | |
53 void discard(GrRenderTarget*) SK_OVERRIDE; | 55 void discard(GrRenderTarget*) SK_OVERRIDE; |
54 | 56 |
55 // Used by GrGLProgram and GrGLPathTexGenProgramEffects to configure OpenGL | 57 // Used by GrGLProgram and GrGLPathTexGenProgramEffects to configure OpenGL |
56 // state. | 58 // state. |
57 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te xture); | 59 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te xture); |
58 | 60 |
59 // GrGpu overrides | 61 // GrGpu overrides |
60 GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig, | 62 GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig, |
61 GrPixelConfig surfaceConfig) const S K_OVERRIDE; | 63 GrPixelConfig surfaceConfig) const S K_OVERRIDE; |
62 GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig, | 64 GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig, |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 | 241 |
240 void initFSAASupport(); | 242 void initFSAASupport(); |
241 | 243 |
242 // determines valid stencil formats | 244 // determines valid stencil formats |
243 void initStencilFormats(); | 245 void initStencilFormats(); |
244 | 246 |
245 // sets a texture unit to use for texture operations other than binding a te xture to a program. | 247 // sets a texture unit to use for texture operations other than binding a te xture to a program. |
246 // ensures that such operations don't negatively interact with tracking boun d textures. | 248 // ensures that such operations don't negatively interact with tracking boun d textures. |
247 void setScratchTextureUnit(); | 249 void setScratchTextureUnit(); |
248 | 250 |
249 // bounds is region that may be modified and therefore has to be resolved. | 251 // Binds the render target, sets the viewport, tracks dirty are for resolve, and tracks whether |
250 // NULL means whole target. Can be an empty rect. | 252 // mip maps need rebuilding. bounds is region that may be modified by the dr aw. NULL means whole |
251 void flushRenderTarget(GrGLRenderTarget*, const SkIRect* bounds); | 253 // target. Can be an empty rect. |
254 void prepareToDrawToRenderTarget(GrGLRenderTarget*, const SkIRect* bounds); | |
255 | |
256 // On older GLs there may not be separate FBO bindings for draw and read. In that case these | |
257 // alias each other. | |
258 enum FBOBinding { | |
259 kDraw_FBOBinding, // drawing or dst of blit | |
260 kRead_FBOBinding, // src of blit, read pixels. | |
261 | |
262 kLast_FBOBinding = kRead_FBOBinding | |
263 }; | |
264 static const int kFBOBindingCnt = kLast_FBOBinding + 1; | |
egdaniel
2015/02/25 16:21:34
comment on why there is a +1 here? I'm assuming it
| |
265 | |
266 // binds the FBO and returns the GL enum of the framebuffer target it was bo und to. | |
267 GrGLenum bindFBO(FBOBinding, const GrGLFBO*); | |
268 | |
269 void setViewport(const GrGLIRect& viewport); | |
252 | 270 |
253 void flushStencil(const GrStencilSettings&); | 271 void flushStencil(const GrStencilSettings&); |
254 void flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool isLineDraw); | 272 void flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool isLineDraw); |
255 | 273 |
256 bool configToGLFormats(GrPixelConfig config, | 274 bool configToGLFormats(GrPixelConfig config, |
257 bool getSizedInternal, | 275 bool getSizedInternal, |
258 GrGLenum* internalFormat, | 276 GrGLenum* internalFormat, |
259 GrGLenum* externalFormat, | 277 GrGLenum* externalFormat, |
260 GrGLenum* externalType); | 278 GrGLenum* externalType); |
261 // helper for onCreateTexture and writeTexturePixels | 279 // helper for onCreateTexture and writeTexturePixels |
(...skipping 12 matching lines...) Expand all Loading... | |
274 // with new data. | 292 // with new data. |
275 bool uploadCompressedTexData(const GrSurfaceDesc& desc, | 293 bool uploadCompressedTexData(const GrSurfaceDesc& desc, |
276 const void* data, | 294 const void* data, |
277 bool isNewTexture = true, | 295 bool isNewTexture = true, |
278 int left = 0, int top = 0, | 296 int left = 0, int top = 0, |
279 int width = -1, int height = -1); | 297 int width = -1, int height = -1); |
280 | 298 |
281 bool createRenderTargetObjects(const GrSurfaceDesc&, bool budgeted, GrGLuint texID, | 299 bool createRenderTargetObjects(const GrSurfaceDesc&, bool budgeted, GrGLuint texID, |
282 GrGLRenderTarget::IDDesc*); | 300 GrGLRenderTarget::IDDesc*); |
283 | 301 |
284 enum TempFBOTarget { | 302 static const FBOBinding kInvalidFBOBinding = static_cast<FBOBinding>(-1); |
285 kSrc_TempFBOTarget, | |
286 kDst_TempFBOTarget | |
287 }; | |
288 | 303 |
289 GrGLuint bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLIRect* viewport, | 304 // Binds a surface as an FBO. A temporary FBO ID may be used if the surface is not already |
290 TempFBOTarget tempFBOTarget); | 305 // a render target. Afterwards unbindSurfaceAsFBOForCopy must be called with the value returned. |
306 FBOBinding bindSurfaceAsFBOForCopy(GrSurface*, FBOBinding, GrGLIRect* viewpo rt); | |
291 | 307 |
292 void unbindTextureFromFBO(GrGLenum fboTarget); | 308 // Must be matched with bindSurfaceAsFBOForCopy. |
309 void unbindSurfaceAsFBOForCopy(FBOBinding); | |
293 | 310 |
294 GrGLContext fGLContext; | 311 GrGLContext fGLContext; |
295 | 312 |
296 // GL program-related state | 313 // GL program-related state |
297 ProgramCache* fProgramCache; | 314 ProgramCache* fProgramCache; |
298 SkAutoTUnref<GrGLProgram> fCurrentProgram; | 315 SkAutoTUnref<GrGLProgram> fCurrentProgram; |
299 | 316 |
300 /////////////////////////////////////////////////////////////////////////// | 317 /////////////////////////////////////////////////////////////////////////// |
301 ///@name Caching of GL State | 318 ///@name Caching of GL State |
302 ///@{ | 319 ///@{ |
303 int fHWActiveTextureUnitIdx; | 320 int fHWActiveTextureUnitIdx; |
304 GrGLuint fHWProgramID; | 321 GrGLuint fHWProgramID; |
305 | 322 |
306 enum TriState { | 323 enum TriState { |
307 kNo_TriState, | 324 kNo_TriState, |
308 kYes_TriState, | 325 kYes_TriState, |
309 kUnknown_TriState | 326 kUnknown_TriState |
310 }; | 327 }; |
311 | 328 |
312 GrGLuint fTempSrcFBOID; | 329 SkAutoTUnref<GrGLFBO> fTempSrcFBO; |
313 GrGLuint fTempDstFBOID; | 330 SkAutoTUnref<GrGLFBO> fTempDstFBO; |
314 | 331 SkAutoTUnref<GrGLFBO> fStencilClearFBO; |
315 GrGLuint fStencilClearFBOID; | |
316 | 332 |
317 // last scissor / viewport scissor state seen by the GL. | 333 // last scissor / viewport scissor state seen by the GL. |
318 struct { | 334 struct { |
319 TriState fEnabled; | 335 TriState fEnabled; |
320 GrGLIRect fRect; | 336 GrGLIRect fRect; |
321 void invalidate() { | 337 void invalidate() { |
322 fEnabled = kUnknown_TriState; | 338 fEnabled = kUnknown_TriState; |
323 fRect.invalidate(); | 339 fRect.invalidate(); |
324 } | 340 } |
325 } fHWScissorSettings; | 341 } fHWScissorSettings; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 | 467 |
452 TriState fMSAAEnabled; | 468 TriState fMSAAEnabled; |
453 | 469 |
454 GrStencilSettings fHWStencilSettings; | 470 GrStencilSettings fHWStencilSettings; |
455 TriState fHWStencilTestEnabled; | 471 TriState fHWStencilTestEnabled; |
456 | 472 |
457 | 473 |
458 GrPipelineBuilder::DrawFace fHWDrawFace; | 474 GrPipelineBuilder::DrawFace fHWDrawFace; |
459 TriState fHWWriteToColor; | 475 TriState fHWWriteToColor; |
460 TriState fHWDitherEnabled; | 476 TriState fHWDitherEnabled; |
461 uint32_t fHWBoundRenderTargetUniqueID; | |
462 SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs; | 477 SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs; |
463 | 478 |
479 // Track fbo binding state. | |
480 struct HWFBOBinding { | |
481 uint32_t fGenID; | |
482 bool fIsDefaultFBO; | |
483 void invalidate() { | |
484 fGenID = SK_InvalidGenID; | |
485 fIsDefaultFBO = false; | |
486 } | |
487 } fHWFBOBinding[kFBOBindingCnt]; | |
egdaniel
2015/02/25 16:21:34
Do you want 3 of these? Is one for an invalidBindi
| |
488 | |
464 ///@} | 489 ///@} |
465 | 490 |
466 // we record what stencil format worked last time to hopefully exit early | 491 // we record what stencil format worked last time to hopefully exit early |
467 // from our loop that tries stencil formats and calls check fb status. | 492 // from our loop that tries stencil formats and calls check fb status. |
468 int fLastSuccessfulStencilFmtIdx; | 493 int fLastSuccessfulStencilFmtIdx; |
469 | 494 |
470 typedef GrGpu INHERITED; | 495 typedef GrGpu INHERITED; |
471 friend class GrGLPathRendering; // For accessing setTextureUnit. | 496 friend class GrGLPathRendering; // For accessing setTextureUnit. |
472 }; | 497 }; |
473 | 498 |
474 #endif | 499 #endif |
OLD | NEW |