diff options
author | csmartdalton <csmartdalton@google.com> | 2016-08-10 11:09:07 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-10 11:09:07 -0700 |
commit | f9635999a4aa8810d04e8ef04594a9fbcc061e3d (patch) | |
tree | 07e43ef173ca41adc6ceec7ade2f1dd2669cfbf6 /include/gpu/GrRenderTarget.h | |
parent | 4ab47e087ecfc82f070cbbaef4d9eb562d3fd163 (diff) |
Add flag for window rectangles to GrRenderTarget
Adds a flag to GrRenderTarget that indicates whether it can be used
with window rectangles. Also attempts to clean up some of the mixed
samples API.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2225303002
Review-Url: https://codereview.chromium.org/2225303002
Diffstat (limited to 'include/gpu/GrRenderTarget.h')
-rw-r--r-- | include/gpu/GrRenderTarget.h | 81 |
1 files changed, 21 insertions, 60 deletions
diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h index 77b04d24d3..1f87787d45 100644 --- a/include/gpu/GrRenderTarget.h +++ b/include/gpu/GrRenderTarget.h @@ -30,66 +30,28 @@ public: const GrRenderTarget* asRenderTarget() const override { return this; } // GrRenderTarget - /** - * 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, - * false otherwise - */ - bool isUnifiedMultisampled() const { - if (fSampleConfig != kUnified_SampleConfig) { - return false; - } - return 0 != fDesc.fSampleCnt; - } + bool isStencilBufferMultisampled() const { return fDesc.fSampleCnt > 0; } /** - * @return true if the surface is multisampled in the stencil buffer, - * false otherwise + * For our purposes, "Mixed Sampled" means the stencil buffer is multisampled but the color + * buffer is not. */ - bool isStencilBufferMultisampled() const { - return 0 != fDesc.fSampleCnt; - } + bool isMixedSampled() const { return fFlags & Flags::kMixedSampled; } /** - * @return the number of color samples-per-pixel, or zero if non-MSAA or - * multisampled in the stencil buffer only. + * "Unified Sampled" means the stencil and color buffers are both multisampled. */ - int numColorSamples() const { - if (fSampleConfig == kUnified_SampleConfig) { - return fDesc.fSampleCnt; - } - return 0; - } + bool isUnifiedMultisampled() const { return fDesc.fSampleCnt > 0 && !this->isMixedSampled(); } /** - * @return the number of stencil samples-per-pixel, or zero if non-MSAA. + * Returns the number of samples/pixel in the stencil buffer (Zero if non-MSAA). */ - int numStencilSamples() const { - return fDesc.fSampleCnt; - } + int numStencilSamples() const { return fDesc.fSampleCnt; } /** - * @return true if the surface is mixed sampled, false otherwise. + * Returns the number of samples/pixel in the color buffer (Zero if non-MSAA or mixed sampled). */ - bool hasMixedSamples() const { - SkASSERT(kStencil_SampleConfig != fSampleConfig || - this->isStencilBufferMultisampled()); - return kStencil_SampleConfig == fSampleConfig; - } + int numColorSamples() const { return this->isMixedSampled() ? 0 : fDesc.fSampleCnt; } /** * Call to indicate the multisample contents were modified such that the @@ -156,19 +118,17 @@ public: void setLastDrawTarget(GrDrawTarget* dt); GrDrawTarget* getLastDrawTarget() { return fLastDrawTarget; } - static SampleConfig ComputeSampleConfig(const GrCaps& caps, int sampleCnt); - protected: - GrRenderTarget(GrGpu* gpu, const GrSurfaceDesc& desc, - SampleConfig sampleConfig, GrStencilAttachment* stencil = nullptr) - : INHERITED(gpu, desc) - , fStencilAttachment(stencil) - , fMultisampleSpecsID(0) - , fSampleConfig(sampleConfig) - , fLastDrawTarget(nullptr) { - fResolveRect.setLargestInverted(); - } + enum class Flags { + kNone = 0, + kMixedSampled = 1 << 0, + kWindowRectsSupport = 1 << 1 + }; + + GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(Flags); + GrRenderTarget(GrGpu*, const GrSurfaceDesc&, Flags = Flags::kNone, + GrStencilAttachment* = nullptr); ~GrRenderTarget() override; // override of GrResource @@ -186,7 +146,7 @@ private: GrStencilAttachment* fStencilAttachment; uint8_t fMultisampleSpecsID; - SampleConfig fSampleConfig; + Flags fFlags; SkIRect fResolveRect; @@ -201,5 +161,6 @@ private: typedef GrSurface INHERITED; }; +GR_MAKE_BITFIELD_CLASS_OPS(GrRenderTarget::Flags); #endif |