Chromium Code Reviews| 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 a rt, find or create a stencil buffer and attach it |
| 377 bool attachStencilAttachmentToRenderTarget(GrRenderTarget* target); | 377 // bool attachStencilAttachmentToRenderTarget(GrRenderTarget* target); |
| 378 | |
| 379 // Given the input GrRenderTarget, this function sets GrStencilAttachment* e ither | |
| 380 // from a cached stencil attachment or by creating a new one. If the GrStenc ilAttachment* | |
| 381 // that is returned is non-null, the caller will own the ref on the GrStenci lAttachment. | |
| 382 // This function returns true if the returned GrStencilAttachment was newly created in case | |
| 383 // the caller wants to do any special thing with the stencil (e.g. clearning it). | |
| 384 bool getStencilAttachment(const GrRenderTarget*, GrStencilAttachment**); | |
| 385 | |
| 386 // clears target's entire stencil buffer to 0 | |
| 387 virtual void clearStencil(GrRenderTarget* target) = 0; | |
|
egdaniel
2015/09/11 17:59:49
Since we are not letting the RT handle the attachi
| |
| 378 | 388 |
| 379 // This is only to be used in GL-specific tests. | 389 // This is only to be used in GL-specific tests. |
| 380 virtual const GrGLContext* glContextForTesting() const { return nullptr; } | 390 virtual const GrGLContext* glContextForTesting() const { return nullptr; } |
| 381 | 391 |
| 382 protected: | 392 protected: |
| 383 // Functions used to map clip-respecting stencil tests into normal | 393 // Functions used to map clip-respecting stencil tests into normal |
| 384 // stencil funcs supported by GPUs. | 394 // stencil funcs supported by GPUs. |
| 385 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, | 395 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, |
| 386 GrStencilFunc func); | 396 GrStencilFunc func); |
| 387 static void ConvertStencilFuncAndMask(GrStencilFunc func, | 397 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 | 474 // overridden by backend-specific derived class to perform the resolve |
| 465 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; | 475 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; |
| 466 | 476 |
| 467 // overridden by backend specific derived class to perform the copy surface | 477 // overridden by backend specific derived class to perform the copy surface |
| 468 virtual bool onCopySurface(GrSurface* dst, | 478 virtual bool onCopySurface(GrSurface* dst, |
| 469 GrSurface* src, | 479 GrSurface* src, |
| 470 const SkIRect& srcRect, | 480 const SkIRect& srcRect, |
| 471 const SkIPoint& dstPoint) = 0; | 481 const SkIPoint& dstPoint) = 0; |
| 472 | 482 |
| 473 // width and height may be larger than rt (if underlying API allows it). | 483 // 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 | 484 // Returns nullptr if compatible sb could not be created. |
| 475 // not be created. | 485 virtual GrStencilAttachment* createStencilAttachmentForRenderTarget(const Gr RenderTarget*, |
| 476 virtual bool createStencilAttachmentForRenderTarget(GrRenderTarget*, int wid th, int height) = 0; | 486 int widt h, |
| 477 | 487 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 | 488 |
| 484 void resetContext() { | 489 void resetContext() { |
| 485 this->onResetContext(fResetBits); | 490 this->onResetContext(fResetBits); |
| 486 fResetBits = 0; | 491 fResetBits = 0; |
| 487 ++fResetTimestamp; | 492 ++fResetTimestamp; |
| 488 } | 493 } |
| 489 | 494 |
| 490 void handleDirtyContext() { | 495 void handleDirtyContext() { |
| 491 if (fResetBits) { | 496 if (fResetBits) { |
| 492 this->resetContext(); | 497 this->resetContext(); |
| 493 } | 498 } |
| 494 } | 499 } |
| 495 | 500 |
| 496 ResetTimestamp fResetTi mestamp; | 501 ResetTimestamp fResetTi mestamp; |
| 497 uint32_t fResetBi ts; | 502 uint32_t fResetBi ts; |
| 498 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 503 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
| 499 GrContext* fContext ; | 504 GrContext* fContext ; |
| 500 | 505 |
| 501 friend class GrPathRendering; | 506 friend class GrPathRendering; |
| 502 typedef SkRefCnt INHERITED; | 507 typedef SkRefCnt INHERITED; |
| 503 }; | 508 }; |
| 504 | 509 |
| 505 #endif | 510 #endif |
| OLD | NEW |