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

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

Issue 683673002: clear stencil clip on draw target (Closed) Base URL: https://skia.googlesource.com/skia.git@aa_rect_takes_gpu
Patch Set: rebase 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/GrDrawTarget.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
11 #include "GrDrawTarget.h" 11 #include "GrDrawTarget.h"
12 #include "GrClipMaskManager.h" 12 #include "GrClipMaskManager.h"
13 #include "GrPathRendering.h" 13 #include "GrPathRendering.h"
14 #include "GrProgramDesc.h" 14 #include "GrProgramDesc.h"
15 #include "SkPath.h" 15 #include "SkPath.h"
16 16
17 class GrContext; 17 class GrContext;
18 class GrIndexBufferAllocPool; 18 class GrIndexBufferAllocPool;
19 class GrPath; 19 class GrPath;
20 class GrPathRange; 20 class GrPathRange;
21 class GrPathRenderer; 21 class GrPathRenderer;
22 class GrPathRendererChain; 22 class GrPathRendererChain;
23 class GrStencilBuffer; 23 class GrStencilBuffer;
24 class GrVertexBufferAllocPool; 24 class GrVertexBufferAllocPool;
25 25
26 class GrGpu : public GrDrawTarget { 26 class GrGpu : public GrClipTarget {
27 public: 27 public:
28 28
29 /** 29 /**
30 * Additional blend coefficients for dual source blending, not exposed 30 * Additional blend coefficients for dual source blending, not exposed
31 * through GrPaint/GrContext. 31 * through GrPaint/GrContext.
32 */ 32 */
33 enum ExtendedBlendCoeffs { 33 enum ExtendedBlendCoeffs {
34 // source 2 refers to second output color when 34 // source 2 refers to second output color when
35 // using dual source blending. 35 // using dual source blending.
36 kS2C_GrBlendCoeff = kPublicGrBlendCoeffCount, 36 kS2C_GrBlendCoeff = kPublicGrBlendCoeffCount,
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 int left, int top, int width, int height, 265 int left, int top, int width, int height,
266 GrPixelConfig config, const void* buffer, 266 GrPixelConfig config, const void* buffer,
267 size_t rowBytes); 267 size_t rowBytes);
268 268
269 // GrDrawTarget overrides 269 // GrDrawTarget overrides
270 virtual void clear(const SkIRect* rect, 270 virtual void clear(const SkIRect* rect,
271 GrColor color, 271 GrColor color,
272 bool canIgnoreRect, 272 bool canIgnoreRect,
273 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; 273 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE;
274 274
275 virtual void clearStencilClip(const SkIRect& rect,
276 bool insideClip,
277 GrRenderTarget* renderTarget = NULL) SK_OVERRI DE;
278
275 virtual void purgeResources() SK_OVERRIDE { 279 virtual void purgeResources() SK_OVERRIDE {
276 // The clip mask manager can rebuild all its clip masks so just 280 // The clip mask manager can rebuild all its clip masks so just
277 // get rid of them all. 281 // get rid of them all.
278 fClipMaskManager.purgeResources(); 282 fClipMaskManager.purgeResources();
279 } 283 }
280 284
281 // After the client interacts directly with the 3D context state the GrGpu 285 // After the client interacts directly with the 3D context state the GrGpu
282 // must resync its internal state and assumptions about 3D context state. 286 // must resync its internal state and assumptions about 3D context state.
283 // Each time this occurs the GrGpu bumps a timestamp. 287 // Each time this occurs the GrGpu bumps a timestamp.
284 // state of the 3D context 288 // state of the 3D context
285 // At 10 resets / frame and 60fps a 64bit timestamp will overflow in about 289 // At 10 resets / frame and 60fps a 64bit timestamp will overflow in about
286 // a billion years. 290 // a billion years.
287 typedef uint64_t ResetTimestamp; 291 typedef uint64_t ResetTimestamp;
288 292
289 // This timestamp is always older than the current timestamp 293 // This timestamp is always older than the current timestamp
290 static const ResetTimestamp kExpiredTimestamp = 0; 294 static const ResetTimestamp kExpiredTimestamp = 0;
291 // Returns a timestamp based on the number of times the context was reset. 295 // Returns a timestamp based on the number of times the context was reset.
292 // This timestamp can be used to lazily detect when cached 3D context state 296 // This timestamp can be used to lazily detect when cached 3D context state
293 // is dirty. 297 // is dirty.
294 ResetTimestamp getResetTimestamp() const { 298 ResetTimestamp getResetTimestamp() const {
295 return fResetTimestamp; 299 return fResetTimestamp;
296 } 300 }
297 301
298 // GrGpu subclass sets clip bit in the stencil buffer. The subclass is
299 // free to clear the remaining bits to zero if masked clears are more
300 // expensive than clearing all bits.
301 virtual void clearStencilClip(GrRenderTarget*, const SkIRect& rect, bool ins ideClip) = 0;
302
303 enum PrivateDrawStateStateBits { 302 enum PrivateDrawStateStateBits {
304 kFirstBit = (GrDrawState::kLastPublicStateBit << 1), 303 kFirstBit = (GrDrawState::kLastPublicStateBit << 1),
305 304
306 kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify 305 kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify
307 // stencil bits used for 306 // stencil bits used for
308 // clipping. 307 // clipping.
309 }; 308 };
310 309
311 void getPathStencilSettingsForFillType(SkPath::FillType fill, GrStencilSetti ngs* outStencilSettings); 310 void getPathStencilSettingsForFillType(SkPath::FillType fill, GrStencilSetti ngs* outStencilSettings);
312 311
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge tDesc&) = 0; 414 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge tDesc&) = 0;
416 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; 415 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0;
417 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; 416 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0;
418 417
419 // overridden by backend-specific derived class to perform the clear and 418 // overridden by backend-specific derived class to perform the clear and
420 // clearRect. NULL rect means clear whole target. If canIgnoreRect is 419 // clearRect. NULL rect means clear whole target. If canIgnoreRect is
421 // true, it is okay to perform a full clear instead of a partial clear 420 // true, it is okay to perform a full clear instead of a partial clear
422 virtual void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, 421 virtual void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color,
423 bool canIgnoreRect) = 0; 422 bool canIgnoreRect) = 0;
424 423
424
425 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is
426 // ONLY used by the the clip target
427 virtual void onClearStencilClip(GrRenderTarget*,
428 const SkIRect& rect,
429 bool insideClip) = 0;
430
425 // overridden by backend-specific derived class to perform the draw call. 431 // overridden by backend-specific derived class to perform the draw call.
426 virtual void onGpuDraw(const DrawInfo&) = 0; 432 virtual void onGpuDraw(const DrawInfo&) = 0;
427 433
428 // overridden by backend-specific derived class to perform the read pixels. 434 // overridden by backend-specific derived class to perform the read pixels.
429 virtual bool onReadPixels(GrRenderTarget* target, 435 virtual bool onReadPixels(GrRenderTarget* target,
430 int left, int top, int width, int height, 436 int left, int top, int width, int height,
431 GrPixelConfig, 437 GrPixelConfig,
432 void* buffer, 438 void* buffer,
433 size_t rowBytes) = 0; 439 size_t rowBytes) = 0;
434 440
(...skipping 12 matching lines...) Expand all
447 virtual bool createStencilBufferForRenderTarget(GrRenderTarget*, int width, int height) = 0; 453 virtual bool createStencilBufferForRenderTarget(GrRenderTarget*, int width, int height) = 0;
448 454
449 // attaches an existing SB to an existing RT. 455 // attaches an existing SB to an existing RT.
450 virtual bool attachStencilBufferToRenderTarget(GrStencilBuffer*, GrRenderTar get*) = 0; 456 virtual bool attachStencilBufferToRenderTarget(GrStencilBuffer*, GrRenderTar get*) = 0;
451 457
452 // The GrGpu typically records the clients requested state and then flushes 458 // The GrGpu typically records the clients requested state and then flushes
453 // deltas from previous state at draw time. This function does the 459 // deltas from previous state at draw time. This function does the
454 // backend-specific flush of the state. 460 // backend-specific flush of the state.
455 // returns false if current state is unsupported. 461 // returns false if current state is unsupported.
456 virtual bool flushGraphicsState(DrawType, 462 virtual bool flushGraphicsState(DrawType,
457 const ScissorState&, 463 const GrClipMaskManager::ScissorState&,
458 const GrDeviceCoordTexture* dstCopy) = 0; 464 const GrDeviceCoordTexture* dstCopy) = 0;
459 465
460 // clears target's entire stencil buffer to 0 466 // clears target's entire stencil buffer to 0
461 virtual void clearStencil(GrRenderTarget* target) = 0; 467 virtual void clearStencil(GrRenderTarget* target) = 0;
462 468
463 // Given a rt, find or create a stencil buffer and attach it 469 // Given a rt, find or create a stencil buffer and attach it
464 bool attachStencilBufferToRenderTarget(GrRenderTarget* target); 470 bool attachStencilBufferToRenderTarget(GrRenderTarget* target);
465 471
466 // GrDrawTarget overrides 472 // GrDrawTarget overrides
467 virtual void onDraw(const DrawInfo&) SK_OVERRIDE; 473 virtual void onDraw(const DrawInfo&) SK_OVERRIDE;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 ResetTimestamp fResetTi mestamp; 506 ResetTimestamp fResetTi mestamp;
501 uint32_t fResetBi ts; 507 uint32_t fResetBi ts;
502 GrVertexBufferAllocPool* fVertexP ool; 508 GrVertexBufferAllocPool* fVertexP ool;
503 GrIndexBufferAllocPool* fIndexPo ol; 509 GrIndexBufferAllocPool* fIndexPo ol;
504 // counts number of uses of vertex/index pool in the geometry stack 510 // counts number of uses of vertex/index pool in the geometry stack
505 int fVertexP oolUseCnt; 511 int fVertexP oolUseCnt;
506 int fIndexPo olUseCnt; 512 int fIndexPo olUseCnt;
507 // these are mutable so they can be created on-demand 513 // these are mutable so they can be created on-demand
508 mutable GrIndexBuffer* fQuadInd exBuffer; 514 mutable GrIndexBuffer* fQuadInd exBuffer;
509 515
510 typedef GrDrawTarget INHERITED; 516 typedef GrClipTarget INHERITED;
511 }; 517 };
512 518
513 #endif 519 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698