Chromium Code Reviews| Index: include/gpu/GrRenderTarget.h |
| diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h |
| index ae420cea6c3aaa9e7c98c23af7185221dc5985b4..be16c59095df810c3cf16ab3c68e3402212922e3 100644 |
| --- a/include/gpu/GrRenderTarget.h |
| +++ b/include/gpu/GrRenderTarget.h |
| @@ -31,14 +31,60 @@ 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. This enum allows the caller to query about |
| + * specific buffers in isMultisampled() and numSamples(). |
| */ |
| - bool isMultisampled() const { return 0 != fDesc.fSampleCnt; } |
| + enum BufferBits { |
| + kAny_BufferBits = 0, |
| + kColor_BufferBit = 1, |
| + kStencil_BufferBit = (1 << 1), |
| + kAll_BufferBits = kColor_BufferBit + kStencil_BufferBit |
| + }; |
| + |
| + /** |
| + * 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 = kColor_BufferBit + kStencil_BufferBit, |
| + kStencil_SampleConfig = kStencil_BufferBit |
| + }; |
| /** |
| - * @return the number of samples-per-pixel or zero if non-MSAA. |
| + * @param buffers specifies the buffers for which multisampling is queried |
| + * @return true if the surface is multisampled in the specified buffer(s), |
|
Chris Dalton
2015/04/07 23:48:23
Nit picking, but this is maybe ambiguous. How abou
vbuzinov
2015/04/08 12:05:30
Done.
|
| + * false otherwise |
| */ |
| - int numSamples() const { return fDesc.fSampleCnt; } |
| + bool isMultisampled(BufferBits buffers = kAll_BufferBits) const { |
| + if (buffers != (fSampleConfig & buffers)) { |
| + // One of the buffers is not in our msaa config. |
| + return false; |
| + } |
| + return 0 != fDesc.fSampleCnt; |
| + } |
| + |
| + /** |
| + * @param buffers specifies the buffers for which multisampling is queried |
| + * @return the number of samples-per-pixel, or zero if the render target |
| + * is not multisampled in the specified buffer(s) |
|
Chris Dalton
2015/04/07 23:48:23
Here too:
"@return the number of samples-per-pixe
vbuzinov
2015/04/08 12:05:30
Done.
|
| + */ |
| + int numSamples(BufferBits buffers = kAll_BufferBits) const { |
| + return this->isMultisampled(buffers) ? fDesc.fSampleCnt : 0; |
| + } |
| + |
| + /** |
| + * @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; |
| + } |
| /** |
| * Call to indicate the multisample contents were modified such that the |
| @@ -94,8 +140,10 @@ 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) |
| + , fSampleConfig(sampleConfig) |
| , fStencilBuffer(NULL) { |
| fResolveRect.setLargestInverted(); |
| } |
| @@ -110,6 +158,8 @@ private: |
| friend class GrRenderTargetPriv; |
| + SampleConfig fSampleConfig; |
| + |
| GrStencilBuffer* fStencilBuffer; |
| SkIRect fResolveRect; |
| @@ -117,4 +167,6 @@ private: |
| typedef GrSurface INHERITED; |
| }; |
| +GR_MAKE_BITFIELD_OPS(GrRenderTarget::BufferBits) |
| + |
| #endif |