aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Phillips <robertphillips@google.com>2019-02-01 23:12:08 +0000
committerSkia Commit-Bot <skia-commit-bot@chromium.org>2019-02-01 23:12:12 +0000
commit5b1813ab81b7c60ccb4a10d021a2afdbb3c17037 (patch)
tree1ab63c77fac4cf048ae09a0b1cffae93ccdf4ccf
parentdbb1fe52480bc0f45c57445017f7e2387562ee94 (diff)
downloadplatform_external_skqp-5b1813ab81b7c60ccb4a10d021a2afdbb3c17037.tar.gz
platform_external_skqp-5b1813ab81b7c60ccb4a10d021a2afdbb3c17037.tar.bz2
platform_external_skqp-5b1813ab81b7c60ccb4a10d021a2afdbb3c17037.zip
Revert "Add isTextureable parameter to GrContextThreadSafeProxy::createCharacterization"
This reverts commit 87685ba492a520eaeb2801e28e83d34cfa84ff84. Reason for revert: Macs Original change's description: > Add isTextureable parameter to GrContextThreadSafeProxy::createCharacterization > > Change-Id: I08d263490982a7d5c1e48a5b31acca25405ab09a > Reviewed-on: https://skia-review.googlesource.com/c/188628 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com Change-Id: I6f912f587e823b44c3747937619251d05b610fea No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/188860 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r--include/gpu/GrContextThreadSafeProxy.h5
-rw-r--r--src/gpu/GrBackendSurface.cpp7
-rw-r--r--src/gpu/GrContextThreadSafeProxy.cpp13
-rw-r--r--src/gpu/GrRenderTargetProxy.cpp3
-rw-r--r--tests/DeferredDisplayListTest.cpp164
-rw-r--r--tests/ProxyTest.cpp2
6 files changed, 40 insertions, 154 deletions
diff --git a/include/gpu/GrContextThreadSafeProxy.h b/include/gpu/GrContextThreadSafeProxy.h
index d27c25eec2..2d119387fb 100644
--- a/include/gpu/GrContextThreadSafeProxy.h
+++ b/include/gpu/GrContextThreadSafeProxy.h
@@ -59,16 +59,13 @@ public:
* allocated for mipmaps?
* @param willUseGLFBO0 Will the surface the DDL will be replayed into be backed by GL
* FBO 0. This flag is only valid if using an GL backend.
- * @param isTextureable Will the surface be able to act as a texture?
*/
SkSurfaceCharacterization createCharacterization(
size_t cacheMaxResourceBytes,
const SkImageInfo& ii, const GrBackendFormat& backendFormat,
int sampleCount, GrSurfaceOrigin origin,
const SkSurfaceProps& surfaceProps,
- bool isMipMapped,
- bool willUseGLFBO0 = false,
- bool isTextureable = true);
+ bool isMipMapped, bool willUseGLFBO0 = false);
bool operator==(const GrContextThreadSafeProxy& that) const {
// Each GrContext should only ever have a single thread-safe proxy.
diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp
index 4e6eb2732f..ecb7844793 100644
--- a/src/gpu/GrBackendSurface.cpp
+++ b/src/gpu/GrBackendSurface.cpp
@@ -472,15 +472,14 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width,
int sampleCnt,
int stencilBits,
const GrGLFramebufferInfo& glInfo)
- : fWidth(width)
+ : fIsValid(true)
+ , fWidth(width)
, fHeight(height)
, fSampleCnt(SkTMax(1, sampleCnt))
, fStencilBits(stencilBits)
, fConfig(kUnknown_GrPixelConfig)
, fBackend(GrBackendApi::kOpenGL)
- , fGLInfo(glInfo) {
- fIsValid = SkToBool(glInfo.fFormat); // the glInfo must have a valid format
-}
+ , fGLInfo(glInfo) {}
GrBackendRenderTarget::GrBackendRenderTarget(int width,
int height,
diff --git a/src/gpu/GrContextThreadSafeProxy.cpp b/src/gpu/GrContextThreadSafeProxy.cpp
index 4412c40f7e..b3754e49d8 100644
--- a/src/gpu/GrContextThreadSafeProxy.cpp
+++ b/src/gpu/GrContextThreadSafeProxy.cpp
@@ -36,7 +36,7 @@ SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(
const SkImageInfo& ii, const GrBackendFormat& backendFormat,
int sampleCnt, GrSurfaceOrigin origin,
const SkSurfaceProps& surfaceProps,
- bool isMipMapped, bool willUseGLFBO0, bool isTextureable) {
+ bool isMipMapped, bool willUseGLFBO0) {
if (!backendFormat.isValid()) {
return SkSurfaceCharacterization(); // return an invalid characterization
}
@@ -69,19 +69,16 @@ SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(
FSAAType = fCaps->usesMixedSamples() ? GrFSAAType::kMixedSamples : GrFSAAType::kUnifiedMSAA;
}
- if (willUseGLFBO0 && isTextureable) {
- return SkSurfaceCharacterization(); // return an invalid characterization
- }
-
- if (isTextureable && !fCaps->isConfigTexturable(config)) {
- // Skia doesn't agree that this is textureable.
+ // This surface characterization factory assumes that the resulting characterization is
+ // textureable.
+ if (!fCaps->isConfigTexturable(config)) {
return SkSurfaceCharacterization(); // return an invalid characterization
}
return SkSurfaceCharacterization(sk_ref_sp<GrContextThreadSafeProxy>(this),
cacheMaxResourceBytes, ii,
origin, config, FSAAType, sampleCnt,
- SkSurfaceCharacterization::Textureable(isTextureable),
+ SkSurfaceCharacterization::Textureable(true),
SkSurfaceCharacterization::MipMapped(isMipMapped),
SkSurfaceCharacterization::UsesGLFBO0(willUseGLFBO0),
SkSurfaceCharacterization::VulkanSecondaryCBCompatible(false),
diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp
index 3f7b7e0637..ee32309020 100644
--- a/src/gpu/GrRenderTargetProxy.cpp
+++ b/src/gpu/GrRenderTargetProxy.cpp
@@ -111,8 +111,7 @@ bool GrRenderTargetProxy::refsWrappedObjects() const {
#ifdef SK_DEBUG
void GrRenderTargetProxy::onValidateSurface(const GrSurface* surface) {
- // We do not check that surface->asTexture returns null since, when replaying DDLs we
- // can fulfill a renderTarget-only proxy w/ a textureRenderTarget.
+ SkASSERT(!surface->asTexture());
// Anything that is checked here should be duplicated in GrTextureRenderTargetProxy's version
SkASSERT(surface->asRenderTarget());
diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp
index 1a84a6e6a3..54feddfa22 100644
--- a/tests/DeferredDisplayListTest.cpp
+++ b/tests/DeferredDisplayListTest.cpp
@@ -251,14 +251,12 @@ static GrBackendFormat create_backend_format(GrContext* context,
class SurfaceParameters {
public:
- static const int kNumParams = 11;
+ static const int kNumParams = 9;
static const int kSampleCount = 5;
static const int kMipMipCount = 8;
- static const int kFBO0Count = 9;
- SurfaceParameters(GrBackendApi backend)
- : fBackend(backend)
- , fWidth(64)
+ SurfaceParameters(const GrCaps* caps)
+ : fWidth(64)
, fHeight(64)
, fOrigin(kTopLeft_GrSurfaceOrigin)
, fColorType(kRGBA_8888_SkColorType)
@@ -266,9 +264,7 @@ public:
, fColorSpace(SkColorSpace::MakeSRGB())
, fSampleCount(1)
, fSurfaceProps(0x0, kUnknown_SkPixelGeometry)
- , fShouldCreateMipMaps(true)
- , fUsesGLFBO0(false)
- , fIsTextureable(true) {
+ , fShouldCreateMipMaps(true) {
}
int sampleCount() const { return fSampleCount; }
@@ -276,7 +272,6 @@ public:
void setColorType(SkColorType ct) { fColorType = ct; }
void setColorSpace(sk_sp<SkColorSpace> cs) { fColorSpace = std::move(cs); }
void setConfig(GrPixelConfig config) { fConfig = config; }
- void setTextureable(bool isTextureable) { fIsTextureable = isTextureable; }
// Modify the SurfaceParameters in just one way
void modify(int i) {
@@ -313,15 +308,6 @@ public:
case 8:
fShouldCreateMipMaps = false;
break;
- case 9:
- if (GrBackendApi::kOpenGL == fBackend) {
- fUsesGLFBO0 = true;
- fIsTextureable = false;
- }
- break;
- case 10:
- fIsTextureable = false;
- break;
}
}
@@ -341,8 +327,7 @@ public:
SkSurfaceCharacterization c = context->threadSafeProxy()->createCharacterization(
maxResourceBytes, ii, backendFormat, fSampleCount,
- fOrigin, fSurfaceProps, fShouldCreateMipMaps,
- fUsesGLFBO0, fIsTextureable);
+ fOrigin, fSurfaceProps, fShouldCreateMipMaps);
return c;
}
@@ -362,33 +347,14 @@ public:
}
// Create the surface with the current set of parameters
- sk_sp<SkSurface> make(GrContext* context, GrBackendTexture* backend) const {
+ sk_sp<SkSurface> make(GrContext* context, GrBackendTexture* backend,
+ bool nonTextureable) const {
GrGpu* gpu = context->contextPriv().getGpu();
- GrMipMapped mipmapped = !fIsTextureable
+ GrMipMapped mipmapped = nonTextureable
? GrMipMapped::kNo
: GrMipMapped(fShouldCreateMipMaps);
- if (fUsesGLFBO0) {
- if (GrBackendApi::kOpenGL != context->backend()) {
- return nullptr;
- }
-
- GrGLFramebufferInfo fboInfo;
- fboInfo.fFBOID = 0;
- fboInfo.fFormat = GR_GL_RGBA8;
- static constexpr int kStencilBits = 8;
- GrBackendRenderTarget backendRT(fWidth, fHeight, 1, kStencilBits, fboInfo);
- backendRT.setPixelConfig(fConfig);
-
- if (!backendRT.isValid()) {
- return nullptr;
- }
-
- return SkSurface::MakeFromBackendRenderTarget(context, backendRT, fOrigin,
- fColorType, fColorSpace, &fSurfaceProps);
- }
-
*backend = gpu->createTestingOnlyBackendTexture(nullptr, fWidth, fHeight,
fColorType, true, mipmapped);
if (!backend->isValid() || !gpu->isTestingOnlyBackendTexture(*backend)) {
@@ -396,7 +362,7 @@ public:
}
sk_sp<SkSurface> surface;
- if (!fIsTextureable) {
+ if (nonTextureable) {
// Create a surface w/ the current parameters but make it non-textureable
surface = SkSurface::MakeFromBackendTextureAsRenderTarget(
context, *backend, fOrigin, fSampleCount, fColorType,
@@ -416,17 +382,12 @@ public:
}
void cleanUpBackEnd(GrContext* context, const GrBackendTexture& backend) const {
- if (!backend.isValid()) {
- return;
- }
-
GrGpu* gpu = context->contextPriv().getGpu();
gpu->deleteTestingOnlyBackendTexture(backend);
}
private:
- GrBackendApi fBackend;
int fWidth;
int fHeight;
GrSurfaceOrigin fOrigin;
@@ -436,8 +397,6 @@ private:
int fSampleCount;
SkSurfaceProps fSurfaceProps;
bool fShouldCreateMipMaps;
- bool fUsesGLFBO0;
- bool fIsTextureable;
};
// Test out operator== && operator!=
@@ -445,7 +404,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLOperatorEqTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
for (int i = 0; i < SurfaceParameters::kNumParams; ++i) {
- SurfaceParameters params1(context->backend());
+ SurfaceParameters params1(context->contextPriv().caps());
params1.modify(i);
SkSurfaceCharacterization char1 = params1.createCharacterization(context);
@@ -454,7 +413,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLOperatorEqTest, reporter, ctxInfo) {
}
for (int j = 0; j < SurfaceParameters::kNumParams; ++j) {
- SurfaceParameters params2(context->backend());
+ SurfaceParameters params2(context->contextPriv().caps());
params2.modify(j);
SkSurfaceCharacterization char2 = params2.createCharacterization(context);
@@ -472,7 +431,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLOperatorEqTest, reporter, ctxInfo) {
}
{
- SurfaceParameters params(context->backend());
+ SurfaceParameters params(context->contextPriv().caps());
SkSurfaceCharacterization valid = params.createCharacterization(context);
SkASSERT(valid.isValid());
@@ -502,14 +461,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSurfaceCharacterizationTest, reporter, ctx
// First, create a DDL using the stock SkSurface parameters
{
- SurfaceParameters params(context->backend());
+ SurfaceParameters params(context->contextPriv().caps());
ddl = params.createDDL(context);
SkAssertResult(ddl);
// The DDL should draw into an SkSurface created with the same parameters
GrBackendTexture backend;
- sk_sp<SkSurface> s = params.make(context, &backend);
+ sk_sp<SkSurface> s = params.make(context, &backend, false);
if (!s) {
return;
}
@@ -524,11 +483,11 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSurfaceCharacterizationTest, reporter, ctx
// Then, alter each parameter in turn and check that the DDL & surface are incompatible
for (int i = 0; i < SurfaceParameters::kNumParams; ++i) {
- SurfaceParameters params(context->backend());
+ SurfaceParameters params(context->contextPriv().caps());
params.modify(i);
GrBackendTexture backend;
- sk_sp<SkSurface> s = params.make(context, &backend);
+ sk_sp<SkSurface> s = params.make(context, &backend, false);
if (!s) {
continue;
}
@@ -560,13 +519,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSurfaceCharacterizationTest, reporter, ctx
continue;
}
- if (SurfaceParameters::kFBO0Count == i && context->backend() != GrBackendApi::kOpenGL) {
- // FBO0 only affects the surface characterization when using OpenGL
- s = nullptr;
- params.cleanUpBackEnd(context, backend);
- continue;
- }
-
REPORTER_ASSERT(reporter, !s->draw(ddl.get()),
"DDLSurfaceCharacterizationTest failed on parameter: %d\n", i);
@@ -578,10 +530,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSurfaceCharacterizationTest, reporter, ctx
// Next test the compatibility of resource cache parameters
{
- const SurfaceParameters params(context->backend());
+ const SurfaceParameters params(context->contextPriv().caps());
GrBackendTexture backend;
- sk_sp<SkSurface> s = params.make(context, &backend);
+ sk_sp<SkSurface> s = params.make(context, &backend, false);
int maxResourceCount;
size_t maxResourceBytes;
@@ -616,12 +568,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSurfaceCharacterizationTest, reporter, ctx
// Test that the textureability of the DDL characterization can block a DDL draw
{
GrBackendTexture backend;
- SurfaceParameters params(context->backend());
- params.setTextureable(false);
-
- sk_sp<SkSurface> s = params.make(context, &backend);
+ const SurfaceParameters params(context->contextPriv().caps());
+ sk_sp<SkSurface> s = params.make(context, &backend, true);
if (s) {
- REPORTER_ASSERT(reporter, !s->draw(ddl.get())); // bc the DDL was made w/ textureability
+ REPORTER_ASSERT(reporter, !s->draw(ddl.get()));
context->flush();
gpu->testingOnly_flushGpuAndSync();
@@ -641,10 +591,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSurfaceCharacterizationTest, reporter, ctx
// Exercise the createResized method
{
- SurfaceParameters params(context->backend());
+ SurfaceParameters params(context->contextPriv().caps());
GrBackendTexture backend;
- sk_sp<SkSurface> s = params.make(context, &backend);
+ sk_sp<SkSurface> s = params.make(context, &backend, false);
if (!s) {
return;
}
@@ -671,54 +621,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSurfaceCharacterizationTest, reporter, ctx
}
}
-// Test that a DDL created w/o textureability can be replayed into both a textureable and
-// non-textureable destination. Note that DDLSurfaceCharacterizationTest tests that a
-// textureable DDL cannot be played into a non-textureable destination but can be replayed
-// into a textureable destination.
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLNonTextureabilityTest, reporter, ctxInfo) {
- GrContext* context = ctxInfo.grContext();
- GrGpu* gpu = context->contextPriv().getGpu();
-
- // Create a bitmap that we can readback into
- SkImageInfo imageInfo = SkImageInfo::Make(64, 64, kRGBA_8888_SkColorType,
- kPremul_SkAlphaType);
- SkBitmap bitmap;
- bitmap.allocPixels(imageInfo);
-
- for (bool textureability : { true, false }) {
- std::unique_ptr<SkDeferredDisplayList> ddl;
-
- // First, create a DDL w/o textureability. TODO: once we have reusable DDLs, move this
- // outside of the loop.
- {
- SurfaceParameters params(context->backend());
- params.setTextureable(false);
-
- ddl = params.createDDL(context);
- SkAssertResult(ddl);
- }
-
- // Then verify it can draw into either flavor of destination
- SurfaceParameters params(context->backend());
- params.setTextureable(textureability);
-
- GrBackendTexture backend;
- sk_sp<SkSurface> s = params.make(context, &backend);
- if (!s) {
- params.cleanUpBackEnd(context, backend);
- continue;
- }
-
- REPORTER_ASSERT(reporter, s->draw(ddl.get()));
- s->readPixels(imageInfo, bitmap.getPixels(), bitmap.rowBytes(), 0, 0);
- context->flush();
- gpu->testingOnly_flushGpuAndSync();
- s = nullptr;
- params.cleanUpBackEnd(context, backend);
- }
-
-}
-
////////////////////////////////////////////////////////////////////////////////
// This tests the SkSurface::MakeRenderTarget variant that takes an SkSurfaceCharacterization.
// In particular, the SkSurface and the SkSurfaceCharacterization should always be compatible.
@@ -726,14 +628,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLMakeRenderTargetTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
for (int i = 0; i < SurfaceParameters::kNumParams; ++i) {
- SurfaceParameters params(context->backend());
+ SurfaceParameters params(context->contextPriv().caps());
params.modify(i);
SkSurfaceCharacterization c = params.createCharacterization(context);
GrBackendTexture backend;
if (!c.isValid()) {
- sk_sp<SkSurface> tmp = params.make(context, &backend);
+ sk_sp<SkSurface> tmp = params.make(context, &backend, false);
// If we couldn't characterize the surface we shouldn't be able to create it either
REPORTER_ASSERT(reporter, !tmp);
@@ -744,7 +646,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLMakeRenderTargetTest, reporter, ctxInfo) {
continue;
}
- sk_sp<SkSurface> s = params.make(context, &backend);
+ sk_sp<SkSurface> s = params.make(context, &backend, false);
if (!s) {
REPORTER_ASSERT(reporter, !c.isValid());
continue;
@@ -752,12 +654,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLMakeRenderTargetTest, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, c.isValid());
- if (SurfaceParameters::kFBO0Count == i) {
- // MakeRenderTarget doesn't support FBO0
- params.cleanUpBackEnd(context, backend);
- continue;
- }
-
s = SkSurface::MakeRenderTarget(context, c, SkBudgeted::kYes);
REPORTER_ASSERT(reporter, s);
@@ -792,10 +688,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) {
return;
}
- SurfaceParameters params(context->backend());
+ SurfaceParameters params(context->contextPriv().caps());
GrBackendTexture backend;
- sk_sp<SkSurface> s = params.make(context, &backend);
+ sk_sp<SkSurface> s = params.make(context, &backend, false);
if (!s) {
gpu->deleteTestingOnlyBackendTexture(backendTex);
return;
@@ -1021,7 +917,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(DDLCompatibilityTest, reporter, ctxInfo) {
for (int config = 0; config < kPrivateConfig1_GrPixelConfig; ++config) {
GrPixelConfig pixelConfig = static_cast<GrPixelConfig>(config);
- SurfaceParameters params(context->backend());
+ SurfaceParameters params(context->contextPriv().caps());
params.setColorType(colorType);
params.setConfig(pixelConfig);
params.setColorSpace(nullptr);
@@ -1046,7 +942,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(DDLCompatibilityTest, reporter, ctxInfo) {
continue;
}
- sk_sp<SkSurface> s = params.make(context, &backend);
+ sk_sp<SkSurface> s = params.make(context, &backend, false);
REPORTER_ASSERT(reporter, s);
if (!s) {
s = nullptr;
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 8c351b352f..7419feec14 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -20,7 +20,6 @@
#include "GrTexture.h"
#include "GrTextureProxy.h"
#include "SkGr.h"
-#include "gl/GrGLDefines.h"
// Check that the surface proxy's member vars are set as expected
static void check_surface(skiatest::Reporter* reporter,
@@ -252,7 +251,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
if (GrBackendApi::kOpenGL == ctxInfo.backend()) {
GrGLFramebufferInfo fboInfo;
fboInfo.fFBOID = 0;
- fboInfo.fFormat = GR_GL_RGBA8;
static constexpr int kStencilBits = 8;
GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples,
kStencilBits, fboInfo);