Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: src/gpu/GrGpu.h

Issue 676983003: Clip mask manager sets stencil on draw type (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: bug fix Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrGpu.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
321 // GrGpu subclass sets clip bit in the stencil buffer. The subclass is 309 // GrGpu subclass sets clip bit in the stencil buffer. The subclass is
322 // free to clear the remaining bits to zero if masked clears are more 310 // free to clear the remaining bits to zero if masked clears are more
323 // expensive than clearing all bits. 311 // expensive than clearing all bits.
324 virtual void clearStencilClip(GrRenderTarget*, const SkIRect& rect, bool ins ideClip) = 0; 312 virtual void clearStencilClip(GrRenderTarget*, const SkIRect& rect, bool ins ideClip) = 0;
325 313
326 enum PrivateDrawStateStateBits { 314 enum PrivateDrawStateStateBits {
327 kFirstBit = (GrDrawState::kLastPublicStateBit << 1), 315 kFirstBit = (GrDrawState::kLastPublicStateBit << 1),
328 316
329 kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify 317 kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify
330 // stencil bits used for 318 // stencil bits used for
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 return kDrawLines_DrawType; 350 return kDrawLines_DrawType;
363 default: 351 default:
364 SkFAIL("Unexpected primitive type"); 352 SkFAIL("Unexpected primitive type");
365 return kDrawTriangles_DrawType; 353 return kDrawTriangles_DrawType;
366 } 354 }
367 } 355 }
368 356
369 // prepares clip flushes gpu state before a draw 357 // prepares clip flushes gpu state before a draw
370 bool setupClipAndFlushState(DrawType, 358 bool setupClipAndFlushState(DrawType,
371 const GrDeviceCoordTexture* dstCopy, 359 const GrDeviceCoordTexture* dstCopy,
372 GrDrawState::AutoRestoreEffects* are, 360 GrDrawState::AutoRestoreEffects*,
373 const SkRect* devBounds); 361 const SkRect* devBounds);
374 362
375 // Functions used to map clip-respecting stencil tests into normal 363 // Functions used to map clip-respecting stencil tests into normal
376 // stencil funcs supported by GPUs. 364 // stencil funcs supported by GPUs.
377 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, 365 static GrStencilFunc ConvertStencilFunc(bool stencilInClip,
378 GrStencilFunc func); 366 GrStencilFunc func);
379 static void ConvertStencilFuncAndMask(GrStencilFunc func, 367 static void ConvertStencilFuncAndMask(GrStencilFunc func,
380 bool clipInStencil, 368 bool clipInStencil,
381 unsigned int clipBit, 369 unsigned int clipBit,
382 unsigned int userBits, 370 unsigned int userBits,
(...skipping 14 matching lines...) Expand all
397 const GeometryPoolState& getGeomPoolState() { 385 const GeometryPoolState& getGeomPoolState() {
398 return fGeomPoolStateStack.back(); 386 return fGeomPoolStateStack.back();
399 } 387 }
400 388
401 // The state of the scissor is controlled by the clip manager 389 // The state of the scissor is controlled by the clip manager
402 struct ScissorState { 390 struct ScissorState {
403 bool fEnabled; 391 bool fEnabled;
404 SkIRect fRect; 392 SkIRect fRect;
405 } fScissorState; 393 } fScissorState;
406 394
407 // The final stencil settings to use as determined by the clip manager.
408 GrStencilSettings fStencilSettings;
409
410 // Helpers for setting up geometry state 395 // Helpers for setting up geometry state
411 void finalizeReservedVertices(); 396 void finalizeReservedVertices();
412 void finalizeReservedIndices(); 397 void finalizeReservedIndices();
413 398
414 SkAutoTDelete<GrPathRendering> fPathRendering; 399 SkAutoTDelete<GrPathRendering> fPathRendering;
415 400
416 private: 401 private:
417 // GrDrawTarget overrides 402 // GrDrawTarget overrides
418 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) SK_OVERRIDE; 403 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) SK_OVERRIDE;
419 virtual bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE ; 404 virtual bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE ;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 // counts number of uses of vertex/index pool in the geometry stack 513 // counts number of uses of vertex/index pool in the geometry stack
529 int fVertexP oolUseCnt; 514 int fVertexP oolUseCnt;
530 int fIndexPo olUseCnt; 515 int fIndexPo olUseCnt;
531 // these are mutable so they can be created on-demand 516 // these are mutable so they can be created on-demand
532 mutable GrIndexBuffer* fQuadInd exBuffer; 517 mutable GrIndexBuffer* fQuadInd exBuffer;
533 518
534 typedef GrDrawTarget INHERITED; 519 typedef GrDrawTarget INHERITED;
535 }; 520 };
536 521
537 #endif 522 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698