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