aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-02-02 20:32:49 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-03 01:59:59 +0000
commitbdecacfbe47bc7211336bb847bb33c00ef85ea3e (patch)
treefdaac47f9254d9a8e3de61604b899eae8cb718ff /include
parent816acee9be62d9de323ff5144017451e443b3329 (diff)
Revert "Revert "Revert "Revert "Revert "Revert "Redefine the meaning of sample counts in GPU backend.""""""
This reverts commit 3a2cc2c2ec124de36d2544b2a523ef1dd317ca32. Fix code with samplecnt=0 that slipped in between trybots/CQ and landing of previous version Change-Id: Iab19f2e8d1e9901601c8c76244d7a88c5d707fab Reviewed-on: https://skia-review.googlesource.com/103181 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/core/SkSurface.h10
-rw-r--r--include/gpu/GrCaps.h33
-rw-r--r--include/gpu/GrContext.h24
-rw-r--r--include/gpu/GrRenderTarget.h11
-rw-r--r--include/gpu/GrTypes.h19
-rw-r--r--include/gpu/mock/GrMockTypes.h7
-rw-r--r--include/private/GrRenderTargetProxy.h8
7 files changed, 77 insertions, 35 deletions
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index 1f2c4b7f07..d621fdf062 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -90,7 +90,7 @@ public:
/**
* Used to wrap a pre-existing backend 3D API texture as a SkSurface. Skia will not assume
* ownership of the texture and the client must ensure the texture is valid for the lifetime
- * of the SkSurface. If sampleCnt > 0, then we will create an intermediate mssa surface which
+ * of the SkSurface. If sampleCnt > 1, then we will create an intermediate mssa surface which
* we will use for rendering. We then resolve into the passed in texture.
*/
static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* context,
@@ -102,13 +102,13 @@ public:
/**
* Used to wrap a pre-existing backend 3D API texture as a SkSurface. Skia will not assume
* ownership of the texture and the client must ensure the texture is valid for the lifetime
- * of the SkSurface. If sampleCnt > 0, then we will create an intermediate mssa surface which
+ * of the SkSurface. If sampleCnt > 1, then we will create an intermediate mssa surface which
* we will use for rendering. We then resolve into the passed in texture.
*
* The GrBackendTexture must have a valid backend format supplied (GrGLTextureInfo::fFormat,
* GrVkImageInfo::fFormat, etc.) in it. The passed in SkColorType informs skia how it should
* interpret the backend format supplied by the GrBackendTexture. If the format in the
- * GrBackendTexture is not compitable with the sampleCnt, SkColorType, and SkColorSpace we
+ * GrBackendTexture is not compatible with the sampleCnt, SkColorType, and SkColorSpace we
* will return nullptr.
*/
static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* context,
@@ -128,7 +128,7 @@ public:
* The GrBackendRenderTarget must have a valid backend format set (GrGLTextureInfo::fFormat,
* GrVkImageInfo::fFormat, etc.) in it. The passed in SkColorType informs skia how it should
* interpret the backend format supplied by the GrBackendRenderTarget. If the format in the
- * GrBackendRenderTarget is not compitable with the sampleCnt, SkColorType, and SkColorSpace
+ * GrBackendRenderTarget is not compatible with the sampleCnt, SkColorType, and SkColorSpace
* we will return nullptr.
*/
static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* context,
@@ -162,7 +162,7 @@ public:
* The GrBackendTexture must have a valid backend format supplied (GrGLTextureInfo::fFormat,
* GrVkImageInfo::fFormat, etc.) in it. The passed in SkColorType informs skia how it should
* interpret the backend format supplied by the GrBackendTexture. If the format in the
- * GrBackendTexture is not compitable with the sampleCnt, SkColorType, and SkColorSpace we
+ * GrBackendTexture is not compatible with the sampleCnt, SkColorType, and SkColorSpace we
* will return nullptr.
*/
static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(GrContext* context,
diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h
index f4d6e06280..0f03f162f0 100644
--- a/include/gpu/GrCaps.h
+++ b/include/gpu/GrCaps.h
@@ -134,10 +134,6 @@ public:
int maxRasterSamples() const { return fMaxRasterSamples; }
- // Find a sample count greater than or equal to the requested count which is supported for a
- // color buffer of the given config. If MSAA is not support for the config we will return 0.
- virtual int getSampleCount(int requestedCount, GrPixelConfig config) const = 0;
-
int maxWindowRectangles() const { return fMaxWindowRectangles; }
// A tuned, platform-specific value for the maximum number of analytic fragment processors we
@@ -145,9 +141,32 @@ public:
int maxClipAnalyticFPs() const { return fMaxClipAnalyticFPs; }
virtual bool isConfigTexturable(GrPixelConfig) const = 0;
- virtual bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const = 0;
+
// Returns whether a texture of the given config can be copied to a texture of the same config.
- virtual bool isConfigCopyable(GrPixelConfig config) const = 0;
+ virtual bool isConfigCopyable(GrPixelConfig) const = 0;
+
+ // Returns the maximum supported sample count for a config. 0 means the config is not renderable
+ // 1 means the config is renderable but doesn't support MSAA.
+ virtual int maxRenderTargetSampleCount(GrPixelConfig) const = 0;
+
+ bool isConfigRenderable(GrPixelConfig config) const {
+ return this->maxRenderTargetSampleCount(config) > 0;
+ }
+
+ // TODO: Remove this after Flutter updated to no longer use it.
+ bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const {
+ return this->maxRenderTargetSampleCount(config) > (withMSAA ? 1 : 0);
+ }
+
+ // Find a sample count greater than or equal to the requested count which is supported for a
+ // color buffer of the given config or 0 if no such sample count is supported. If the requested
+ // sample count is 1 then 1 will be returned if non-MSAA rendering is supported, otherwise 0.
+ // For historical reasons requestedCount==0 is handled identically to requestedCount==1.
+ virtual int getRenderTargetSampleCount(int requestedCount, GrPixelConfig) const = 0;
+ // TODO: Remove. Legacy name used by Chrome.
+ int getSampleCount(int requestedCount, GrPixelConfig config) const {
+ return this->getRenderTargetSampleCount(requestedCount, config);
+ }
bool suppressPrints() const { return fSuppressPrints; }
@@ -178,6 +197,8 @@ public:
virtual bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
bool* rectsMustMatch, bool* disallowSubrect) const = 0;
+ bool validateSurfaceDesc(const GrSurfaceDesc&, GrMipMapped) const;
+
/**
* Returns true if the GrBackendTexutre can we used with the supplied SkColorType. If it is
* compatible, the passed in GrPixelConfig will be set to a config that matches the backend
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index f85efc4940..d0ca90e0f0 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -216,6 +216,26 @@ public:
/** Access the context capabilities */
const GrCaps* caps() const { return fCaps.get(); }
+ /**
+ * Can a SkImage be created with the given color type.
+ */
+ bool colorTypeSupportedAsImage(SkColorType) const;
+
+ /**
+ * Can a SkSurface be created with the given color type. To check whether MSAA is supported
+ * use maxSurfaceSampleCountForColorType().
+ */
+ bool colorTypeSupportedAsSurface(SkColorType colorType) const {
+ return this->maxSurfaceSampleCountForColorType(colorType) > 0;
+ }
+
+ /**
+ * Gets the maximum supported sample count for a color type. 1 is returned if only non-MSAA
+ * rendering is supported for the color type. 0 is returned if rendering to this color type
+ * is not supported at all.
+ */
+ int maxSurfaceSampleCountForColorType(SkColorType) const;
+
/*
* Create a new render target context backed by a deferred-style
* GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
@@ -226,7 +246,7 @@ public:
int width, int height,
GrPixelConfig config,
sk_sp<SkColorSpace> colorSpace,
- int sampleCnt = 0,
+ int sampleCnt = 1,
GrMipMapped = GrMipMapped::kNo,
GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
const SkSurfaceProps* surfaceProps = nullptr,
@@ -242,7 +262,7 @@ public:
int width, int height,
GrPixelConfig config,
sk_sp<SkColorSpace> colorSpace,
- int sampleCnt = 0,
+ int sampleCnt = 1,
GrMipMapped = GrMipMapped::kNo,
GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
const SkSurfaceProps* surfaceProps = nullptr,
diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h
index 4eee7f63ce..0aad636a69 100644
--- a/include/gpu/GrRenderTarget.h
+++ b/include/gpu/GrRenderTarget.h
@@ -33,10 +33,11 @@ public:
const GrRenderTarget* asRenderTarget() const override { return this; }
// GrRenderTarget
- bool isStencilBufferMultisampled() const { return fSampleCnt > 0; }
+ bool isStencilBufferMultisampled() const { return fSampleCnt > 1; }
GrFSAAType fsaaType() const {
- if (!fSampleCnt) {
+ SkASSERT(fSampleCnt >= 1);
+ if (fSampleCnt <= 1) {
SkASSERT(!(fFlags & GrRenderTargetFlags::kMixedSampled));
return GrFSAAType::kNone;
}
@@ -45,15 +46,15 @@ public:
}
/**
- * Returns the number of samples/pixel in the stencil buffer (Zero if non-MSAA).
+ * Returns the number of samples/pixel in the stencil buffer (One if non-MSAA).
*/
int numStencilSamples() const { return fSampleCnt; }
/**
- * Returns the number of samples/pixel in the color buffer (Zero if non-MSAA or mixed sampled).
+ * Returns the number of samples/pixel in the color buffer (One if non-MSAA or mixed sampled).
*/
int numColorSamples() const {
- return GrFSAAType::kMixedSamples == this->fsaaType() ? 0 : fSampleCnt;
+ return GrFSAAType::kMixedSamples == this->fsaaType() ? 1 : fSampleCnt;
}
/**
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index 3081543aac..ab21fba732 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -402,13 +402,12 @@ struct GrMipLevel {
*/
struct GrSurfaceDesc {
GrSurfaceDesc()
- : fFlags(kNone_GrSurfaceFlags)
- , fOrigin(kTopLeft_GrSurfaceOrigin)
- , fWidth(0)
- , fHeight(0)
- , fConfig(kUnknown_GrPixelConfig)
- , fSampleCnt(0) {
- }
+ : fFlags(kNone_GrSurfaceFlags)
+ , fOrigin(kTopLeft_GrSurfaceOrigin)
+ , fWidth(0)
+ , fHeight(0)
+ , fConfig(kUnknown_GrPixelConfig)
+ , fSampleCnt(1) {}
GrSurfaceFlags fFlags; //!< bitfield of TextureFlags
GrSurfaceOrigin fOrigin; //!< origin of the texture
@@ -422,11 +421,11 @@ struct GrSurfaceDesc {
GrPixelConfig fConfig;
/**
- * The number of samples per pixel or 0 to disable full scene AA. This only
+ * The number of samples per pixel. Zero is treated equivalently to 1. This only
* applies if the kRenderTarget_GrSurfaceFlag is set. The actual number
* of samples may not exactly match the request. The request will be rounded
- * up to the next supported sample count, or down if it is larger than the
- * max supported count.
+ * up to the next supported sample count. A value larger than the largest
+ * supported sample count will fail.
*/
int fSampleCnt;
};
diff --git a/include/gpu/mock/GrMockTypes.h b/include/gpu/mock/GrMockTypes.h
index cf30a333f3..0954c5eadc 100644
--- a/include/gpu/mock/GrMockTypes.h
+++ b/include/gpu/mock/GrMockTypes.h
@@ -22,8 +22,9 @@ struct GrMockTextureInfo {
*/
struct GrMockOptions {
GrMockOptions() {
+ using Renderability = ConfigOptions::Renderability;
// By default RGBA_8888 is textureable and renderable and A8 and RGB565 are texturable.
- fConfigOptions[kRGBA_8888_GrPixelConfig].fRenderable[0] = true;
+ fConfigOptions[kRGBA_8888_GrPixelConfig].fRenderability = Renderability::kNonMSAA;
fConfigOptions[kRGBA_8888_GrPixelConfig].fTexturable = true;
fConfigOptions[kAlpha_8_GrPixelConfig].fTexturable = true;
fConfigOptions[kAlpha_8_as_Alpha_GrPixelConfig].fTexturable = true;
@@ -32,8 +33,8 @@ struct GrMockOptions {
}
struct ConfigOptions {
- /** The first value is for non-MSAA rendering, the second for MSAA. */
- bool fRenderable[2] = {false, false};
+ enum Renderability { kNo, kNonMSAA, kMSAA };
+ Renderability fRenderability;
bool fTexturable = false;
};
diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h
index 1cd3d5d1a2..efe282318f 100644
--- a/include/private/GrRenderTargetProxy.h
+++ b/include/private/GrRenderTargetProxy.h
@@ -26,7 +26,7 @@ public:
bool instantiate(GrResourceProvider*) override;
GrFSAAType fsaaType() const {
- if (!fSampleCnt) {
+ if (fSampleCnt <= 1) {
SkASSERT(!(fRenderTargetFlags & GrRenderTargetFlags::kMixedSampled));
return GrFSAAType::kNone;
}
@@ -42,15 +42,15 @@ public:
bool needsStencil() const { return fNeedsStencil; }
/**
- * Returns the number of samples/pixel in the stencil buffer (Zero if non-MSAA).
+ * Returns the number of samples/pixel in the stencil buffer (One if non-MSAA).
*/
int numStencilSamples() const { return fSampleCnt; }
/**
- * Returns the number of samples/pixel in the color buffer (Zero if non-MSAA or mixed sampled).
+ * Returns the number of samples/pixel in the color buffer (One if non-MSAA or mixed sampled).
*/
int numColorSamples() const {
- return GrFSAAType::kMixedSamples == this->fsaaType() ? 0 : fSampleCnt;
+ return GrFSAAType::kMixedSamples == this->fsaaType() ? 1 : fSampleCnt;
}
int maxWindowRectangles(const GrCaps& caps) const;