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