Make sure random unit test processors use an alpha type compatible with
texture data. It'd probably be good to provide an opaque texture that has an alpha channel and widen the range of color types that are present in the future. Change-Id: I5587a479f7e2f3991f8ae27a4cd44afc533324e8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/260696 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
cd774debd7
commit
766098de94
@ -545,12 +545,8 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect);
|
|||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
std::unique_ptr<GrFragmentProcessor> GrDisplacementMapEffect::TestCreate(GrProcessorTestData* d) {
|
std::unique_ptr<GrFragmentProcessor> GrDisplacementMapEffect::TestCreate(GrProcessorTestData* d) {
|
||||||
int texIdxDispl = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
|
auto [dispProxy, ct1, at1] = d->randomProxy();
|
||||||
GrProcessorUnitTest::kAlphaTextureIdx;
|
auto [colorProxy, ct2, at2] = d->randomProxy();
|
||||||
int texIdxColor = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
|
|
||||||
GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
sk_sp<GrTextureProxy> dispProxy = d->textureProxy(texIdxDispl);
|
|
||||||
sk_sp<GrTextureProxy> colorProxy = d->textureProxy(texIdxColor);
|
|
||||||
static const int kMaxComponent = static_cast<int>(SkColorChannel::kLastEnum);
|
static const int kMaxComponent = static_cast<int>(SkColorChannel::kLastEnum);
|
||||||
SkColorChannel xChannelSelector =
|
SkColorChannel xChannelSelector =
|
||||||
static_cast<SkColorChannel>(d->fRandom->nextRangeU(1, kMaxComponent));
|
static_cast<SkColorChannel>(d->fRandom->nextRangeU(1, kMaxComponent));
|
||||||
|
@ -1705,9 +1705,7 @@ static SkImageFilterLight* create_random_light(SkRandom* random) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<GrFragmentProcessor> GrDiffuseLightingEffect::TestCreate(GrProcessorTestData* d) {
|
std::unique_ptr<GrFragmentProcessor> GrDiffuseLightingEffect::TestCreate(GrProcessorTestData* d) {
|
||||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
auto [proxy, ct, at] = d->randomProxy();
|
||||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
|
|
||||||
SkScalar surfaceScale = d->fRandom->nextSScalar1();
|
SkScalar surfaceScale = d->fRandom->nextSScalar1();
|
||||||
SkScalar kd = d->fRandom->nextUScalar1();
|
SkScalar kd = d->fRandom->nextUScalar1();
|
||||||
sk_sp<SkImageFilterLight> light(create_random_light(d->fRandom));
|
sk_sp<SkImageFilterLight> light(create_random_light(d->fRandom));
|
||||||
@ -1923,9 +1921,7 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSpecularLightingEffect);
|
|||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
std::unique_ptr<GrFragmentProcessor> GrSpecularLightingEffect::TestCreate(GrProcessorTestData* d) {
|
std::unique_ptr<GrFragmentProcessor> GrSpecularLightingEffect::TestCreate(GrProcessorTestData* d) {
|
||||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
auto [proxy, ct, at] = d->randomProxy();
|
||||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
|
|
||||||
SkScalar surfaceScale = d->fRandom->nextSScalar1();
|
SkScalar surfaceScale = d->fRandom->nextSScalar1();
|
||||||
SkScalar ks = d->fRandom->nextUScalar1();
|
SkScalar ks = d->fRandom->nextUScalar1();
|
||||||
SkScalar shininess = d->fRandom->nextUScalar1();
|
SkScalar shininess = d->fRandom->nextUScalar1();
|
||||||
|
@ -455,17 +455,13 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMorphologyEffect);
|
|||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
std::unique_ptr<GrFragmentProcessor> GrMorphologyEffect::TestCreate(GrProcessorTestData* d) {
|
std::unique_ptr<GrFragmentProcessor> GrMorphologyEffect::TestCreate(GrProcessorTestData* d) {
|
||||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
auto [proxy, ct, at] = d->randomProxy();
|
||||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
|
|
||||||
|
|
||||||
MorphDirection dir = d->fRandom->nextBool() ? MorphDirection::kX : MorphDirection::kY;
|
MorphDirection dir = d->fRandom->nextBool() ? MorphDirection::kX : MorphDirection::kY;
|
||||||
static const int kMaxRadius = 10;
|
static const int kMaxRadius = 10;
|
||||||
int radius = d->fRandom->nextRangeU(1, kMaxRadius);
|
int radius = d->fRandom->nextRangeU(1, kMaxRadius);
|
||||||
MorphType type = d->fRandom->nextBool() ? MorphType::kErode : MorphType::kDilate;
|
MorphType type = d->fRandom->nextBool() ? MorphType::kErode : MorphType::kDilate;
|
||||||
auto alphaType = static_cast<SkAlphaType>(
|
return GrMorphologyEffect::Make(std::move(proxy), at, dir, radius, type);
|
||||||
d->fRandom->nextRangeU(kUnknown_SkAlphaType + 1, kLastEnum_SkAlphaType));
|
|
||||||
return GrMorphologyEffect::Make(std::move(proxy), alphaType, dir, radius, type);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -15,86 +15,6 @@
|
|||||||
#include "src/gpu/GrTextureProxy.h"
|
#include "src/gpu/GrTextureProxy.h"
|
||||||
#include "src/gpu/GrXferProcessor.h"
|
#include "src/gpu/GrXferProcessor.h"
|
||||||
|
|
||||||
#if GR_TEST_UTILS
|
|
||||||
|
|
||||||
GrResourceProvider* GrProcessorTestData::resourceProvider() {
|
|
||||||
return fContext->priv().resourceProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
GrProxyProvider* GrProcessorTestData::proxyProvider() {
|
|
||||||
return fContext->priv().proxyProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
const GrCaps* GrProcessorTestData::caps() { return fContext->priv().caps(); }
|
|
||||||
|
|
||||||
class GrFragmentProcessor;
|
|
||||||
class GrGeometryProcessor;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Originally these were both in the processor unit test header, but then it seemed to cause linker
|
|
||||||
* problems on android.
|
|
||||||
*/
|
|
||||||
template <>
|
|
||||||
SkTArray<GrFragmentProcessorTestFactory*, true>* GrFragmentProcessorTestFactory::GetFactories() {
|
|
||||||
static SkTArray<GrFragmentProcessorTestFactory*, true> gFactories;
|
|
||||||
return &gFactories;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
SkTArray<GrGeometryProcessorTestFactory*, true>* GrGeometryProcessorTestFactory::GetFactories() {
|
|
||||||
static SkTArray<GrGeometryProcessorTestFactory*, true> gFactories;
|
|
||||||
return &gFactories;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkTArray<GrXPFactoryTestFactory*, true>* GrXPFactoryTestFactory::GetFactories() {
|
|
||||||
static SkTArray<GrXPFactoryTestFactory*, true> gFactories;
|
|
||||||
return &gFactories;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To ensure we always have successful static initialization, before creating from the factories
|
|
||||||
* we verify the count is as expected. If a new factory is added, then these numbers must be
|
|
||||||
* manually adjusted.
|
|
||||||
*/
|
|
||||||
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
|
|
||||||
static const int kFPFactoryCount = 37;
|
|
||||||
static const int kGPFactoryCount = 14;
|
|
||||||
static const int kXPFactoryCount = 4;
|
|
||||||
#else
|
|
||||||
static const int kFPFactoryCount = 0;
|
|
||||||
static const int kGPFactoryCount = 0;
|
|
||||||
static const int kXPFactoryCount = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <>
|
|
||||||
void GrFragmentProcessorTestFactory::VerifyFactoryCount() {
|
|
||||||
if (kFPFactoryCount != GetFactories()->count()) {
|
|
||||||
SkDebugf("\nExpected %d fragment processor factories, found %d.\n",
|
|
||||||
kFPFactoryCount, GetFactories()->count());
|
|
||||||
SK_ABORT("Wrong number of fragment processor factories!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
void GrGeometryProcessorTestFactory::VerifyFactoryCount() {
|
|
||||||
if (kGPFactoryCount != GetFactories()->count()) {
|
|
||||||
SkDebugf("\nExpected %d geometry processor factories, found %d.\n",
|
|
||||||
kGPFactoryCount, GetFactories()->count());
|
|
||||||
SK_ABORT("Wrong number of geometry processor factories!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GrXPFactoryTestFactory::VerifyFactoryCount() {
|
|
||||||
if (kXPFactoryCount != GetFactories()->count()) {
|
|
||||||
SkDebugf("\nExpected %d xp factory factories, found %d.\n",
|
|
||||||
kXPFactoryCount, GetFactories()->count());
|
|
||||||
SK_ABORT("Wrong number of xp factory factories!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// We use a global pool protected by a mutex(spinlock). Chrome may use the same GrContext on
|
// We use a global pool protected by a mutex(spinlock). Chrome may use the same GrContext on
|
||||||
// different threads. The GrContext is not used concurrently on different threads and there is a
|
// different threads. The GrContext is not used concurrently on different threads and there is a
|
||||||
// memory barrier between accesses of a context on different threads. Also, there may be multiple
|
// memory barrier between accesses of a context on different threads. Also, there may be multiple
|
||||||
|
@ -5,21 +5,116 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "src/gpu/GrFragmentProcessor.h"
|
|
||||||
#include "src/gpu/GrProcessorUnitTest.h"
|
#include "src/gpu/GrProcessorUnitTest.h"
|
||||||
|
|
||||||
|
#include "include/gpu/GrContext.h"
|
||||||
|
#include "src/gpu/GrContextPriv.h"
|
||||||
|
#include "src/gpu/GrFragmentProcessor.h"
|
||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
|
|
||||||
|
GrProcessorTestData::GrProcessorTestData(SkRandom* random,
|
||||||
|
GrContext* context,
|
||||||
|
int numProxies,
|
||||||
|
const ProxyInfo proxies[])
|
||||||
|
: fRandom(random), fContext(context) {
|
||||||
|
fProxies.reset(proxies, numProxies);
|
||||||
|
fArena = std::unique_ptr<SkArenaAlloc>(new SkArenaAlloc(1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
GrResourceProvider* GrProcessorTestData::resourceProvider() {
|
||||||
|
return fContext->priv().resourceProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
GrProxyProvider* GrProcessorTestData::proxyProvider() { return fContext->priv().proxyProvider(); }
|
||||||
|
|
||||||
|
const GrCaps* GrProcessorTestData::caps() { return fContext->priv().caps(); }
|
||||||
|
|
||||||
|
GrProcessorTestData::ProxyInfo GrProcessorTestData::randomProxy() {
|
||||||
|
SkASSERT(!fProxies.empty());
|
||||||
|
return fProxies[fRandom->nextULessThan(fProxies.count())];
|
||||||
|
}
|
||||||
|
|
||||||
|
GrProcessorTestData::ProxyInfo GrProcessorTestData::randomAlphaOnlyProxy() {
|
||||||
|
int numAlphaOnly = 0;
|
||||||
|
for (const auto& [p, ct, at] : fProxies) {
|
||||||
|
if (GrColorTypeIsAlphaOnly(ct)) {
|
||||||
|
++numAlphaOnly;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SkASSERT(numAlphaOnly);
|
||||||
|
int idx = fRandom->nextULessThan(numAlphaOnly);
|
||||||
|
for (const auto& [p, ct, at] : fProxies) {
|
||||||
|
if (GrColorTypeIsAlphaOnly(ct) && !idx--) {
|
||||||
|
return {p, ct, at};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SkUNREACHABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
class GrFragmentProcessor;
|
||||||
|
class GrGeometryProcessor;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Originally these were both in the processor unit test header, but then it seemed to cause linker
|
||||||
|
* problems on android.
|
||||||
|
*/
|
||||||
|
template <>
|
||||||
|
SkTArray<GrFragmentProcessorTestFactory*, true>* GrFragmentProcessorTestFactory::GetFactories() {
|
||||||
|
static SkTArray<GrFragmentProcessorTestFactory*, true> gFactories;
|
||||||
|
return &gFactories;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
SkTArray<GrGeometryProcessorTestFactory*, true>* GrGeometryProcessorTestFactory::GetFactories() {
|
||||||
|
static SkTArray<GrGeometryProcessorTestFactory*, true> gFactories;
|
||||||
|
return &gFactories;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkTArray<GrXPFactoryTestFactory*, true>* GrXPFactoryTestFactory::GetFactories() {
|
||||||
|
static SkTArray<GrXPFactoryTestFactory*, true> gFactories;
|
||||||
|
return &gFactories;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To ensure we always have successful static initialization, before creating from the factories
|
||||||
|
* we verify the count is as expected. If a new factory is added, then these numbers must be
|
||||||
|
* manually adjusted.
|
||||||
|
*/
|
||||||
|
static const int kFPFactoryCount = 37;
|
||||||
|
static const int kGPFactoryCount = 14;
|
||||||
|
static const int kXPFactoryCount = 4;
|
||||||
|
|
||||||
|
template <> void GrFragmentProcessorTestFactory::VerifyFactoryCount() {
|
||||||
|
if (kFPFactoryCount != GetFactories()->count()) {
|
||||||
|
SkDebugf("\nExpected %d fragment processor factories, found %d.\n", kFPFactoryCount,
|
||||||
|
GetFactories()->count());
|
||||||
|
SK_ABORT("Wrong number of fragment processor factories!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <> void GrGeometryProcessorTestFactory::VerifyFactoryCount() {
|
||||||
|
if (kGPFactoryCount != GetFactories()->count()) {
|
||||||
|
SkDebugf("\nExpected %d geometry processor factories, found %d.\n", kGPFactoryCount,
|
||||||
|
GetFactories()->count());
|
||||||
|
SK_ABORT("Wrong number of geometry processor factories!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GrXPFactoryTestFactory::VerifyFactoryCount() {
|
||||||
|
if (kXPFactoryCount != GetFactories()->count()) {
|
||||||
|
SkDebugf("\nExpected %d xp factory factories, found %d.\n", kXPFactoryCount,
|
||||||
|
GetFactories()->count());
|
||||||
|
SK_ABORT("Wrong number of xp factory factories!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<GrFragmentProcessor> GrProcessorUnitTest::MakeChildFP(GrProcessorTestData* data) {
|
std::unique_ptr<GrFragmentProcessor> GrProcessorUnitTest::MakeChildFP(GrProcessorTestData* data) {
|
||||||
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
|
|
||||||
std::unique_ptr<GrFragmentProcessor> fp;
|
std::unique_ptr<GrFragmentProcessor> fp;
|
||||||
do {
|
do {
|
||||||
fp = GrFragmentProcessorTestFactory::Make(data);
|
fp = GrFragmentProcessorTestFactory::Make(data);
|
||||||
SkASSERT(fp);
|
SkASSERT(fp);
|
||||||
} while (fp->numChildProcessors() != 0);
|
} while (fp->numChildProcessors() != 0);
|
||||||
return fp;
|
return fp;
|
||||||
#else
|
|
||||||
SK_ABORT("Should not be called if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,12 +17,14 @@
|
|||||||
#include "src/gpu/GrTestUtils.h"
|
#include "src/gpu/GrTestUtils.h"
|
||||||
#include "src/gpu/GrTextureProxy.h"
|
#include "src/gpu/GrTextureProxy.h"
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
class SkMatrix;
|
class SkMatrix;
|
||||||
class GrCaps;
|
class GrCaps;
|
||||||
class GrContext;
|
class GrContext;
|
||||||
class GrProxyProvider;
|
class GrProxyProvider;
|
||||||
class GrRenderTargetContext;
|
class GrRenderTargetContext;
|
||||||
struct GrProcessorTestData;
|
class GrProcessorTestData;
|
||||||
class GrTexture;
|
class GrTexture;
|
||||||
class GrXPFactory;
|
class GrXPFactory;
|
||||||
class GrGeometryProcessor;
|
class GrGeometryProcessor;
|
||||||
@ -48,33 +50,25 @@ std::unique_ptr<GrFragmentProcessor> MakeChildFP(GrProcessorTestData*);
|
|||||||
* kAlpha_8_GrPixelConfig. TestCreate functions are also free to create additional textures using
|
* kAlpha_8_GrPixelConfig. TestCreate functions are also free to create additional textures using
|
||||||
* the GrContext.
|
* the GrContext.
|
||||||
*/
|
*/
|
||||||
struct GrProcessorTestData {
|
class GrProcessorTestData {
|
||||||
GrProcessorTestData(SkRandom* random,
|
public:
|
||||||
GrContext* context,
|
using ProxyInfo = std::tuple<sk_sp<GrTextureProxy>, GrColorType, SkAlphaType>;
|
||||||
const GrRenderTargetContext* renderTargetContext,
|
GrProcessorTestData(SkRandom* random, GrContext* context, int numProxies, const ProxyInfo[]);
|
||||||
sk_sp<GrTextureProxy> proxies[2])
|
|
||||||
: fRandom(random), fRenderTargetContext(renderTargetContext), fContext(context) {
|
|
||||||
SkASSERT(proxies[0] && proxies[1]);
|
|
||||||
fProxies[0] = proxies[0];
|
|
||||||
fProxies[1] = proxies[1];
|
|
||||||
|
|
||||||
fArena = std::unique_ptr<SkArenaAlloc>(new SkArenaAlloc(1000));
|
|
||||||
}
|
|
||||||
|
|
||||||
SkRandom* fRandom;
|
|
||||||
const GrRenderTargetContext* fRenderTargetContext;
|
|
||||||
|
|
||||||
GrContext* context() { return fContext; }
|
GrContext* context() { return fContext; }
|
||||||
GrResourceProvider* resourceProvider();
|
GrResourceProvider* resourceProvider();
|
||||||
GrProxyProvider* proxyProvider();
|
GrProxyProvider* proxyProvider();
|
||||||
const GrCaps* caps();
|
const GrCaps* caps();
|
||||||
sk_sp<GrTextureProxy> textureProxy(int index) { return fProxies[index]; }
|
|
||||||
SkArenaAlloc* allocator() { return fArena.get(); }
|
SkArenaAlloc* allocator() { return fArena.get(); }
|
||||||
|
|
||||||
|
ProxyInfo randomProxy();
|
||||||
|
ProxyInfo randomAlphaOnlyProxy();
|
||||||
|
|
||||||
|
SkRandom* fRandom;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GrContext* fContext;
|
GrContext* fContext;
|
||||||
sk_sp<GrTextureProxy> fProxies[2];
|
SkTArray<ProxyInfo> fProxies;
|
||||||
|
|
||||||
std::unique_ptr<SkArenaAlloc> fArena;
|
std::unique_ptr<SkArenaAlloc> fArena;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
class GrColorInfo;
|
class GrColorInfo;
|
||||||
class GrColorSpaceXform;
|
class GrColorSpaceXform;
|
||||||
struct GrProcessorTestData;
|
class GrProcessorTestData;
|
||||||
class GrStyle;
|
class GrStyle;
|
||||||
class SkMatrix;
|
class SkMatrix;
|
||||||
class SkPath;
|
class SkPath;
|
||||||
|
@ -61,7 +61,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test(testData) {
|
@test(testData) {
|
||||||
sk_sp<GrTextureProxy> maskProxy = testData->textureProxy(GrProcessorUnitTest::kAlphaTextureIdx);
|
auto [maskProxy, ct, at] = testData->randomAlphaOnlyProxy();
|
||||||
// Make the inner and outer thresholds be in (0, 1) exclusive and be sorted correctly.
|
// Make the inner and outer thresholds be in (0, 1) exclusive and be sorted correctly.
|
||||||
float innerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
|
float innerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
|
||||||
float outerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
|
float outerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
|
||||||
|
@ -208,11 +208,8 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect);
|
|||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
std::unique_ptr<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTestData* d) {
|
std::unique_ptr<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTestData* d) {
|
||||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
|
||||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
static const GrSamplerState::WrapMode kClampClamp[] = {GrSamplerState::WrapMode::kClamp,
|
static const GrSamplerState::WrapMode kClampClamp[] = {GrSamplerState::WrapMode::kClamp,
|
||||||
GrSamplerState::WrapMode::kClamp};
|
GrSamplerState::WrapMode::kClamp};
|
||||||
SkAlphaType alphaType = d->fRandom->nextBool() ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
|
|
||||||
Direction direction = Direction::kX;
|
Direction direction = Direction::kX;
|
||||||
switch (d->fRandom->nextULessThan(3)) {
|
switch (d->fRandom->nextULessThan(3)) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -225,8 +222,8 @@ std::unique_ptr<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTest
|
|||||||
direction = Direction::kXY;
|
direction = Direction::kXY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return GrBicubicEffect::Make(d->textureProxy(texIdx), SkMatrix::I(), kClampClamp, direction,
|
auto [proxy, ct, at] = d->randomProxy();
|
||||||
alphaType);
|
return GrBicubicEffect::Make(proxy, SkMatrix::I(), kClampClamp, direction, at);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -199,9 +199,7 @@ GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc);
|
|||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
|
|
||||||
GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
|
GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
auto [proxy, ct, at] = d->randomProxy();
|
||||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
|
|
||||||
|
|
||||||
GrSamplerState::WrapMode wrapModes[2];
|
GrSamplerState::WrapMode wrapModes[2];
|
||||||
GrTest::TestWrapModes(d->fRandom, wrapModes);
|
GrTest::TestWrapModes(d->fRandom, wrapModes);
|
||||||
@ -209,15 +207,16 @@ GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
|
|||||||
? GrSamplerState::Filter::kBilerp
|
? GrSamplerState::Filter::kBilerp
|
||||||
: GrSamplerState::Filter::kNearest);
|
: GrSamplerState::Filter::kNearest);
|
||||||
|
|
||||||
GrMaskFormat format = kARGB_GrMaskFormat; // init to avoid warning
|
GrMaskFormat format;
|
||||||
switch (d->fRandom->nextULessThan(3)) {
|
switch (ct) {
|
||||||
case 0:
|
case GrColorType::kAlpha_8:
|
||||||
format = kA8_GrMaskFormat;
|
format = kA8_GrMaskFormat;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case GrColorType::kBGR_565:
|
||||||
format = kA565_GrMaskFormat;
|
format = kA565_GrMaskFormat;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case GrColorType::kRGBA_8888:
|
||||||
|
default: // It doesn't really matter that color type and mask format agree.
|
||||||
format = kARGB_GrMaskFormat;
|
format = kARGB_GrMaskFormat;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -287,9 +287,7 @@ GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc);
|
|||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestData* d) {
|
GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
auto [proxy, ct, at] = d->randomAlphaOnlyProxy();
|
||||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
|
|
||||||
|
|
||||||
GrSamplerState::WrapMode wrapModes[2];
|
GrSamplerState::WrapMode wrapModes[2];
|
||||||
GrTest::TestWrapModes(d->fRandom, wrapModes);
|
GrTest::TestWrapModes(d->fRandom, wrapModes);
|
||||||
@ -582,9 +580,7 @@ GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc);
|
|||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData* d) {
|
GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
auto [proxy, ct, at] = d->randomAlphaOnlyProxy();
|
||||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
|
|
||||||
|
|
||||||
GrSamplerState::WrapMode wrapModes[2];
|
GrSamplerState::WrapMode wrapModes[2];
|
||||||
GrTest::TestWrapModes(d->fRandom, wrapModes);
|
GrTest::TestWrapModes(d->fRandom, wrapModes);
|
||||||
@ -906,9 +902,7 @@ GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc);
|
|||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestData* d) {
|
GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
|
auto [proxy, ct, at] = d->randomProxy();
|
||||||
GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
|
|
||||||
|
|
||||||
GrSamplerState::WrapMode wrapModes[2];
|
GrSamplerState::WrapMode wrapModes[2];
|
||||||
GrTest::TestWrapModes(d->fRandom, wrapModes);
|
GrTest::TestWrapModes(d->fRandom, wrapModes);
|
||||||
|
@ -280,9 +280,7 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrGaussianConvolutionFragmentProcessor);
|
|||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
std::unique_ptr<GrFragmentProcessor> GrGaussianConvolutionFragmentProcessor::TestCreate(
|
std::unique_ptr<GrFragmentProcessor> GrGaussianConvolutionFragmentProcessor::TestCreate(
|
||||||
GrProcessorTestData* d) {
|
GrProcessorTestData* d) {
|
||||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
auto [proxy, ct, at] = d->randomProxy();
|
||||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
|
|
||||||
|
|
||||||
int bounds[2];
|
int bounds[2];
|
||||||
int modeIdx = d->fRandom->nextRangeU(0, GrTextureDomain::kModeCount-1);
|
int modeIdx = d->fRandom->nextRangeU(0, GrTextureDomain::kModeCount-1);
|
||||||
@ -301,10 +299,8 @@ std::unique_ptr<GrFragmentProcessor> GrGaussianConvolutionFragmentProcessor::Tes
|
|||||||
int radius = d->fRandom->nextRangeU(1, kMaxKernelRadius);
|
int radius = d->fRandom->nextRangeU(1, kMaxKernelRadius);
|
||||||
float sigma = radius / 3.f;
|
float sigma = radius / 3.f;
|
||||||
|
|
||||||
auto alphaType = static_cast<SkAlphaType>(
|
return GrGaussianConvolutionFragmentProcessor::Make(std::move(proxy), at, dir, radius, sigma,
|
||||||
d->fRandom->nextRangeU(kUnknown_SkAlphaType + 1, kLastEnum_SkAlphaType));
|
static_cast<GrTextureDomain::Mode>(modeIdx),
|
||||||
return GrGaussianConvolutionFragmentProcessor::Make(
|
bounds);
|
||||||
std::move(proxy), alphaType, dir, radius, sigma,
|
|
||||||
static_cast<GrTextureDomain::Mode>(modeIdx), bounds);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -71,7 +71,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test(d) {
|
@test(d) {
|
||||||
sk_sp<GrTextureProxy> proxy = d->textureProxy(0);
|
auto [proxy, ct, at] = d->randomProxy();
|
||||||
const int kMaxWidth = 200;
|
const int kMaxWidth = 200;
|
||||||
const int kMaxHeight = 200;
|
const int kMaxHeight = 200;
|
||||||
const SkScalar kMaxInset = 20.0f;
|
const SkScalar kMaxInset = 20.0f;
|
||||||
|
@ -317,9 +317,7 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect);
|
|||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
std::unique_ptr<GrFragmentProcessor> GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* d) {
|
std::unique_ptr<GrFragmentProcessor> GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* d) {
|
||||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
auto [proxy, ct, at] = d->randomProxy();
|
||||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
|
|
||||||
|
|
||||||
int width = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE);
|
int width = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE);
|
||||||
int height = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE / width);
|
int height = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE / width);
|
||||||
|
@ -85,7 +85,7 @@ GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrRRectShadowGeoProc);
|
|||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
GrGeometryProcessor* GrRRectShadowGeoProc::TestCreate(GrProcessorTestData* d) {
|
GrGeometryProcessor* GrRRectShadowGeoProc::TestCreate(GrProcessorTestData* d) {
|
||||||
sk_sp<GrSurfaceProxy> proxy = d->textureProxy(GrProcessorUnitTest::kAlphaTextureIdx);
|
auto [proxy, ct, at] = d->randomAlphaOnlyProxy();
|
||||||
GrSurfaceOrigin origin = proxy->origin();
|
GrSurfaceOrigin origin = proxy->origin();
|
||||||
const GrSwizzle& swizzle = proxy->textureSwizzle();
|
const GrSwizzle& swizzle = proxy->textureSwizzle();
|
||||||
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
||||||
|
@ -60,8 +60,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test(testData) {
|
@test(testData) {
|
||||||
int texIdx = testData->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
auto [proxy, ct, at] = testData->randomProxy();
|
||||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
GrSamplerState::WrapMode wrapModes[2];
|
GrSamplerState::WrapMode wrapModes[2];
|
||||||
GrTest::TestWrapModes(testData->fRandom, wrapModes);
|
GrTest::TestWrapModes(testData->fRandom, wrapModes);
|
||||||
if (!testData->caps()->npotTextureTileSupport()) {
|
if (!testData->caps()->npotTextureTileSupport()) {
|
||||||
@ -76,7 +75,5 @@ void main() {
|
|||||||
: GrSamplerState::Filter::kNearest);
|
: GrSamplerState::Filter::kNearest);
|
||||||
|
|
||||||
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
|
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
|
||||||
auto alphaType = static_cast<SkAlphaType>(
|
return GrSimpleTextureEffect::Make(std::move(proxy), at, matrix, params);
|
||||||
testData->fRandom->nextRangeU(kUnknown_SkAlphaType + 1, kLastEnum_SkAlphaType));
|
}
|
||||||
return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx),
|
|
||||||
alphaType, matrix, params);}
|
|
||||||
|
@ -607,9 +607,7 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDeviceSpaceTextureDecalFragmentProcessor);
|
|||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceTextureDecalFragmentProcessor::TestCreate(
|
std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceTextureDecalFragmentProcessor::TestCreate(
|
||||||
GrProcessorTestData* d) {
|
GrProcessorTestData* d) {
|
||||||
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
auto [proxy, at, ct] = d->randomProxy();
|
||||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
|
|
||||||
SkIRect subset;
|
SkIRect subset;
|
||||||
subset.fLeft = d->fRandom->nextULessThan(proxy->width() - 1);
|
subset.fLeft = d->fRandom->nextULessThan(proxy->width() - 1);
|
||||||
subset.fRight = d->fRandom->nextRangeU(subset.fLeft, proxy->width());
|
subset.fRight = d->fRandom->nextRangeU(subset.fLeft, proxy->width());
|
||||||
|
@ -111,7 +111,7 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrAlphaThresholdFragmentProcessor);
|
|||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
std::unique_ptr<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::TestCreate(
|
std::unique_ptr<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::TestCreate(
|
||||||
GrProcessorTestData* testData) {
|
GrProcessorTestData* testData) {
|
||||||
sk_sp<GrTextureProxy> maskProxy = testData->textureProxy(GrProcessorUnitTest::kAlphaTextureIdx);
|
auto [maskProxy, ct, at] = testData->randomAlphaOnlyProxy();
|
||||||
// Make the inner and outer thresholds be in (0, 1) exclusive and be sorted correctly.
|
// Make the inner and outer thresholds be in (0, 1) exclusive and be sorted correctly.
|
||||||
float innerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
|
float innerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
|
||||||
float outerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
|
float outerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
|
||||||
|
@ -178,7 +178,7 @@ const GrFragmentProcessor::TextureSampler& GrMagnifierEffect::onTextureSampler(i
|
|||||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
|
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
std::unique_ptr<GrFragmentProcessor> GrMagnifierEffect::TestCreate(GrProcessorTestData* d) {
|
std::unique_ptr<GrFragmentProcessor> GrMagnifierEffect::TestCreate(GrProcessorTestData* d) {
|
||||||
sk_sp<GrTextureProxy> proxy = d->textureProxy(0);
|
auto [proxy, ct, at] = d->randomProxy();
|
||||||
const int kMaxWidth = 200;
|
const int kMaxWidth = 200;
|
||||||
const int kMaxHeight = 200;
|
const int kMaxHeight = 200;
|
||||||
const SkScalar kMaxInset = 20.0f;
|
const SkScalar kMaxInset = 20.0f;
|
||||||
|
@ -72,8 +72,7 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect);
|
|||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate(
|
std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate(
|
||||||
GrProcessorTestData* testData) {
|
GrProcessorTestData* testData) {
|
||||||
int texIdx = testData->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
|
auto [proxy, ct, at] = testData->randomProxy();
|
||||||
: GrProcessorUnitTest::kAlphaTextureIdx;
|
|
||||||
GrSamplerState::WrapMode wrapModes[2];
|
GrSamplerState::WrapMode wrapModes[2];
|
||||||
GrTest::TestWrapModes(testData->fRandom, wrapModes);
|
GrTest::TestWrapModes(testData->fRandom, wrapModes);
|
||||||
if (!testData->caps()->npotTextureTileSupport()) {
|
if (!testData->caps()->npotTextureTileSupport()) {
|
||||||
@ -88,8 +87,6 @@ std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate(
|
|||||||
: GrSamplerState::Filter::kNearest);
|
: GrSamplerState::Filter::kNearest);
|
||||||
|
|
||||||
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
|
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
|
||||||
auto alphaType = static_cast<SkAlphaType>(
|
return GrSimpleTextureEffect::Make(std::move(proxy), at, matrix, params);
|
||||||
testData->fRandom->nextRangeU(kUnknown_SkAlphaType + 1, kLastEnum_SkAlphaType));
|
|
||||||
return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), alphaType, matrix, params);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -257,7 +257,7 @@ void render_fp(GrContext* context, GrRenderTargetContext* rtc, GrFragmentProcess
|
|||||||
bool init_test_textures(GrResourceProvider* resourceProvider,
|
bool init_test_textures(GrResourceProvider* resourceProvider,
|
||||||
GrProxyProvider* proxyProvider,
|
GrProxyProvider* proxyProvider,
|
||||||
SkRandom* random,
|
SkRandom* random,
|
||||||
sk_sp<GrTextureProxy> proxies[2]) {
|
GrProcessorTestData::ProxyInfo proxies[2]) {
|
||||||
static const int kTestTextureSize = 256;
|
static const int kTestTextureSize = 256;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -274,9 +274,12 @@ bool init_test_textures(GrResourceProvider* resourceProvider,
|
|||||||
kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
||||||
SkPixmap pixmap(ii, rgbaData.get(), ii.minRowBytes());
|
SkPixmap pixmap(ii, rgbaData.get(), ii.minRowBytes());
|
||||||
sk_sp<SkImage> img = SkImage::MakeRasterCopy(pixmap);
|
sk_sp<SkImage> img = SkImage::MakeRasterCopy(pixmap);
|
||||||
proxies[0] =
|
auto proxy =
|
||||||
proxyProvider->createTextureProxy(img, 1, SkBudgeted::kYes, SkBackingFit::kExact);
|
proxyProvider->createTextureProxy(img, 1, SkBudgeted::kYes, SkBackingFit::kExact);
|
||||||
proxies[0]->instantiate(resourceProvider);
|
if (!proxy || !proxy->instantiate(resourceProvider)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
proxies[0] = {std::move(proxy), GrColorType::kRGBA_8888, kPremul_SkAlphaType};
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -292,12 +295,15 @@ bool init_test_textures(GrResourceProvider* resourceProvider,
|
|||||||
kAlpha_8_SkColorType, kPremul_SkAlphaType);
|
kAlpha_8_SkColorType, kPremul_SkAlphaType);
|
||||||
SkPixmap pixmap(ii, alphaData.get(), ii.minRowBytes());
|
SkPixmap pixmap(ii, alphaData.get(), ii.minRowBytes());
|
||||||
sk_sp<SkImage> img = SkImage::MakeRasterCopy(pixmap);
|
sk_sp<SkImage> img = SkImage::MakeRasterCopy(pixmap);
|
||||||
proxies[1] =
|
auto proxy =
|
||||||
proxyProvider->createTextureProxy(img, 1, SkBudgeted::kYes, SkBackingFit::kExact);
|
proxyProvider->createTextureProxy(img, 1, SkBudgeted::kYes, SkBackingFit::kExact);
|
||||||
proxies[1]->instantiate(resourceProvider);
|
if (!proxy || !proxy->instantiate(resourceProvider)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
proxies[1] = {std::move(proxy), GrColorType::kAlpha_8, kPremul_SkAlphaType};
|
||||||
}
|
}
|
||||||
|
|
||||||
return proxies[0] && proxies[1];
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a texture of premul colors used as the output of the fragment processor that precedes
|
// Creates a texture of premul colors used as the output of the fragment processor that precedes
|
||||||
@ -427,12 +433,12 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
|
|||||||
auto rtc = context->priv().makeDeferredRenderTargetContext(
|
auto rtc = context->priv().makeDeferredRenderTargetContext(
|
||||||
SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr);
|
SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr);
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxies[2];
|
GrProcessorTestData::ProxyInfo proxies[2];
|
||||||
if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) {
|
if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) {
|
||||||
ERRORF(reporter, "Could not create test textures");
|
ERRORF(reporter, "Could not create test textures");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GrProcessorTestData testData(&random, context, rtc.get(), proxies);
|
GrProcessorTestData testData(&random, context, 2, proxies);
|
||||||
|
|
||||||
// Coverage optimization uses three frames with a linearly transformed input texture. The first
|
// Coverage optimization uses three frames with a linearly transformed input texture. The first
|
||||||
// frame has no offset, second frames add .2 and .4, which should then be present as a fixed
|
// frame has no offset, second frames add .2 and .4, which should then be present as a fixed
|
||||||
@ -664,12 +670,12 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) {
|
|||||||
auto rtc = context->priv().makeDeferredRenderTargetContext(
|
auto rtc = context->priv().makeDeferredRenderTargetContext(
|
||||||
SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr);
|
SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr);
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxies[2];
|
GrProcessorTestData::ProxyInfo proxies[2];
|
||||||
if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) {
|
if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) {
|
||||||
ERRORF(reporter, "Could not create test textures");
|
ERRORF(reporter, "Could not create test textures");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GrProcessorTestData testData(&random, context, rtc.get(), proxies);
|
GrProcessorTestData testData(&random, context, 2, proxies);
|
||||||
|
|
||||||
auto inputTexture = make_input_texture(proxyProvider, kRenderSize, kRenderSize, 0.0f);
|
auto inputTexture = make_input_texture(proxyProvider, kRenderSize, kRenderSize, 0.0f);
|
||||||
std::unique_ptr<GrColor[]> readData1(new GrColor[kRenderSize * kRenderSize]);
|
std::unique_ptr<GrColor[]> readData1(new GrColor[kRenderSize * kRenderSize]);
|
||||||
|
@ -260,7 +260,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
|
|||||||
GrDrawingManager* drawingManager = context->priv().drawingManager();
|
GrDrawingManager* drawingManager = context->priv().drawingManager();
|
||||||
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxies[2];
|
GrProcessorTestData::ProxyInfo proxies[2];
|
||||||
|
|
||||||
// setup dummy textures
|
// setup dummy textures
|
||||||
GrMipMapped mipMapped = GrMipMapped(context->priv().caps()->mipMapSupport());
|
GrMipMapped mipMapped = GrMipMapped(context->priv().caps()->mipMapSupport());
|
||||||
@ -272,10 +272,13 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
|
|||||||
const GrBackendFormat format =
|
const GrBackendFormat format =
|
||||||
context->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
|
context->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
|
||||||
GrRenderable::kYes);
|
GrRenderable::kYes);
|
||||||
proxies[0] = proxyProvider->createProxy(format, dummyDesc, GrRenderable::kYes, 1,
|
proxies[0] = {proxyProvider->createProxy(format, dummyDesc, GrRenderable::kYes, 1,
|
||||||
kBottomLeft_GrSurfaceOrigin, mipMapped,
|
kBottomLeft_GrSurfaceOrigin, mipMapped,
|
||||||
SkBackingFit::kExact, SkBudgeted::kNo,
|
SkBackingFit::kExact, SkBudgeted::kNo,
|
||||||
GrProtected::kNo, GrInternalSurfaceFlags::kNone);
|
GrProtected::kNo, GrInternalSurfaceFlags::kNone),
|
||||||
|
GrColorType::kRGBA_8888,
|
||||||
|
kPremul_SkAlphaType
|
||||||
|
};
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
GrSurfaceDesc dummyDesc;
|
GrSurfaceDesc dummyDesc;
|
||||||
@ -285,13 +288,16 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
|
|||||||
const GrBackendFormat format =
|
const GrBackendFormat format =
|
||||||
context->priv().caps()->getDefaultBackendFormat(GrColorType::kAlpha_8,
|
context->priv().caps()->getDefaultBackendFormat(GrColorType::kAlpha_8,
|
||||||
GrRenderable::kNo);
|
GrRenderable::kNo);
|
||||||
proxies[1] = proxyProvider->createProxy(format, dummyDesc, GrRenderable::kNo, 1,
|
proxies[1] = {proxyProvider->createProxy(format, dummyDesc, GrRenderable::kNo, 1,
|
||||||
kTopLeft_GrSurfaceOrigin, mipMapped,
|
kTopLeft_GrSurfaceOrigin, mipMapped,
|
||||||
SkBackingFit::kExact, SkBudgeted::kNo,
|
SkBackingFit::kExact, SkBudgeted::kNo,
|
||||||
GrProtected::kNo, GrInternalSurfaceFlags::kNone);
|
GrProtected::kNo, GrInternalSurfaceFlags::kNone),
|
||||||
|
GrColorType::kAlpha_8,
|
||||||
|
kPremul_SkAlphaType
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!proxies[0] || !proxies[1]) {
|
if (!std::get<0>(proxies[0]) || !std::get<0>(proxies[1])) {
|
||||||
SkDebugf("Could not allocate dummy textures");
|
SkDebugf("Could not allocate dummy textures");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -308,7 +314,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrPaint paint;
|
GrPaint paint;
|
||||||
GrProcessorTestData ptd(&random, context, renderTargetContext.get(), proxies);
|
GrProcessorTestData ptd(&random, context, 2, proxies);
|
||||||
set_random_color_coverage_stages(&paint, &ptd, maxStages, maxLevels);
|
set_random_color_coverage_stages(&paint, &ptd, maxStages, maxLevels);
|
||||||
set_random_xpf(&paint, &ptd);
|
set_random_xpf(&paint, &ptd);
|
||||||
GrDrawRandomOp(&random, renderTargetContext.get(), std::move(paint));
|
GrDrawRandomOp(&random, renderTargetContext.get(), std::move(paint));
|
||||||
@ -333,7 +339,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
|
|||||||
for (int i = 0; i < fpFactoryCnt; ++i) {
|
for (int i = 0; i < fpFactoryCnt; ++i) {
|
||||||
// Since FP factories internally randomize, call each 10 times.
|
// Since FP factories internally randomize, call each 10 times.
|
||||||
for (int j = 0; j < 10; ++j) {
|
for (int j = 0; j < 10; ++j) {
|
||||||
GrProcessorTestData ptd(&random, context, renderTargetContext.get(), proxies);
|
GrProcessorTestData ptd(&random, context, 2, proxies);
|
||||||
|
|
||||||
GrPaint paint;
|
GrPaint paint;
|
||||||
paint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
|
paint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
|
||||||
|
Loading…
Reference in New Issue
Block a user