| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 237 |
| 238 void initFSAASupport(); | 238 void initFSAASupport(); |
| 239 | 239 |
| 240 // determines valid stencil formats | 240 // determines valid stencil formats |
| 241 void initStencilFormats(); | 241 void initStencilFormats(); |
| 242 | 242 |
| 243 // sets a texture unit to use for texture operations other than binding a te
xture to a program. | 243 // sets a texture unit to use for texture operations other than binding a te
xture to a program. |
| 244 // ensures that such operations don't negatively interact with tracking boun
d textures. | 244 // ensures that such operations don't negatively interact with tracking boun
d textures. |
| 245 void setScratchTextureUnit(); | 245 void setScratchTextureUnit(); |
| 246 | 246 |
| 247 // Enumerates the reasons for binding an FBO. | 247 // bounds is region that may be modified and therefore has to be resolved. |
| 248 enum FBOBinding { | 248 // NULL means whole target. Can be an empty rect. |
| 249 kDraw_FBOBinding, | 249 void flushRenderTarget(GrGLRenderTarget*, const SkIRect* bounds); |
| 250 kClear_FBOBinding, | |
| 251 kDiscard_FBOBinding, | |
| 252 kChangeAttachments_FBOBinding, | |
| 253 kReadPixels_FBOBinding, | |
| 254 kCopyTexSrc_FBOBinding, | |
| 255 kBlitSrc_FBOBinding, | |
| 256 kBlitDst_FBOBinding, | |
| 257 }; | |
| 258 | |
| 259 // binds the FBO and returns the GL enum of the framebuffer target it was bo
und to. | |
| 260 GrGLenum bindFBO(FBOBinding, const GrGLFBO*); | |
| 261 | |
| 262 // Tracks dirty area for resolve, and tracks whether mip maps need rebuildin
g. bounds is the | |
| 263 // region that may be modified. NULL means whole surface. Can be an empty re
ct. | |
| 264 void markSurfaceContentsDirty(GrSurface*, const SkIRect* bounds); | |
| 265 | |
| 266 void setViewport(const GrGLIRect& viewport); | |
| 267 | 250 |
| 268 void flushStencil(const GrStencilSettings&); | 251 void flushStencil(const GrStencilSettings&); |
| 269 | |
| 270 void flushHWAAState(GrRenderTarget* rt, bool useHWAA); | 252 void flushHWAAState(GrRenderTarget* rt, bool useHWAA); |
| 271 | 253 |
| 272 bool configToGLFormats(GrPixelConfig config, | 254 bool configToGLFormats(GrPixelConfig config, |
| 273 bool getSizedInternal, | 255 bool getSizedInternal, |
| 274 GrGLenum* internalFormat, | 256 GrGLenum* internalFormat, |
| 275 GrGLenum* externalFormat, | 257 GrGLenum* externalFormat, |
| 276 GrGLenum* externalType); | 258 GrGLenum* externalType); |
| 277 // helper for onCreateTexture and writeTexturePixels | 259 // helper for onCreateTexture and writeTexturePixels |
| 278 bool uploadTexData(const GrSurfaceDesc& desc, | 260 bool uploadTexData(const GrSurfaceDesc& desc, |
| 279 bool isNewTexture, | 261 bool isNewTexture, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 290 // with new data. | 272 // with new data. |
| 291 bool uploadCompressedTexData(const GrSurfaceDesc& desc, | 273 bool uploadCompressedTexData(const GrSurfaceDesc& desc, |
| 292 const void* data, | 274 const void* data, |
| 293 bool isNewTexture = true, | 275 bool isNewTexture = true, |
| 294 int left = 0, int top = 0, | 276 int left = 0, int top = 0, |
| 295 int width = -1, int height = -1); | 277 int width = -1, int height = -1); |
| 296 | 278 |
| 297 bool createRenderTargetObjects(const GrSurfaceDesc&, bool budgeted, GrGLuint
texID, | 279 bool createRenderTargetObjects(const GrSurfaceDesc&, bool budgeted, GrGLuint
texID, |
| 298 GrGLRenderTarget::IDDesc*); | 280 GrGLRenderTarget::IDDesc*); |
| 299 | 281 |
| 300 static const FBOBinding kInvalidFBOBinding = static_cast<FBOBinding>(-1); | 282 enum TempFBOTarget { |
| 283 kSrc_TempFBOTarget, |
| 284 kDst_TempFBOTarget |
| 285 }; |
| 301 | 286 |
| 302 // Binds a surface as an FBO. A temporary FBO ID may be used if the surface
is not already | 287 GrGLuint bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLIRect*
viewport, |
| 303 // a render target. Afterwards unbindSurfaceAsFBOForCopy must be called with
the value returned. | 288 TempFBOTarget tempFBOTarget); |
| 304 FBOBinding bindSurfaceAsFBOForCopy(GrSurface*, FBOBinding, GrGLIRect* viewpo
rt); | |
| 305 | 289 |
| 306 // Must be matched with bindSurfaceAsFBOForCopy. | 290 void unbindTextureFromFBO(GrGLenum fboTarget); |
| 307 void unbindSurfaceAsFBOForCopy(FBOBinding); | |
| 308 | 291 |
| 309 GrGLContext fGLContext; | 292 GrGLContext fGLContext; |
| 310 | 293 |
| 311 // GL program-related state | 294 // GL program-related state |
| 312 ProgramCache* fProgramCache; | 295 ProgramCache* fProgramCache; |
| 313 SkAutoTUnref<GrGLProgram> fCurrentProgram; | 296 SkAutoTUnref<GrGLProgram> fCurrentProgram; |
| 314 | 297 |
| 315 /////////////////////////////////////////////////////////////////////////// | 298 /////////////////////////////////////////////////////////////////////////// |
| 316 ///@name Caching of GL State | 299 ///@name Caching of GL State |
| 317 ///@{ | 300 ///@{ |
| 318 int fHWActiveTextureUnitIdx; | 301 int fHWActiveTextureUnitIdx; |
| 319 GrGLuint fHWProgramID; | 302 GrGLuint fHWProgramID; |
| 320 | 303 |
| 321 enum TriState { | 304 enum TriState { |
| 322 kNo_TriState, | 305 kNo_TriState, |
| 323 kYes_TriState, | 306 kYes_TriState, |
| 324 kUnknown_TriState | 307 kUnknown_TriState |
| 325 }; | 308 }; |
| 326 | 309 |
| 327 SkAutoTUnref<GrGLFBO> fTempSrcFBO; | 310 GrGLuint fTempSrcFBOID; |
| 328 SkAutoTUnref<GrGLFBO> fTempDstFBO; | 311 GrGLuint fTempDstFBOID; |
| 329 SkAutoTUnref<GrGLFBO> fStencilClearFBO; | 312 |
| 313 GrGLuint fStencilClearFBOID; |
| 330 | 314 |
| 331 // last scissor / viewport scissor state seen by the GL. | 315 // last scissor / viewport scissor state seen by the GL. |
| 332 struct { | 316 struct { |
| 333 TriState fEnabled; | 317 TriState fEnabled; |
| 334 GrGLIRect fRect; | 318 GrGLIRect fRect; |
| 335 void invalidate() { | 319 void invalidate() { |
| 336 fEnabled = kUnknown_TriState; | 320 fEnabled = kUnknown_TriState; |
| 337 fRect.invalidate(); | 321 fRect.invalidate(); |
| 338 } | 322 } |
| 339 } fHWScissorSettings; | 323 } fHWScissorSettings; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 449 |
| 466 TriState fMSAAEnabled; | 450 TriState fMSAAEnabled; |
| 467 | 451 |
| 468 GrStencilSettings fHWStencilSettings; | 452 GrStencilSettings fHWStencilSettings; |
| 469 TriState fHWStencilTestEnabled; | 453 TriState fHWStencilTestEnabled; |
| 470 | 454 |
| 471 | 455 |
| 472 GrPipelineBuilder::DrawFace fHWDrawFace; | 456 GrPipelineBuilder::DrawFace fHWDrawFace; |
| 473 TriState fHWWriteToColor; | 457 TriState fHWWriteToColor; |
| 474 TriState fHWDitherEnabled; | 458 TriState fHWDitherEnabled; |
| 459 uint32_t fHWBoundRenderTargetUniqueID; |
| 475 SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs; | 460 SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs; |
| 476 | 461 |
| 477 // Track fbo binding state for GL_DRAW_FRAMEBUFFER and GL_READ_FRAMEBUFFER | |
| 478 struct HWFBOBinding { | |
| 479 SkAutoTUnref<const GrGLFBO> fFBO; | |
| 480 void invalidate() { fFBO.reset(NULL); } | |
| 481 } fHWFBOBinding[2]; | |
| 482 | |
| 483 ///@} | 462 ///@} |
| 484 | 463 |
| 485 // we record what stencil format worked last time to hopefully exit early | 464 // we record what stencil format worked last time to hopefully exit early |
| 486 // from our loop that tries stencil formats and calls check fb status. | 465 // from our loop that tries stencil formats and calls check fb status. |
| 487 int fLastSuccessfulStencilFmtIdx; | 466 int fLastSuccessfulStencilFmtIdx; |
| 488 | 467 |
| 489 typedef GrGpu INHERITED; | 468 typedef GrGpu INHERITED; |
| 490 friend class GrGLPathRendering; // For accessing setTextureUnit. | 469 friend class GrGLPathRendering; // For accessing setTextureUnit. |
| 491 }; | 470 }; |
| 492 | 471 |
| 493 #endif | 472 #endif |
| OLD | NEW |