Chromium Code Reviews| Index: include/gpu/GrRenderTarget.h |
| diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h |
| index 5984bf71d8b514c10c44e2f40f7ba214bf56c738..dabc38d94ee4f988d26e1e628ecf124f5e46738f 100644 |
| --- a/include/gpu/GrRenderTarget.h |
| +++ b/include/gpu/GrRenderTarget.h |
| @@ -31,14 +31,65 @@ public: |
| // GrRenderTarget |
| /** |
| - * @return true if the surface is multisampled, false otherwise |
| + * On some hardware it is possible for a render target to have multisampling |
| + * only in certain buffers. |
| + * Enforce only two legal sample configs. |
| + * kUnified_SampleConfig signifies multisampling in both color and stencil |
| + * buffers and is available across all hardware. |
| + * kStencil_SampleConfig means multisampling is present in stencil buffer |
| + * only; this config requires hardware support of |
| + * NV_framebuffer_mixed_samples. |
| + */ |
| + enum SampleConfig { |
| + kUnified_SampleConfig = 0, |
| + kStencil_SampleConfig = 1 |
| + }; |
| + |
| + /** |
| + * @return true if the surface is multisampled in all buffers, |
|
bsalomon
2015/06/10 19:57:06
Can we come up with a more clear name for this?
i
|
| + * false otherwise |
| + */ |
| + bool isMultisampled() const { |
| + if (fSampleConfig != kUnified_SampleConfig) { |
| + return false; |
| + } |
| + return 0 != fDesc.fSampleCnt; |
| + } |
| + |
| + /** |
| + * @return true if the surface is multisampled in the stencil buffer, |
| + * false otherwise |
| + */ |
| + bool isStencilBufferMultisampled() const { |
| + return 0 != fDesc.fSampleCnt; |
| + } |
| + |
| + /** |
| + * @return the number of color samples-per-pixel, or zero if non-MSAA or |
| + * multisampled in the stencil buffer only. |
| */ |
| - bool isMultisampled() const { return 0 != fDesc.fSampleCnt; } |
| + int numColorSamples() const { |
| + if (fSampleConfig == kUnified_SampleConfig) { |
| + return fDesc.fSampleCnt; |
| + } |
| + return 0; |
| + } |
| /** |
| - * @return the number of samples-per-pixel or zero if non-MSAA. |
| + * @return the number of stencil samples-per-pixel, or zero if non-MSAA. |
| */ |
| - int numSamples() const { return fDesc.fSampleCnt; } |
| + int numStencilSamples() const { |
| + return fDesc.fSampleCnt; |
| + } |
| + |
| + /** |
| + * @return sample config: kUnified_SampleConfig if both color and stencil |
| + buffers are MSAA, or kStencil_SampleConfig if only stencil |
| + buffer is MSAA. |
| + */ |
| + SampleConfig sampleConfig() const { |
| + return fSampleConfig; |
|
Chris Dalton
2015/06/11 00:02:29
Maybe change this to:
bool hasMixedSamples() co
|
| + } |
| /** |
| * Call to indicate the multisample contents were modified such that the |
| @@ -94,9 +145,11 @@ public: |
| const GrRenderTargetPriv renderTargetPriv() const; |
| protected: |
| - GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc) |
| + GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc, |
| + SampleConfig sampleConfig) |
| : INHERITED(gpu, lifeCycle, desc) |
| - , fStencilAttachment(NULL) { |
| + , fStencilAttachment(NULL) |
| + , fSampleConfig(sampleConfig) { |
| fResolveRect.setLargestInverted(); |
| } |
| @@ -111,10 +164,12 @@ private: |
| friend class GrRenderTargetPriv; |
| GrStencilAttachment* fStencilAttachment; |
| + SampleConfig fSampleConfig; |
| SkIRect fResolveRect; |
| typedef GrSurface INHERITED; |
| }; |
| + |
| #endif |