Make Mock GrBackendFormat use GrColorType (instead of GrPixelConfig)
The switch to GrColorType does mean that we can no longer represent compressed backend formats in the Mock backend surfaces. This will require a Chrome CL before it can land in Skia. TBR=bsalomon@google.com Change-Id: Ie4e2d4826f960664a21d3de79933eb1cb5d06896 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225538 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
0a7cab0f67
commit
a5e78be278
@ -528,6 +528,7 @@ skia_gpu_sources = [
|
|||||||
"$_src/gpu/mock/GrMockGpuCommandBuffer.h",
|
"$_src/gpu/mock/GrMockGpuCommandBuffer.h",
|
||||||
"$_src/gpu/mock/GrMockStencilAttachment.h",
|
"$_src/gpu/mock/GrMockStencilAttachment.h",
|
||||||
"$_src/gpu/mock/GrMockTexture.h",
|
"$_src/gpu/mock/GrMockTexture.h",
|
||||||
|
"$_src/gpu/mock/GrMockTypes.cpp",
|
||||||
|
|
||||||
# Sk files
|
# Sk files
|
||||||
"$_src/gpu/SkGpuDevice.cpp",
|
"$_src/gpu/SkGpuDevice.cpp",
|
||||||
|
@ -66,8 +66,8 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static GrBackendFormat MakeMock(GrPixelConfig config) {
|
static GrBackendFormat MakeMock(GrColorType colorType, GrSRGBEncoded srgbEncoded) {
|
||||||
return GrBackendFormat(config);
|
return GrBackendFormat(colorType, srgbEncoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const GrBackendFormat& that) const;
|
bool operator==(const GrBackendFormat& that) const;
|
||||||
@ -77,7 +77,7 @@ public:
|
|||||||
GrTextureType textureType() const { return fTextureType; }
|
GrTextureType textureType() const { return fTextureType; }
|
||||||
|
|
||||||
// If the backend API is GL, these return a pointer to the format and target. Otherwise
|
// If the backend API is GL, these return a pointer to the format and target. Otherwise
|
||||||
// it returns nullptr.
|
// they return nullptr.
|
||||||
const GrGLenum* getGLFormat() const;
|
const GrGLenum* getGLFormat() const;
|
||||||
const GrGLenum* getGLTarget() const;
|
const GrGLenum* getGLTarget() const;
|
||||||
|
|
||||||
@ -93,9 +93,10 @@ public:
|
|||||||
const GrMTLPixelFormat* getMtlFormat() const;
|
const GrMTLPixelFormat* getMtlFormat() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// If the backend API is Mock, this returns a pointer to a GrPixelConfig. Otherwise
|
// If the backend API is Mock, these return a pointer to the colorType and srgb encoding.
|
||||||
// it returns nullptr.
|
// Otherwise they return nullptr.
|
||||||
const GrPixelConfig* getMockFormat() const;
|
const GrColorType* getMockColorType() const;
|
||||||
|
const GrSRGBEncoded* getMockSRGBEncoded() const;
|
||||||
|
|
||||||
// If possible, copies the GrBackendFormat and forces the texture type to be Texture2D. If the
|
// If possible, copies the GrBackendFormat and forces the texture type to be Texture2D. If the
|
||||||
// GrBackendFormat was for Vulkan and it originally had a GrVkYcbcrConversionInfo, we will
|
// GrBackendFormat was for Vulkan and it originally had a GrVkYcbcrConversionInfo, we will
|
||||||
@ -114,7 +115,7 @@ private:
|
|||||||
GrBackendFormat(const GrMTLPixelFormat mtlFormat);
|
GrBackendFormat(const GrMTLPixelFormat mtlFormat);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GrBackendFormat(const GrPixelConfig config);
|
GrBackendFormat(GrColorType colorType, GrSRGBEncoded srgbEncoded);
|
||||||
|
|
||||||
GrBackendApi fBackend = GrBackendApi::kMock;
|
GrBackendApi fBackend = GrBackendApi::kMock;
|
||||||
bool fValid = false;
|
bool fValid = false;
|
||||||
@ -128,7 +129,10 @@ private:
|
|||||||
#ifdef SK_METAL
|
#ifdef SK_METAL
|
||||||
GrMTLPixelFormat fMtlFormat;
|
GrMTLPixelFormat fMtlFormat;
|
||||||
#endif
|
#endif
|
||||||
GrPixelConfig fMockFormat;
|
struct {
|
||||||
|
GrColorType fColorType;
|
||||||
|
GrSRGBEncoded fSRGBEncoded;
|
||||||
|
} fMock;
|
||||||
};
|
};
|
||||||
GrTextureType fTextureType = GrTextureType::kNone;
|
GrTextureType fTextureType = GrTextureType::kNone;
|
||||||
};
|
};
|
||||||
|
@ -11,22 +11,67 @@
|
|||||||
#include "include/gpu/GrTypes.h"
|
#include "include/gpu/GrTypes.h"
|
||||||
#include "include/private/GrTypesPriv.h"
|
#include "include/private/GrTypesPriv.h"
|
||||||
|
|
||||||
|
class GrBackendFormat;
|
||||||
|
|
||||||
struct GrMockTextureInfo {
|
struct GrMockTextureInfo {
|
||||||
GrPixelConfig fConfig;
|
GrMockTextureInfo()
|
||||||
int fID;
|
: fColorType(GrColorType::kUnknown)
|
||||||
|
, fSRGBEncoded(GrSRGBEncoded::kNo)
|
||||||
|
, fID(0) {}
|
||||||
|
|
||||||
|
GrMockTextureInfo(GrColorType colorType, GrSRGBEncoded srgbEncoded, int id)
|
||||||
|
: fColorType(colorType)
|
||||||
|
, fSRGBEncoded(srgbEncoded)
|
||||||
|
, fID(id) {
|
||||||
|
SkASSERT(fID);
|
||||||
|
}
|
||||||
|
|
||||||
bool operator==(const GrMockTextureInfo& that) const {
|
bool operator==(const GrMockTextureInfo& that) const {
|
||||||
return fConfig == that.fConfig && fID == that.fID;
|
return fColorType == that.fColorType &&
|
||||||
|
fSRGBEncoded == that.fSRGBEncoded &&
|
||||||
|
fID == that.fID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GrPixelConfig pixelConfig() const {
|
||||||
|
return GrColorTypeToPixelConfig(fColorType, fSRGBEncoded);
|
||||||
|
}
|
||||||
|
|
||||||
|
GrBackendFormat getBackendFormat() const;
|
||||||
|
|
||||||
|
GrColorType fColorType;
|
||||||
|
GrSRGBEncoded fSRGBEncoded;
|
||||||
|
int fID;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GrMockRenderTargetInfo {
|
struct GrMockRenderTargetInfo {
|
||||||
GrPixelConfig fConfig;
|
GrMockRenderTargetInfo()
|
||||||
int fID;
|
: fColorType(GrColorType::kUnknown)
|
||||||
|
, fSRGBEncoded(GrSRGBEncoded::kNo)
|
||||||
|
, fID(0) {}
|
||||||
|
|
||||||
|
GrMockRenderTargetInfo(GrColorType colorType, GrSRGBEncoded srgbEncoded, int id)
|
||||||
|
: fColorType(colorType)
|
||||||
|
, fSRGBEncoded(srgbEncoded)
|
||||||
|
, fID(id) {
|
||||||
|
SkASSERT(fID);
|
||||||
|
}
|
||||||
|
|
||||||
bool operator==(const GrMockRenderTargetInfo& that) const {
|
bool operator==(const GrMockRenderTargetInfo& that) const {
|
||||||
return fConfig == that.fConfig && fID == that.fID;
|
return fColorType == that.fColorType &&
|
||||||
|
fSRGBEncoded == that.fSRGBEncoded &&
|
||||||
|
fID == that.fID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GrPixelConfig pixelConfig() const {
|
||||||
|
return GrColorTypeToPixelConfig(fColorType, fSRGBEncoded);
|
||||||
|
}
|
||||||
|
|
||||||
|
GrBackendFormat getBackendFormat() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
GrColorType fColorType;
|
||||||
|
GrSRGBEncoded fSRGBEncoded;
|
||||||
|
int fID;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,14 +84,12 @@ struct GrMockOptions {
|
|||||||
using Renderability = ConfigOptions::Renderability;
|
using Renderability = ConfigOptions::Renderability;
|
||||||
// By default RGBA_8888 and BGRA_8888 are textureable and renderable and
|
// By default RGBA_8888 and BGRA_8888 are textureable and renderable and
|
||||||
// A8 and RGB565 are texturable.
|
// A8 and RGB565 are texturable.
|
||||||
fConfigOptions[kRGBA_8888_GrPixelConfig].fRenderability = Renderability::kNonMSAA;
|
fConfigOptions[(int)GrColorType::kRGBA_8888].fRenderability = Renderability::kNonMSAA;
|
||||||
fConfigOptions[kRGBA_8888_GrPixelConfig].fTexturable = true;
|
fConfigOptions[(int)GrColorType::kRGBA_8888].fTexturable = true;
|
||||||
fConfigOptions[kAlpha_8_GrPixelConfig].fTexturable = true;
|
fConfigOptions[(int)GrColorType::kAlpha_8].fTexturable = true;
|
||||||
fConfigOptions[kAlpha_8_as_Alpha_GrPixelConfig].fTexturable = true;
|
fConfigOptions[(int)GrColorType::kBGR_565].fTexturable = true;
|
||||||
fConfigOptions[kAlpha_8_as_Red_GrPixelConfig].fTexturable = true;
|
|
||||||
fConfigOptions[kRGB_565_GrPixelConfig].fTexturable = true;
|
|
||||||
|
|
||||||
fConfigOptions[kBGRA_8888_GrPixelConfig] = fConfigOptions[kRGBA_8888_GrPixelConfig];
|
fConfigOptions[(int)GrColorType::kBGRA_8888] = fConfigOptions[(int)GrColorType::kRGBA_8888];
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ConfigOptions {
|
struct ConfigOptions {
|
||||||
@ -62,7 +105,7 @@ struct GrMockOptions {
|
|||||||
int fMaxTextureSize = 2048;
|
int fMaxTextureSize = 2048;
|
||||||
int fMaxRenderTargetSize = 2048;
|
int fMaxRenderTargetSize = 2048;
|
||||||
int fMaxVertexAttributes = 16;
|
int fMaxVertexAttributes = 16;
|
||||||
ConfigOptions fConfigOptions[kGrPixelConfigCnt];
|
ConfigOptions fConfigOptions[kGrColorTypeCnt];
|
||||||
|
|
||||||
// GrShaderCaps options.
|
// GrShaderCaps options.
|
||||||
bool fGeometryShaderSupport = false;
|
bool fGeometryShaderSupport = false;
|
||||||
|
@ -1178,8 +1178,12 @@ enum class GrColorType {
|
|||||||
// Experimental (for Y416 and mutant P016/P010)
|
// Experimental (for Y416 and mutant P016/P010)
|
||||||
kRGBA_16161616, // Not in SkColorType
|
kRGBA_16161616, // Not in SkColorType
|
||||||
kRG_F16, // Not in SkColorType
|
kRG_F16, // Not in SkColorType
|
||||||
|
|
||||||
|
kLast = kRG_F16
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const int kGrColorTypeCnt = static_cast<int>(GrColorType::kLast) + 1;
|
||||||
|
|
||||||
static constexpr SkColorType GrColorTypeToSkColorType(GrColorType ct) {
|
static constexpr SkColorType GrColorTypeToSkColorType(GrColorType ct) {
|
||||||
switch (ct) {
|
switch (ct) {
|
||||||
case GrColorType::kUnknown: return kUnknown_SkColorType;
|
case GrColorType::kUnknown: return kUnknown_SkColorType;
|
||||||
|
@ -45,7 +45,7 @@ GrBackendFormat::GrBackendFormat(const GrBackendFormat& that)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case GrBackendApi::kMock:
|
case GrBackendApi::kMock:
|
||||||
fMockFormat = that.fMockFormat;
|
fMock = that.fMock;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SK_ABORT("Unknown GrBackend");
|
SK_ABORT("Unknown GrBackend");
|
||||||
@ -154,20 +154,29 @@ const GrMTLPixelFormat* GrBackendFormat::getMtlFormat() const {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GrBackendFormat::GrBackendFormat(GrPixelConfig config)
|
GrBackendFormat::GrBackendFormat(GrColorType colorType, GrSRGBEncoded srgbEncoded)
|
||||||
: fBackend(GrBackendApi::kMock)
|
: fBackend(GrBackendApi::kMock)
|
||||||
, fValid(true)
|
, fValid(true)
|
||||||
, fMockFormat(config)
|
|
||||||
, fTextureType(GrTextureType::k2D) {
|
, fTextureType(GrTextureType::k2D) {
|
||||||
|
fMock.fColorType = colorType;
|
||||||
|
fMock.fSRGBEncoded = srgbEncoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GrPixelConfig* GrBackendFormat::getMockFormat() const {
|
const GrColorType* GrBackendFormat::getMockColorType() const {
|
||||||
if (this->isValid() && GrBackendApi::kMock == fBackend) {
|
if (this->isValid() && GrBackendApi::kMock == fBackend) {
|
||||||
return &fMockFormat;
|
return &fMock.fColorType;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GrSRGBEncoded* GrBackendFormat::getMockSRGBEncoded() const {
|
||||||
|
if (this->isValid() && GrBackendApi::kMock == fBackend) {
|
||||||
|
return &fMock.fSRGBEncoded;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GrBackendFormat GrBackendFormat::makeTexture2D() const {
|
GrBackendFormat GrBackendFormat::makeTexture2D() const {
|
||||||
GrBackendFormat copy = *this;
|
GrBackendFormat copy = *this;
|
||||||
if (const GrVkYcbcrConversionInfo* ycbcrInfo = this->getVkYcbcrConversionInfo()) {
|
if (const GrVkYcbcrConversionInfo* ycbcrInfo = this->getVkYcbcrConversionInfo()) {
|
||||||
@ -208,7 +217,8 @@ bool GrBackendFormat::operator==(const GrBackendFormat& that) const {
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case GrBackendApi::kMock:
|
case GrBackendApi::kMock:
|
||||||
return fMockFormat == that.fMockFormat;
|
return fMock.fColorType == that.fMock.fColorType &&
|
||||||
|
fMock.fSRGBEncoded == that.fMock.fSRGBEncoded;
|
||||||
default:
|
default:
|
||||||
SK_ABORT("Unknown GrBackend");
|
SK_ABORT("Unknown GrBackend");
|
||||||
}
|
}
|
||||||
@ -299,7 +309,7 @@ GrBackendTexture::GrBackendTexture(int width,
|
|||||||
: fIsValid(true)
|
: fIsValid(true)
|
||||||
, fWidth(width)
|
, fWidth(width)
|
||||||
, fHeight(height)
|
, fHeight(height)
|
||||||
, fConfig(mockInfo.fConfig)
|
, fConfig(mockInfo.pixelConfig())
|
||||||
, fMipMapped(mipMapped)
|
, fMipMapped(mipMapped)
|
||||||
, fBackend(GrBackendApi::kMock)
|
, fBackend(GrBackendApi::kMock)
|
||||||
, fMockInfo(mockInfo) {}
|
, fMockInfo(mockInfo) {}
|
||||||
@ -492,7 +502,7 @@ GrBackendFormat GrBackendTexture::getBackendFormat() const {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
case GrBackendApi::kMock:
|
case GrBackendApi::kMock:
|
||||||
return GrBackendFormat::MakeMock(fMockInfo.fConfig);
|
return fMockInfo.getBackendFormat();
|
||||||
default:
|
default:
|
||||||
return GrBackendFormat();
|
return GrBackendFormat();
|
||||||
}
|
}
|
||||||
@ -625,7 +635,7 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width,
|
|||||||
, fHeight(height)
|
, fHeight(height)
|
||||||
, fSampleCnt(SkTMax(1, sampleCnt))
|
, fSampleCnt(SkTMax(1, sampleCnt))
|
||||||
, fStencilBits(stencilBits)
|
, fStencilBits(stencilBits)
|
||||||
, fConfig(mockInfo.fConfig)
|
, fConfig(mockInfo.pixelConfig())
|
||||||
, fMockInfo(mockInfo) {}
|
, fMockInfo(mockInfo) {}
|
||||||
|
|
||||||
GrBackendRenderTarget::~GrBackendRenderTarget() {
|
GrBackendRenderTarget::~GrBackendRenderTarget() {
|
||||||
@ -757,7 +767,7 @@ GrBackendFormat GrBackendRenderTarget::getBackendFormat() const {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
case GrBackendApi::kMock:
|
case GrBackendApi::kMock:
|
||||||
return GrBackendFormat::MakeMock(fMockInfo.fConfig);
|
return fMockInfo.getBackendFormat();
|
||||||
default:
|
default:
|
||||||
return GrBackendFormat();
|
return GrBackendFormat();
|
||||||
}
|
}
|
||||||
|
@ -37,49 +37,41 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isFormatSRGB(const GrBackendFormat& format) const override {
|
bool isFormatSRGB(const GrBackendFormat& format) const override {
|
||||||
if (!format.getMockFormat()) {
|
if (!format.getMockSRGBEncoded()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return kSRGBA_8888_GrPixelConfig == *format.getMockFormat();
|
return GrSRGBEncoded::kYes == *format.getMockSRGBEncoded();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFormatTexturable(GrColorType, const GrBackendFormat& format) const override {
|
bool isFormatTexturable(GrColorType, const GrBackendFormat& format) const override {
|
||||||
if (!format.getMockFormat()) {
|
if (!format.getMockColorType()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->isConfigTexturable(*format.getMockFormat());
|
// We are ignoring the srgb encoding here
|
||||||
|
return fOptions.fConfigOptions[(int)*format.getMockColorType()].fTexturable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isConfigTexturable(GrPixelConfig config) const override {
|
bool isConfigTexturable(GrPixelConfig config) const override {
|
||||||
return fOptions.fConfigOptions[config].fTexturable;
|
GrColorType ct = GrPixelConfigToColorType(config);
|
||||||
|
|
||||||
|
// We are ignoring the srgb encoding here
|
||||||
|
return fOptions.fConfigOptions[(int)ct].fTexturable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFormatCopyable(SkColorType, const GrBackendFormat& format) const override {
|
bool isFormatCopyable(SkColorType, const GrBackendFormat& format) const override {
|
||||||
if (!format.getMockFormat()) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->isConfigCopyable(*format.getMockFormat());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isConfigCopyable(GrPixelConfig config) const override {
|
bool isConfigCopyable(GrPixelConfig config) const override {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getRenderTargetSampleCount(int requestCount,
|
int getRenderTargetSampleCount(int requestCount, GrColorType ct) const {
|
||||||
SkColorType, const GrBackendFormat& format) const override {
|
|
||||||
if (!format.getMockFormat()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->getRenderTargetSampleCount(requestCount, *format.getMockFormat());
|
|
||||||
}
|
|
||||||
|
|
||||||
int getRenderTargetSampleCount(int requestCount, GrPixelConfig config) const override {
|
|
||||||
requestCount = SkTMax(requestCount, 1);
|
requestCount = SkTMax(requestCount, 1);
|
||||||
switch (fOptions.fConfigOptions[config].fRenderability) {
|
|
||||||
|
switch (fOptions.fConfigOptions[(int)ct].fRenderability) {
|
||||||
case GrMockOptions::ConfigOptions::Renderability::kNo:
|
case GrMockOptions::ConfigOptions::Renderability::kNo:
|
||||||
return 0;
|
return 0;
|
||||||
case GrMockOptions::ConfigOptions::Renderability::kNonMSAA:
|
case GrMockOptions::ConfigOptions::Renderability::kNonMSAA:
|
||||||
@ -90,16 +82,25 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxRenderTargetSampleCount(SkColorType, const GrBackendFormat& format) const override {
|
int getRenderTargetSampleCount(int requestCount,
|
||||||
if (!format.getMockFormat()) {
|
SkColorType, const GrBackendFormat& format) const override {
|
||||||
|
if (!format.getMockColorType()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->maxRenderTargetSampleCount(*format.getMockFormat());
|
// We are ignoring the srgb encoding here
|
||||||
|
return this->getRenderTargetSampleCount(requestCount, *format.getMockColorType());
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxRenderTargetSampleCount(GrPixelConfig config) const override {
|
int getRenderTargetSampleCount(int requestCount, GrPixelConfig config) const override {
|
||||||
switch (fOptions.fConfigOptions[config].fRenderability) {
|
GrColorType ct = GrPixelConfigToColorType(config);
|
||||||
|
|
||||||
|
// We are ignoring the srgb encoding here
|
||||||
|
return this->getRenderTargetSampleCount(requestCount, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxRenderTargetSampleCount(GrColorType ct) const {
|
||||||
|
switch (fOptions.fConfigOptions[(int)ct].fRenderability) {
|
||||||
case GrMockOptions::ConfigOptions::Renderability::kNo:
|
case GrMockOptions::ConfigOptions::Renderability::kNo:
|
||||||
return 0;
|
return 0;
|
||||||
case GrMockOptions::ConfigOptions::Renderability::kNonMSAA:
|
case GrMockOptions::ConfigOptions::Renderability::kNonMSAA:
|
||||||
@ -110,6 +111,22 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int maxRenderTargetSampleCount(SkColorType, const GrBackendFormat& format) const override {
|
||||||
|
if (!format.getMockColorType()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We are ignoring the srgb encoding here
|
||||||
|
return this->maxRenderTargetSampleCount(*format.getMockColorType());
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxRenderTargetSampleCount(GrPixelConfig config) const override {
|
||||||
|
GrColorType ct = GrPixelConfigToColorType(config);
|
||||||
|
|
||||||
|
// We are ignoring the srgb encoding here
|
||||||
|
return this->maxRenderTargetSampleCount(ct);
|
||||||
|
}
|
||||||
|
|
||||||
SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface*) const override {
|
SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface*) const override {
|
||||||
return SurfaceReadPixelsSupport::kSupported;
|
return SurfaceReadPixelsSupport::kSupported;
|
||||||
}
|
}
|
||||||
@ -125,29 +142,20 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrPixelConfig getYUVAConfigFromBackendFormat(const GrBackendFormat& format) const override {
|
GrPixelConfig getYUVAConfigFromBackendFormat(const GrBackendFormat& format) const override {
|
||||||
const GrPixelConfig* mockFormat = format.getMockFormat();
|
if (!format.getMockColorType() || !format.getMockSRGBEncoded()) {
|
||||||
if (!mockFormat) {
|
|
||||||
return kUnknown_GrPixelConfig;
|
return kUnknown_GrPixelConfig;
|
||||||
}
|
}
|
||||||
return *mockFormat;
|
|
||||||
|
return GrColorTypeToPixelConfig(*format.getMockColorType(),
|
||||||
|
*format.getMockSRGBEncoded());
|
||||||
}
|
}
|
||||||
|
|
||||||
GrBackendFormat getBackendFormatFromColorType(GrColorType ct,
|
GrBackendFormat getBackendFormatFromColorType(GrColorType ct,
|
||||||
GrSRGBEncoded srgbEncoded) const override {
|
GrSRGBEncoded srgbEncoded) const override {
|
||||||
GrPixelConfig config = GrColorTypeToPixelConfig(ct, srgbEncoded);
|
return GrBackendFormat::MakeMock(ct, srgbEncoded);
|
||||||
if (config == kUnknown_GrPixelConfig) {
|
|
||||||
return GrBackendFormat();
|
|
||||||
}
|
|
||||||
return GrBackendFormat::MakeMock(config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GrBackendFormat getBackendFormatFromCompressionType(
|
GrBackendFormat getBackendFormatFromCompressionType(SkImage::CompressionType) const override {
|
||||||
SkImage::CompressionType compressionType) const override {
|
|
||||||
switch (compressionType) {
|
|
||||||
case SkImage::kETC1_CompressionType:
|
|
||||||
return GrBackendFormat::MakeMock(kRGB_ETC1_GrPixelConfig);
|
|
||||||
}
|
|
||||||
SK_ABORT("Invalid compression type");
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,125 +179,29 @@ private:
|
|||||||
|
|
||||||
GrPixelConfig onGetConfigFromBackendFormat(const GrBackendFormat& format,
|
GrPixelConfig onGetConfigFromBackendFormat(const GrBackendFormat& format,
|
||||||
GrColorType) const override {
|
GrColorType) const override {
|
||||||
const GrPixelConfig* mockFormat = format.getMockFormat();
|
if (!format.getMockColorType() || !format.getMockSRGBEncoded()) {
|
||||||
if (!mockFormat) {
|
|
||||||
return kUnknown_GrPixelConfig;
|
return kUnknown_GrPixelConfig;
|
||||||
}
|
}
|
||||||
return *mockFormat;
|
|
||||||
|
return GrColorTypeToPixelConfig(*format.getMockColorType(),
|
||||||
|
*format.getMockSRGBEncoded());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onAreColorTypeAndFormatCompatible(GrColorType ct,
|
bool onAreColorTypeAndFormatCompatible(GrColorType ct,
|
||||||
const GrBackendFormat& format) const override {
|
const GrBackendFormat& format) const override {
|
||||||
const GrPixelConfig* mockFormat = format.getMockFormat();
|
if (GrColorType::kUnknown == ct) {
|
||||||
if (!mockFormat) {
|
return false;
|
||||||
return kUnknown_GrPixelConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ct) {
|
const GrColorType* mockColorType = format.getMockColorType();
|
||||||
case GrColorType::kUnknown:
|
if (!mockColorType) {
|
||||||
return false;
|
return false;
|
||||||
case GrColorType::kAlpha_8:
|
|
||||||
if (kAlpha_8_GrPixelConfig == *mockFormat ||
|
|
||||||
kAlpha_8_as_Alpha_GrPixelConfig == *mockFormat ||
|
|
||||||
kAlpha_8_as_Red_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kBGR_565:
|
|
||||||
if (kRGB_565_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kABGR_4444:
|
|
||||||
if (kRGBA_4444_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_8888:
|
|
||||||
if (kRGBA_8888_GrPixelConfig == *mockFormat ||
|
|
||||||
kSRGBA_8888_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGB_888x:
|
|
||||||
if (kRGB_888X_GrPixelConfig == *mockFormat ||
|
|
||||||
kRGB_888_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRG_88:
|
|
||||||
if (kRG_88_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kBGRA_8888:
|
|
||||||
if (kBGRA_8888_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_1010102:
|
|
||||||
if (kRGBA_1010102_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kGray_8:
|
|
||||||
if (kGray_8_GrPixelConfig == *mockFormat ||
|
|
||||||
kGray_8_as_Lum_GrPixelConfig == *mockFormat ||
|
|
||||||
kGray_8_as_Red_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kAlpha_F16:
|
|
||||||
if (kAlpha_half_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case GrColorType::kRGBA_F16:
|
|
||||||
if (kRGBA_half_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_F16_Clamped:
|
|
||||||
if (kRGBA_half_Clamped_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRG_F32:
|
|
||||||
if (kRG_float_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_F32:
|
|
||||||
if (kRGBA_float_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kR_16:
|
|
||||||
if (kR_16_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRG_1616:
|
|
||||||
if (kRG_1616_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRGBA_16161616:
|
|
||||||
if (kRGBA_16161616_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GrColorType::kRG_F16:
|
|
||||||
if (kRG_half_GrPixelConfig == *mockFormat) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return ct == *mockColorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const int kMaxSampleCnt = 16;
|
static const int kMaxSampleCnt = 16;
|
||||||
|
|
||||||
GrMockOptions fOptions;
|
GrMockOptions fOptions;
|
||||||
|
@ -91,15 +91,17 @@ sk_sp<GrTexture> GrMockGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgete
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GrSRGBEncoded srgbEncoding;
|
||||||
|
GrColorType ct = GrPixelConfigToColorTypeAndEncoding(desc.fConfig, &srgbEncoding);
|
||||||
|
if (GrColorType::kUnknown == ct) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
GrMipMapsStatus mipMapsStatus = mipLevelCount > 1 ? GrMipMapsStatus::kValid
|
GrMipMapsStatus mipMapsStatus = mipLevelCount > 1 ? GrMipMapsStatus::kValid
|
||||||
: GrMipMapsStatus::kNotAllocated;
|
: GrMipMapsStatus::kNotAllocated;
|
||||||
GrMockTextureInfo texInfo;
|
GrMockTextureInfo texInfo(ct, srgbEncoding, NextInternalTextureID());
|
||||||
texInfo.fConfig = desc.fConfig;
|
|
||||||
texInfo.fID = NextInternalTextureID();
|
|
||||||
if (desc.fFlags & kRenderTarget_GrSurfaceFlag) {
|
if (desc.fFlags & kRenderTarget_GrSurfaceFlag) {
|
||||||
GrMockRenderTargetInfo rtInfo;
|
GrMockRenderTargetInfo rtInfo(ct, srgbEncoding, NextInternalRenderTargetID());
|
||||||
rtInfo.fConfig = desc.fConfig;
|
|
||||||
rtInfo.fID = NextInternalRenderTargetID();
|
|
||||||
return sk_sp<GrTexture>(new GrMockTextureRenderTarget(this, budgeted, desc, mipMapsStatus,
|
return sk_sp<GrTexture>(new GrMockTextureRenderTarget(this, budgeted, desc, mipMapsStatus,
|
||||||
texInfo, rtInfo));
|
texInfo, rtInfo));
|
||||||
}
|
}
|
||||||
@ -109,32 +111,19 @@ sk_sp<GrTexture> GrMockGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgete
|
|||||||
sk_sp<GrTexture> GrMockGpu::onCreateCompressedTexture(int width, int height,
|
sk_sp<GrTexture> GrMockGpu::onCreateCompressedTexture(int width, int height,
|
||||||
SkImage::CompressionType compressionType,
|
SkImage::CompressionType compressionType,
|
||||||
SkBudgeted budgeted, const void* data) {
|
SkBudgeted budgeted, const void* data) {
|
||||||
if (fMockOptions.fFailTextureAllocations) {
|
return nullptr;
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
GrBackendFormat format = this->caps()->getBackendFormatFromCompressionType(compressionType);
|
|
||||||
|
|
||||||
GrMockTextureInfo texInfo;
|
|
||||||
texInfo.fConfig = *format.getMockFormat();
|
|
||||||
texInfo.fID = NextInternalTextureID();
|
|
||||||
GrSurfaceDesc desc;
|
|
||||||
desc.fConfig = texInfo.fConfig;
|
|
||||||
desc.fWidth = width;
|
|
||||||
desc.fHeight = height;
|
|
||||||
return sk_sp<GrTexture>(
|
|
||||||
new GrMockTexture(this, budgeted, desc, GrMipMapsStatus::kNotAllocated, texInfo));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTexture> GrMockGpu::onWrapBackendTexture(const GrBackendTexture& tex,
|
sk_sp<GrTexture> GrMockGpu::onWrapBackendTexture(const GrBackendTexture& tex,
|
||||||
GrWrapOwnership ownership,
|
GrWrapOwnership ownership,
|
||||||
GrWrapCacheable wrapType, GrIOType ioType) {
|
GrWrapCacheable wrapType, GrIOType ioType) {
|
||||||
|
GrMockTextureInfo info;
|
||||||
|
SkAssertResult(tex.getMockTextureInfo(&info));
|
||||||
|
|
||||||
GrSurfaceDesc desc;
|
GrSurfaceDesc desc;
|
||||||
desc.fWidth = tex.width();
|
desc.fWidth = tex.width();
|
||||||
desc.fHeight = tex.height();
|
desc.fHeight = tex.height();
|
||||||
|
desc.fConfig = info.pixelConfig();
|
||||||
GrMockTextureInfo info;
|
|
||||||
SkAssertResult(tex.getMockTextureInfo(&info));
|
|
||||||
desc.fConfig = info.fConfig;
|
|
||||||
|
|
||||||
GrMipMapsStatus mipMapsStatus = tex.hasMipMaps() ? GrMipMapsStatus::kValid
|
GrMipMapsStatus mipMapsStatus = tex.hasMipMaps() ? GrMipMapsStatus::kValid
|
||||||
: GrMipMapsStatus::kNotAllocated;
|
: GrMipMapsStatus::kNotAllocated;
|
||||||
@ -146,36 +135,35 @@ sk_sp<GrTexture> GrMockGpu::onWrapRenderableBackendTexture(const GrBackendTextur
|
|||||||
int sampleCnt,
|
int sampleCnt,
|
||||||
GrWrapOwnership ownership,
|
GrWrapOwnership ownership,
|
||||||
GrWrapCacheable cacheable) {
|
GrWrapCacheable cacheable) {
|
||||||
|
GrMockTextureInfo texInfo;
|
||||||
|
SkAssertResult(tex.getMockTextureInfo(&texInfo));
|
||||||
|
|
||||||
GrSurfaceDesc desc;
|
GrSurfaceDesc desc;
|
||||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||||
desc.fWidth = tex.width();
|
desc.fWidth = tex.width();
|
||||||
desc.fHeight = tex.height();
|
desc.fHeight = tex.height();
|
||||||
|
desc.fConfig = texInfo.pixelConfig();
|
||||||
GrMockTextureInfo texInfo;
|
|
||||||
SkAssertResult(tex.getMockTextureInfo(&texInfo));
|
|
||||||
desc.fConfig = texInfo.fConfig;
|
|
||||||
|
|
||||||
GrMipMapsStatus mipMapsStatus =
|
GrMipMapsStatus mipMapsStatus =
|
||||||
tex.hasMipMaps() ? GrMipMapsStatus::kValid : GrMipMapsStatus::kNotAllocated;
|
tex.hasMipMaps() ? GrMipMapsStatus::kValid : GrMipMapsStatus::kNotAllocated;
|
||||||
|
|
||||||
GrMockRenderTargetInfo rtInfo;
|
|
||||||
rtInfo.fConfig = texInfo.fConfig;
|
|
||||||
// The client gave us the texture ID but we supply the render target ID.
|
// The client gave us the texture ID but we supply the render target ID.
|
||||||
rtInfo.fID = NextInternalRenderTargetID();
|
GrMockRenderTargetInfo rtInfo(texInfo.fColorType, texInfo.fSRGBEncoded,
|
||||||
|
NextInternalRenderTargetID());
|
||||||
|
|
||||||
return sk_sp<GrTexture>(
|
return sk_sp<GrTexture>(
|
||||||
new GrMockTextureRenderTarget(this, desc, mipMapsStatus, texInfo, rtInfo, cacheable));
|
new GrMockTextureRenderTarget(this, desc, mipMapsStatus, texInfo, rtInfo, cacheable));
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& rt) {
|
sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& rt) {
|
||||||
|
GrMockRenderTargetInfo info;
|
||||||
|
SkAssertResult(rt.getMockRenderTargetInfo(&info));
|
||||||
|
|
||||||
GrSurfaceDesc desc;
|
GrSurfaceDesc desc;
|
||||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||||
desc.fWidth = rt.width();
|
desc.fWidth = rt.width();
|
||||||
desc.fHeight = rt.height();
|
desc.fHeight = rt.height();
|
||||||
|
desc.fConfig = info.pixelConfig();
|
||||||
GrMockRenderTargetInfo info;
|
|
||||||
SkAssertResult(rt.getMockRenderTargetInfo(&info));
|
|
||||||
desc.fConfig = info.fConfig;
|
|
||||||
|
|
||||||
return sk_sp<GrRenderTarget>(
|
return sk_sp<GrRenderTarget>(
|
||||||
new GrMockRenderTarget(this, GrMockRenderTarget::kWrapped, desc, info));
|
new GrMockRenderTarget(this, GrMockRenderTarget::kWrapped, desc, info));
|
||||||
@ -183,20 +171,19 @@ sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendRenderTarget(const GrBackendRender
|
|||||||
|
|
||||||
sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
|
sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
|
||||||
int sampleCnt) {
|
int sampleCnt) {
|
||||||
|
GrMockTextureInfo texInfo;
|
||||||
|
SkAssertResult(tex.getMockTextureInfo(&texInfo));
|
||||||
|
|
||||||
GrSurfaceDesc desc;
|
GrSurfaceDesc desc;
|
||||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||||
desc.fWidth = tex.width();
|
desc.fWidth = tex.width();
|
||||||
desc.fHeight = tex.height();
|
desc.fHeight = tex.height();
|
||||||
|
desc.fConfig = texInfo.pixelConfig();
|
||||||
GrMockTextureInfo texInfo;
|
|
||||||
SkAssertResult(tex.getMockTextureInfo(&texInfo));
|
|
||||||
desc.fConfig = texInfo.fConfig;
|
|
||||||
desc.fSampleCnt = sampleCnt;
|
desc.fSampleCnt = sampleCnt;
|
||||||
|
|
||||||
GrMockRenderTargetInfo rtInfo;
|
|
||||||
rtInfo.fConfig = texInfo.fConfig;
|
|
||||||
// The client gave us the texture ID but we supply the render target ID.
|
// The client gave us the texture ID but we supply the render target ID.
|
||||||
rtInfo.fID = NextInternalRenderTargetID();
|
GrMockRenderTargetInfo rtInfo(texInfo.fColorType, texInfo.fSRGBEncoded,
|
||||||
|
NextInternalRenderTargetID());
|
||||||
|
|
||||||
return sk_sp<GrRenderTarget>(
|
return sk_sp<GrRenderTarget>(
|
||||||
new GrMockRenderTarget(this, GrMockRenderTarget::kWrapped, desc, rtInfo));
|
new GrMockRenderTarget(this, GrMockRenderTarget::kWrapped, desc, rtInfo));
|
||||||
@ -224,18 +211,20 @@ GrBackendTexture GrMockGpu::createBackendTexture(int w, int h,
|
|||||||
const SkColor4f* /* color */,
|
const SkColor4f* /* color */,
|
||||||
GrProtected /* isProtected */) {
|
GrProtected /* isProtected */) {
|
||||||
|
|
||||||
const GrPixelConfig* pixelConfig = format.getMockFormat();
|
if (!format.getMockColorType() || !format.getMockSRGBEncoded()) {
|
||||||
if (!pixelConfig) {
|
return GrBackendTexture(); // invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
GrPixelConfig config = GrColorTypeToPixelConfig(*format.getMockColorType(),
|
||||||
|
*format.getMockSRGBEncoded());
|
||||||
|
|
||||||
|
if (!this->caps()->isConfigTexturable(config)) {
|
||||||
return GrBackendTexture(); // invalid
|
return GrBackendTexture(); // invalid
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->caps()->isConfigTexturable(*pixelConfig)) {
|
GrMockTextureInfo info(*format.getMockColorType(), *format.getMockSRGBEncoded(),
|
||||||
return GrBackendTexture(); // invalid
|
NextExternalTextureID());
|
||||||
}
|
|
||||||
|
|
||||||
GrMockTextureInfo info;
|
|
||||||
info.fConfig = *pixelConfig;
|
|
||||||
info.fID = NextExternalTextureID();
|
|
||||||
fOutstandingTestingOnlyTextureIDs.add(info.fID);
|
fOutstandingTestingOnlyTextureIDs.add(info.fID);
|
||||||
return GrBackendTexture(w, h, mipMapped, info);
|
return GrBackendTexture(w, h, mipMapped, info);
|
||||||
}
|
}
|
||||||
@ -263,14 +252,10 @@ bool GrMockGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
|
|||||||
|
|
||||||
GrBackendRenderTarget GrMockGpu::createTestingOnlyBackendRenderTarget(int w, int h,
|
GrBackendRenderTarget GrMockGpu::createTestingOnlyBackendRenderTarget(int w, int h,
|
||||||
GrColorType colorType) {
|
GrColorType colorType) {
|
||||||
auto config = GrColorTypeToPixelConfig(colorType, GrSRGBEncoded::kNo);
|
GrMockRenderTargetInfo info(colorType, GrSRGBEncoded::kNo, NextExternalRenderTargetID());
|
||||||
if (kUnknown_GrPixelConfig == config) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
GrMockRenderTargetInfo info = {config, NextExternalRenderTargetID()};
|
|
||||||
static constexpr int kSampleCnt = 1;
|
static constexpr int kSampleCnt = 1;
|
||||||
static constexpr int kStencilBits = 8;
|
static constexpr int kStencilBits = 8;
|
||||||
return {w, h, kSampleCnt, kStencilBits, info};
|
return GrBackendRenderTarget(w, h, kSampleCnt, kStencilBits, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrMockGpu::deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget&) {}
|
void GrMockGpu::deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget&) {}
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrBackendFormat backendFormat() const override {
|
GrBackendFormat backendFormat() const override {
|
||||||
return GrBackendFormat::MakeMock(fInfo.fConfig);
|
return fInfo.getBackendFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
void textureParamsModified() override {}
|
void textureParamsModified() override {}
|
||||||
@ -109,7 +109,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrBackendFormat backendFormat() const override {
|
GrBackendFormat backendFormat() const override {
|
||||||
return GrBackendFormat::MakeMock(fInfo.fConfig);
|
return fInfo.getBackendFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
18
src/gpu/mock/GrMockTypes.cpp
Normal file
18
src/gpu/mock/GrMockTypes.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "include/gpu/mock/GrMockTypes.h"
|
||||||
|
|
||||||
|
#include "include/gpu/GrBackendSurface.h"
|
||||||
|
|
||||||
|
GrBackendFormat GrMockRenderTargetInfo::getBackendFormat() const {
|
||||||
|
return GrBackendFormat::MakeMock(fColorType, fSRGBEncoded);
|
||||||
|
}
|
||||||
|
|
||||||
|
GrBackendFormat GrMockTextureInfo::getBackendFormat() const {
|
||||||
|
return GrBackendFormat::MakeMock(fColorType, fSRGBEncoded);
|
||||||
|
}
|
@ -143,12 +143,12 @@ public:
|
|||||||
mockOptions.fInstanceAttribSupport = true;
|
mockOptions.fInstanceAttribSupport = true;
|
||||||
mockOptions.fHalfFloatVertexAttributeSupport = true;
|
mockOptions.fHalfFloatVertexAttributeSupport = true;
|
||||||
mockOptions.fMapBufferFlags = GrCaps::kCanMap_MapFlag;
|
mockOptions.fMapBufferFlags = GrCaps::kCanMap_MapFlag;
|
||||||
mockOptions.fConfigOptions[kAlpha_half_GrPixelConfig].fRenderability =
|
mockOptions.fConfigOptions[(int)GrColorType::kAlpha_F16].fRenderability =
|
||||||
GrMockOptions::ConfigOptions::Renderability::kNonMSAA;
|
GrMockOptions::ConfigOptions::Renderability::kNonMSAA;
|
||||||
mockOptions.fConfigOptions[kAlpha_half_GrPixelConfig].fTexturable = true;
|
mockOptions.fConfigOptions[(int)GrColorType::kAlpha_F16].fTexturable = true;
|
||||||
mockOptions.fConfigOptions[kAlpha_8_GrPixelConfig].fRenderability =
|
mockOptions.fConfigOptions[(int)GrColorType::kAlpha_8].fRenderability =
|
||||||
GrMockOptions::ConfigOptions::Renderability::kNonMSAA;
|
GrMockOptions::ConfigOptions::Renderability::kNonMSAA;
|
||||||
mockOptions.fConfigOptions[kAlpha_8_GrPixelConfig].fTexturable = true;
|
mockOptions.fConfigOptions[(int)GrColorType::kAlpha_8].fTexturable = true;
|
||||||
mockOptions.fGeometryShaderSupport = true;
|
mockOptions.fGeometryShaderSupport = true;
|
||||||
mockOptions.fIntegerSupport = true;
|
mockOptions.fIntegerSupport = true;
|
||||||
mockOptions.fFlatInterpolationSupport = true;
|
mockOptions.fFlatInterpolationSupport = true;
|
||||||
|
@ -80,40 +80,6 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
|
|||||||
GrResourceProvider* resourceProvider = context->priv().resourceProvider();
|
GrResourceProvider* resourceProvider = context->priv().resourceProvider();
|
||||||
const GrCaps* caps = context->priv().caps();
|
const GrCaps* caps = context->priv().caps();
|
||||||
|
|
||||||
GrPixelConfig configs[] = {
|
|
||||||
kUnknown_GrPixelConfig,
|
|
||||||
kAlpha_8_GrPixelConfig,
|
|
||||||
kAlpha_8_as_Alpha_GrPixelConfig,
|
|
||||||
kAlpha_8_as_Red_GrPixelConfig,
|
|
||||||
kGray_8_GrPixelConfig,
|
|
||||||
kGray_8_as_Lum_GrPixelConfig,
|
|
||||||
kGray_8_as_Red_GrPixelConfig,
|
|
||||||
kRGB_565_GrPixelConfig,
|
|
||||||
kRGBA_4444_GrPixelConfig,
|
|
||||||
kRGBA_8888_GrPixelConfig,
|
|
||||||
kRGB_888_GrPixelConfig,
|
|
||||||
kRGB_888X_GrPixelConfig,
|
|
||||||
kRG_88_GrPixelConfig,
|
|
||||||
kBGRA_8888_GrPixelConfig,
|
|
||||||
kSRGBA_8888_GrPixelConfig,
|
|
||||||
kRGBA_1010102_GrPixelConfig,
|
|
||||||
kRGBA_float_GrPixelConfig,
|
|
||||||
kRG_float_GrPixelConfig,
|
|
||||||
kAlpha_half_GrPixelConfig,
|
|
||||||
kAlpha_half_as_Red_GrPixelConfig,
|
|
||||||
kRGBA_half_GrPixelConfig,
|
|
||||||
kRGBA_half_Clamped_GrPixelConfig,
|
|
||||||
kRGB_ETC1_GrPixelConfig,
|
|
||||||
|
|
||||||
kR_16_GrPixelConfig,
|
|
||||||
kRG_1616_GrPixelConfig,
|
|
||||||
|
|
||||||
// Experimental (for Y416 and mutant P016/P010)
|
|
||||||
kRGBA_16161616_GrPixelConfig,
|
|
||||||
kRG_half_GrPixelConfig,
|
|
||||||
};
|
|
||||||
GR_STATIC_ASSERT(kGrPixelConfigCnt == SK_ARRAY_COUNT(configs));
|
|
||||||
|
|
||||||
auto createTexture = [](int width, int height, GrPixelConfig config, GrRenderable renderable,
|
auto createTexture = [](int width, int height, GrPixelConfig config, GrRenderable renderable,
|
||||||
GrResourceProvider* rp) -> sk_sp<GrTexture> {
|
GrResourceProvider* rp) -> sk_sp<GrTexture> {
|
||||||
if (GrPixelConfigIsCompressed(config)) {
|
if (GrPixelConfigIsCompressed(config)) {
|
||||||
@ -150,7 +116,9 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (GrPixelConfig config : configs) {
|
for (int c = 0; c <= kLast_GrPixelConfig; ++c) {
|
||||||
|
GrPixelConfig config = static_cast<GrPixelConfig>(c);
|
||||||
|
|
||||||
for (GrSurfaceOrigin origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
|
for (GrSurfaceOrigin origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
|
||||||
if (config == kUnknown_GrPixelConfig) {
|
if (config == kUnknown_GrPixelConfig) {
|
||||||
// It is not valid to be calling into GrProxyProvider with an unknown pixel config.
|
// It is not valid to be calling into GrProxyProvider with an unknown pixel config.
|
||||||
|
@ -199,9 +199,9 @@ private:
|
|||||||
|
|
||||||
DEF_GPUTEST(LazyProxyTest, reporter, /* options */) {
|
DEF_GPUTEST(LazyProxyTest, reporter, /* options */) {
|
||||||
GrMockOptions mockOptions;
|
GrMockOptions mockOptions;
|
||||||
mockOptions.fConfigOptions[kAlpha_half_GrPixelConfig].fRenderability =
|
mockOptions.fConfigOptions[(int)GrColorType::kAlpha_F16].fRenderability =
|
||||||
GrMockOptions::ConfigOptions::Renderability::kNonMSAA;
|
GrMockOptions::ConfigOptions::Renderability::kNonMSAA;
|
||||||
mockOptions.fConfigOptions[kAlpha_half_GrPixelConfig].fTexturable = true;
|
mockOptions.fConfigOptions[(int)GrColorType::kAlpha_F16].fTexturable = true;
|
||||||
sk_sp<GrContext> ctx = GrContext::MakeMock(&mockOptions, GrContextOptions());
|
sk_sp<GrContext> ctx = GrContext::MakeMock(&mockOptions, GrContextOptions());
|
||||||
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
|
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
|
||||||
for (bool nullTexture : {false, true}) {
|
for (bool nullTexture : {false, true}) {
|
||||||
|
@ -111,16 +111,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
|
|||||||
|
|
||||||
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
|
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
|
||||||
for (auto widthHeight : { 100, 128, 1048576 }) {
|
for (auto widthHeight : { 100, 128, 1048576 }) {
|
||||||
for (auto config : { kAlpha_8_GrPixelConfig, kRGB_565_GrPixelConfig,
|
for (auto ct : { GrColorType::kAlpha_8, GrColorType::kBGR_565,
|
||||||
kRGBA_8888_GrPixelConfig, kRGBA_1010102_GrPixelConfig,
|
GrColorType::kRGBA_8888, GrColorType::kRGBA_1010102 } ) {
|
||||||
kRGB_ETC1_GrPixelConfig }) {
|
|
||||||
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
|
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
|
||||||
for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
|
for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
|
||||||
for (auto numSamples : {1, 4, 16, 128}) {
|
for (auto numSamples : {1, 4, 16, 128}) {
|
||||||
// We don't have recycling support for compressed textures
|
|
||||||
if (GrPixelConfigIsCompressed(config) && SkBackingFit::kApprox == fit) {
|
auto config = GrColorTypeToPixelConfig(ct, GrSRGBEncoded::kNo);
|
||||||
continue;
|
SkASSERT(kUnknown_GrPixelConfig != config);
|
||||||
}
|
|
||||||
|
|
||||||
GrSurfaceDesc desc;
|
GrSurfaceDesc desc;
|
||||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||||
@ -129,11 +127,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
|
|||||||
desc.fConfig = config;
|
desc.fConfig = config;
|
||||||
desc.fSampleCnt = numSamples;
|
desc.fSampleCnt = numSamples;
|
||||||
|
|
||||||
GrSRGBEncoded srgbEncoded;
|
|
||||||
GrColorType colorType =
|
|
||||||
GrPixelConfigToColorTypeAndEncoding(config, &srgbEncoded);
|
|
||||||
const GrBackendFormat format =
|
const GrBackendFormat format =
|
||||||
caps.getBackendFormatFromColorType(colorType, srgbEncoded);
|
caps.getBackendFormatFromColorType(ct, GrSRGBEncoded::kNo);
|
||||||
if (!format.isValid()) {
|
if (!format.isValid()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user