| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 * which (called as part of GrGpu's implementation of onDraw and | 299 * which (called as part of GrGpu's implementation of onDraw and |
| 300 * onStencilPath member functions.) The GrGpu subclass should flush the | 300 * onStencilPath member functions.) The GrGpu subclass should flush the |
| 301 * stencil state to the 3D API in its implementation of flushGraphicsState. | 301 * stencil state to the 3D API in its implementation of flushGraphicsState. |
| 302 */ | 302 */ |
| 303 void enableScissor(const SkIRect& rect) { | 303 void enableScissor(const SkIRect& rect) { |
| 304 fScissorState.fEnabled = true; | 304 fScissorState.fEnabled = true; |
| 305 fScissorState.fRect = rect; | 305 fScissorState.fRect = rect; |
| 306 } | 306 } |
| 307 void disableScissor() { fScissorState.fEnabled = false; } | 307 void disableScissor() { fScissorState.fEnabled = false; } |
| 308 | 308 |
| 309 /** |
| 310 * Like the scissor methods above this is called by setupClipping and |
| 311 * should be flushed by the GrGpu subclass in flushGraphicsState. These |
| 312 * stencil settings should be used in place of those on the GrDrawState. |
| 313 * They have been adjusted to account for any interactions between the |
| 314 * GrDrawState's stencil settings and stencil clipping. |
| 315 */ |
| 316 void setStencilSettings(const GrStencilSettings& settings) { |
| 317 fStencilSettings = settings; |
| 318 } |
| 319 void disableStencil() { fStencilSettings.setDisabled(); } |
| 320 |
| 309 // GrGpu subclass sets clip bit in the stencil buffer. The subclass is | 321 // GrGpu subclass sets clip bit in the stencil buffer. The subclass is |
| 310 // free to clear the remaining bits to zero if masked clears are more | 322 // free to clear the remaining bits to zero if masked clears are more |
| 311 // expensive than clearing all bits. | 323 // expensive than clearing all bits. |
| 312 virtual void clearStencilClip(GrRenderTarget*, const SkIRect& rect, bool ins
ideClip) = 0; | 324 virtual void clearStencilClip(GrRenderTarget*, const SkIRect& rect, bool ins
ideClip) = 0; |
| 313 | 325 |
| 314 enum PrivateDrawStateStateBits { | 326 enum PrivateDrawStateStateBits { |
| 315 kFirstBit = (GrDrawState::kLastPublicStateBit << 1), | 327 kFirstBit = (GrDrawState::kLastPublicStateBit << 1), |
| 316 | 328 |
| 317 kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify | 329 kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify |
| 318 // stencil bits used for | 330 // stencil bits used for |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 return kDrawLines_DrawType; | 362 return kDrawLines_DrawType; |
| 351 default: | 363 default: |
| 352 SkFAIL("Unexpected primitive type"); | 364 SkFAIL("Unexpected primitive type"); |
| 353 return kDrawTriangles_DrawType; | 365 return kDrawTriangles_DrawType; |
| 354 } | 366 } |
| 355 } | 367 } |
| 356 | 368 |
| 357 // prepares clip flushes gpu state before a draw | 369 // prepares clip flushes gpu state before a draw |
| 358 bool setupClipAndFlushState(DrawType, | 370 bool setupClipAndFlushState(DrawType, |
| 359 const GrDeviceCoordTexture* dstCopy, | 371 const GrDeviceCoordTexture* dstCopy, |
| 360 GrDrawState::AutoRestoreEffects*, | 372 GrDrawState::AutoRestoreEffects* are, |
| 361 GrDrawState::AutoRestoreStencil*, | |
| 362 const SkRect* devBounds); | 373 const SkRect* devBounds); |
| 363 | 374 |
| 364 // Functions used to map clip-respecting stencil tests into normal | 375 // Functions used to map clip-respecting stencil tests into normal |
| 365 // stencil funcs supported by GPUs. | 376 // stencil funcs supported by GPUs. |
| 366 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, | 377 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, |
| 367 GrStencilFunc func); | 378 GrStencilFunc func); |
| 368 static void ConvertStencilFuncAndMask(GrStencilFunc func, | 379 static void ConvertStencilFuncAndMask(GrStencilFunc func, |
| 369 bool clipInStencil, | 380 bool clipInStencil, |
| 370 unsigned int clipBit, | 381 unsigned int clipBit, |
| 371 unsigned int userBits, | 382 unsigned int userBits, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 386 const GeometryPoolState& getGeomPoolState() { | 397 const GeometryPoolState& getGeomPoolState() { |
| 387 return fGeomPoolStateStack.back(); | 398 return fGeomPoolStateStack.back(); |
| 388 } | 399 } |
| 389 | 400 |
| 390 // The state of the scissor is controlled by the clip manager | 401 // The state of the scissor is controlled by the clip manager |
| 391 struct ScissorState { | 402 struct ScissorState { |
| 392 bool fEnabled; | 403 bool fEnabled; |
| 393 SkIRect fRect; | 404 SkIRect fRect; |
| 394 } fScissorState; | 405 } fScissorState; |
| 395 | 406 |
| 407 // The final stencil settings to use as determined by the clip manager. |
| 408 GrStencilSettings fStencilSettings; |
| 409 |
| 396 // Helpers for setting up geometry state | 410 // Helpers for setting up geometry state |
| 397 void finalizeReservedVertices(); | 411 void finalizeReservedVertices(); |
| 398 void finalizeReservedIndices(); | 412 void finalizeReservedIndices(); |
| 399 | 413 |
| 400 SkAutoTDelete<GrPathRendering> fPathRendering; | 414 SkAutoTDelete<GrPathRendering> fPathRendering; |
| 401 | 415 |
| 402 private: | 416 private: |
| 403 // GrDrawTarget overrides | 417 // GrDrawTarget overrides |
| 404 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void**
vertices) SK_OVERRIDE; | 418 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void**
vertices) SK_OVERRIDE; |
| 405 virtual bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE
; | 419 virtual bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE
; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 // counts number of uses of vertex/index pool in the geometry stack | 528 // counts number of uses of vertex/index pool in the geometry stack |
| 515 int fVertexP
oolUseCnt; | 529 int fVertexP
oolUseCnt; |
| 516 int fIndexPo
olUseCnt; | 530 int fIndexPo
olUseCnt; |
| 517 // these are mutable so they can be created on-demand | 531 // these are mutable so they can be created on-demand |
| 518 mutable GrIndexBuffer* fQuadInd
exBuffer; | 532 mutable GrIndexBuffer* fQuadInd
exBuffer; |
| 519 | 533 |
| 520 typedef GrDrawTarget INHERITED; | 534 typedef GrDrawTarget INHERITED; |
| 521 }; | 535 }; |
| 522 | 536 |
| 523 #endif | 537 #endif |
| OLD | NEW |