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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 | 366 |
367 Stats* stats() { return &fStats; } | 367 Stats* stats() { return &fStats; } |
368 | 368 |
369 // creation and deletion of raw texture for testing | 369 // creation and deletion of raw texture for testing |
370 // only to be used in GPU-specific tests | 370 // only to be used in GPU-specific tests |
371 virtual GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w,
int h, | 371 virtual GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w,
int h, |
372 GrPixelConfig config
) const = 0; | 372 GrPixelConfig config
) const = 0; |
373 virtual bool isTestingOnlyBackendTexture(GrBackendObject id) const = 0; | 373 virtual bool isTestingOnlyBackendTexture(GrBackendObject id) const = 0; |
374 virtual void deleteTestingOnlyBackendTexture(GrBackendObject id) const = 0; | 374 virtual void deleteTestingOnlyBackendTexture(GrBackendObject id) const = 0; |
375 | 375 |
376 // Given a rt, find or create a stencil buffer and attach it | 376 // Given the input GrRenderTarget, this function sets GrStencilAttachment* e
ither |
377 bool attachStencilAttachmentToRenderTarget(GrRenderTarget* target); | 377 // from a cached stencil attachment or by creating a new one. If the GrStenc
ilAttachment* |
| 378 // that is returned is non-null, the caller will own the ref on the GrStenci
lAttachment. |
| 379 // This function returns true if the returned GrStencilAttachment was newly
created in case |
| 380 // the caller wants to do any special thing with the stencil (e.g. clearning
it). |
| 381 bool getStencilAttachment(const GrRenderTarget*, GrStencilAttachment**); |
| 382 |
| 383 // clears target's entire stencil buffer to 0 |
| 384 virtual void clearStencil(GrRenderTarget* target) = 0; |
378 | 385 |
379 // This is only to be used in GL-specific tests. | 386 // This is only to be used in GL-specific tests. |
380 virtual const GrGLContext* glContextForTesting() const { return nullptr; } | 387 virtual const GrGLContext* glContextForTesting() const { return nullptr; } |
381 | 388 |
382 protected: | 389 protected: |
383 // Functions used to map clip-respecting stencil tests into normal | 390 // Functions used to map clip-respecting stencil tests into normal |
384 // stencil funcs supported by GPUs. | 391 // stencil funcs supported by GPUs. |
385 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, | 392 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, |
386 GrStencilFunc func); | 393 GrStencilFunc func); |
387 static void ConvertStencilFuncAndMask(GrStencilFunc func, | 394 static void ConvertStencilFuncAndMask(GrStencilFunc func, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 // overridden by backend-specific derived class to perform the resolve | 471 // overridden by backend-specific derived class to perform the resolve |
465 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; | 472 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; |
466 | 473 |
467 // overridden by backend specific derived class to perform the copy surface | 474 // overridden by backend specific derived class to perform the copy surface |
468 virtual bool onCopySurface(GrSurface* dst, | 475 virtual bool onCopySurface(GrSurface* dst, |
469 GrSurface* src, | 476 GrSurface* src, |
470 const SkIRect& srcRect, | 477 const SkIRect& srcRect, |
471 const SkIPoint& dstPoint) = 0; | 478 const SkIPoint& dstPoint) = 0; |
472 | 479 |
473 // width and height may be larger than rt (if underlying API allows it). | 480 // width and height may be larger than rt (if underlying API allows it). |
474 // Should attach the SB to the RT. Returns false if compatible sb could | 481 // Returns nullptr if compatible sb could not be created. |
475 // not be created. | 482 virtual GrStencilAttachment* createStencilAttachmentForRenderTarget(const Gr
RenderTarget*, |
476 virtual bool createStencilAttachmentForRenderTarget(GrRenderTarget*, int wid
th, int height) = 0; | 483 int widt
h, |
477 | 484 int heig
ht) = 0; |
478 // attaches an existing SB to an existing RT. | |
479 virtual bool attachStencilAttachmentToRenderTarget(GrStencilAttachment*, GrR
enderTarget*) = 0; | |
480 | |
481 // clears target's entire stencil buffer to 0 | |
482 virtual void clearStencil(GrRenderTarget* target) = 0; | |
483 | 485 |
484 void resetContext() { | 486 void resetContext() { |
485 this->onResetContext(fResetBits); | 487 this->onResetContext(fResetBits); |
486 fResetBits = 0; | 488 fResetBits = 0; |
487 ++fResetTimestamp; | 489 ++fResetTimestamp; |
488 } | 490 } |
489 | 491 |
490 void handleDirtyContext() { | 492 void handleDirtyContext() { |
491 if (fResetBits) { | 493 if (fResetBits) { |
492 this->resetContext(); | 494 this->resetContext(); |
493 } | 495 } |
494 } | 496 } |
495 | 497 |
496 ResetTimestamp fResetTi
mestamp; | 498 ResetTimestamp fResetTi
mestamp; |
497 uint32_t fResetBi
ts; | 499 uint32_t fResetBi
ts; |
498 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 500 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
499 GrContext* fContext
; | 501 GrContext* fContext
; |
500 | 502 |
501 friend class GrPathRendering; | 503 friend class GrPathRendering; |
502 typedef SkRefCnt INHERITED; | 504 typedef SkRefCnt INHERITED; |
503 }; | 505 }; |
504 | 506 |
505 #endif | 507 #endif |
OLD | NEW |