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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 362 |
363 Stats* stats() { return &fStats; } | 363 Stats* stats() { return &fStats; } |
364 | 364 |
365 // creation and deletion of raw texture for testing | 365 // creation and deletion of raw texture for testing |
366 // only to be used in GPU-specific tests | 366 // only to be used in GPU-specific tests |
367 virtual GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w,
int h, | 367 virtual GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w,
int h, |
368 GrPixelConfig config
) const = 0; | 368 GrPixelConfig config
) const = 0; |
369 virtual bool isTestingOnlyBackendTexture(GrBackendObject id) const = 0; | 369 virtual bool isTestingOnlyBackendTexture(GrBackendObject id) const = 0; |
370 virtual void deleteTestingOnlyBackendTexture(GrBackendObject id) const = 0; | 370 virtual void deleteTestingOnlyBackendTexture(GrBackendObject id) const = 0; |
371 | 371 |
372 // Given a rt, find or create a stencil buffer and attach it | 372 // width and height may be larger than rt (if underlying API allows it). |
373 bool attachStencilAttachmentToRenderTarget(GrRenderTarget* target); | 373 // Returns nullptr if compatible sb could not be created, otherwise the call
er owns the ref on |
| 374 // the GrStencilAttachment. |
| 375 virtual GrStencilAttachment* createStencilAttachmentForRenderTarget(const Gr
RenderTarget*, |
| 376 int widt
h, |
| 377 int heig
ht) = 0; |
| 378 // clears target's entire stencil buffer to 0 |
| 379 virtual void clearStencil(GrRenderTarget* target) = 0; |
374 | 380 |
375 // This is only to be used in GL-specific tests. | 381 // This is only to be used in GL-specific tests. |
376 virtual const GrGLContext* glContextForTesting() const { return nullptr; } | 382 virtual const GrGLContext* glContextForTesting() const { return nullptr; } |
377 | 383 |
378 protected: | 384 protected: |
379 // Functions used to map clip-respecting stencil tests into normal | 385 // Functions used to map clip-respecting stencil tests into normal |
380 // stencil funcs supported by GPUs. | 386 // stencil funcs supported by GPUs. |
381 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, | 387 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, |
382 GrStencilFunc func); | 388 GrStencilFunc func); |
383 static void ConvertStencilFuncAndMask(GrStencilFunc func, | 389 static void ConvertStencilFuncAndMask(GrStencilFunc func, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 | 465 |
460 // overridden by backend-specific derived class to perform the resolve | 466 // overridden by backend-specific derived class to perform the resolve |
461 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; | 467 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; |
462 | 468 |
463 // overridden by backend specific derived class to perform the copy surface | 469 // overridden by backend specific derived class to perform the copy surface |
464 virtual bool onCopySurface(GrSurface* dst, | 470 virtual bool onCopySurface(GrSurface* dst, |
465 GrSurface* src, | 471 GrSurface* src, |
466 const SkIRect& srcRect, | 472 const SkIRect& srcRect, |
467 const SkIPoint& dstPoint) = 0; | 473 const SkIPoint& dstPoint) = 0; |
468 | 474 |
469 // width and height may be larger than rt (if underlying API allows it). | |
470 // Should attach the SB to the RT. Returns false if compatible sb could | |
471 // not be created. | |
472 virtual bool createStencilAttachmentForRenderTarget(GrRenderTarget*, int wid
th, int height) = 0; | |
473 | |
474 // attaches an existing SB to an existing RT. | |
475 virtual bool attachStencilAttachmentToRenderTarget(GrStencilAttachment*, GrR
enderTarget*) = 0; | |
476 | |
477 // clears target's entire stencil buffer to 0 | |
478 virtual void clearStencil(GrRenderTarget* target) = 0; | |
479 | |
480 void resetContext() { | 475 void resetContext() { |
481 this->onResetContext(fResetBits); | 476 this->onResetContext(fResetBits); |
482 fResetBits = 0; | 477 fResetBits = 0; |
483 ++fResetTimestamp; | 478 ++fResetTimestamp; |
484 } | 479 } |
485 | 480 |
486 void handleDirtyContext() { | 481 void handleDirtyContext() { |
487 if (fResetBits) { | 482 if (fResetBits) { |
488 this->resetContext(); | 483 this->resetContext(); |
489 } | 484 } |
490 } | 485 } |
491 | 486 |
492 ResetTimestamp fResetTi
mestamp; | 487 ResetTimestamp fResetTi
mestamp; |
493 uint32_t fResetBi
ts; | 488 uint32_t fResetBi
ts; |
494 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 489 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
495 GrContext* fContext
; | 490 GrContext* fContext
; |
496 | 491 |
497 friend class GrPathRendering; | 492 friend class GrPathRendering; |
498 typedef SkRefCnt INHERITED; | 493 typedef SkRefCnt INHERITED; |
499 }; | 494 }; |
500 | 495 |
501 #endif | 496 #endif |
OLD | NEW |