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

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: Created 6 years, 2 months 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
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*,
361 GrDrawState::AutoRestoreStencil*,
373 const SkRect* devBounds); 362 const SkRect* devBounds);
374 363
375 // Functions used to map clip-respecting stencil tests into normal 364 // Functions used to map clip-respecting stencil tests into normal
376 // stencil funcs supported by GPUs. 365 // stencil funcs supported by GPUs.
377 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, 366 static GrStencilFunc ConvertStencilFunc(bool stencilInClip,
378 GrStencilFunc func); 367 GrStencilFunc func);
379 static void ConvertStencilFuncAndMask(GrStencilFunc func, 368 static void ConvertStencilFuncAndMask(GrStencilFunc func,
380 bool clipInStencil, 369 bool clipInStencil,
381 unsigned int clipBit, 370 unsigned int clipBit,
382 unsigned int userBits, 371 unsigned int userBits,
(...skipping 14 matching lines...) Expand all
397 const GeometryPoolState& getGeomPoolState() { 386 const GeometryPoolState& getGeomPoolState() {
398 return fGeomPoolStateStack.back(); 387 return fGeomPoolStateStack.back();
399 } 388 }
400 389
401 // The state of the scissor is controlled by the clip manager 390 // The state of the scissor is controlled by the clip manager
402 struct ScissorState { 391 struct ScissorState {
403 bool fEnabled; 392 bool fEnabled;
404 SkIRect fRect; 393 SkIRect fRect;
405 } fScissorState; 394 } fScissorState;
406 395
407 // The final stencil settings to use as determined by the clip manager.
408 GrStencilSettings fStencilSettings;
409
410 // Helpers for setting up geometry state 396 // Helpers for setting up geometry state
411 void finalizeReservedVertices(); 397 void finalizeReservedVertices();
412 void finalizeReservedIndices(); 398 void finalizeReservedIndices();
413 399
414 SkAutoTDelete<GrPathRendering> fPathRendering; 400 SkAutoTDelete<GrPathRendering> fPathRendering;
415 401
416 private: 402 private:
417 // GrDrawTarget overrides 403 // GrDrawTarget overrides
418 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) SK_OVERRIDE; 404 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) SK_OVERRIDE;
419 virtual bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE ; 405 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 514 // counts number of uses of vertex/index pool in the geometry stack
529 int fVertexP oolUseCnt; 515 int fVertexP oolUseCnt;
530 int fIndexPo olUseCnt; 516 int fIndexPo olUseCnt;
531 // these are mutable so they can be created on-demand 517 // these are mutable so they can be created on-demand
532 mutable GrIndexBuffer* fQuadInd exBuffer; 518 mutable GrIndexBuffer* fQuadInd exBuffer;
533 519
534 typedef GrDrawTarget INHERITED; 520 typedef GrDrawTarget INHERITED;
535 }; 521 };
536 522
537 #endif 523 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698