aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/gpu/GrBackendTextureImageGenerator.cpp6
-rw-r--r--src/gpu/GrResourceProvider.cpp6
-rw-r--r--src/gpu/GrSurfaceProxy.cpp3
-rw-r--r--src/gpu/GrTexture.cpp1
-rw-r--r--src/gpu/GrTextureProxy.cpp1
-rw-r--r--tests/GrSurfaceTest.cpp130
-rw-r--r--tests/IntTextureTest.cpp3
7 files changed, 82 insertions, 68 deletions
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 712ebb8bb1..ef391c8f0c 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -182,7 +182,11 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
desc.fWidth = info.width();
desc.fHeight = info.height();
desc.fConfig = proxy->config();
- desc.fIsMipMapped = proxy->isMipMapped();
+ // TODO: We should support the case where we can allocate the mips ahead of time then copy
+ // the subregion into the base layer and then let the GPU generate the rest of the mip
+ // levels.
+ SkASSERT(!proxy->isMipMapped());
+ desc.fIsMipMapped = false;
sk_sp<GrSurfaceContext> sContext(context->contextPriv().makeDeferredSurfaceContext(
desc, SkBackingFit::kExact, SkBudgeted::kYes));
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index bf048a014b..8c96c2986b 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -77,7 +77,8 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, Sk
SkDestinationSurfaceColorMode mipColorMode) {
ASSERT_SINGLE_OWNER
- SkASSERT(mipLevelCount >= 1);
+ SkASSERT(mipLevelCount > 1);
+ SkASSERT(desc.fIsMipMapped);
if (this->isAbandoned()) {
return nullptr;
@@ -97,6 +98,7 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, Sk
sk_sp<GrTexture> GrResourceProvider::getExactScratch(const GrSurfaceDesc& desc,
SkBudgeted budgeted, uint32_t flags) {
+ SkASSERT(!desc.fIsMipMapped);
sk_sp<GrTexture> tex(this->refScratchTexture(desc, flags));
if (tex && SkBudgeted::kNo == budgeted) {
tex->resourcePriv().makeUnbudgeted();
@@ -119,6 +121,7 @@ sk_sp<GrTextureProxy> GrResourceProvider::createTextureProxy(const GrSurfaceDesc
SkBudgeted budgeted,
const GrMipLevel& mipLevel) {
ASSERT_SINGLE_OWNER
+ SkASSERT(!desc.fIsMipMapped);
if (this->isAbandoned()) {
return nullptr;
@@ -178,6 +181,7 @@ sk_sp<GrTexture> GrResourceProvider::createApproxTexture(const GrSurfaceDesc& de
uint32_t flags) {
ASSERT_SINGLE_OWNER
SkASSERT(0 == flags || kNoPendingIO_Flag == flags);
+ SkASSERT(!desc.fIsMipMapped);
if (this->isAbandoned()) {
return nullptr;
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index 433c230881..86f9935b7c 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -74,7 +74,8 @@ sk_sp<GrSurface> GrSurfaceProxy::createSurfaceImpl(
desc.fHeight = fHeight;
desc.fConfig = fConfig;
desc.fSampleCnt = sampleCnt;
- desc.fIsMipMapped = isMipMapped;
+ SkASSERT(!isMipMapped);
+ desc.fIsMipMapped = false;
sk_sp<GrSurface> surface;
if (SkBackingFit::kApprox == fFit) {
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index c749fb731b..f13e8505cb 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -88,6 +88,7 @@ void GrTexturePriv::ComputeScratchKey(GrPixelConfig config, int width, int heigh
}
void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* key) {
+ SkASSERT(!desc.fIsMipMapped);
// Note: the fOrigin field is not used in the scratch key
return ComputeScratchKey(desc.fConfig, desc.fWidth, desc.fHeight,
SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag), desc.fSampleCnt,
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp
index 6ce9bb1782..3c2fc33741 100644
--- a/src/gpu/GrTextureProxy.cpp
+++ b/src/gpu/GrTextureProxy.cpp
@@ -19,6 +19,7 @@ GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit fit, S
, fMipColorMode(SkDestinationSurfaceColorMode::kLegacy)
, fCache(nullptr) {
SkASSERT(!srcData); // currently handled in Make()
+ SkASSERT(!fIsMipMapped);
}
GrTextureProxy::GrTextureProxy(sk_sp<GrSurface> surf, GrSurfaceOrigin origin)
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 54b87bf10d..7ead7cd971 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -125,6 +125,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
texels[i].fPixels = pixelData.get();
texels[i].fRowBytes = rowBytes >> i;
}
+ desc.fIsMipMapped = true;
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferredMipMap(resourceProvider,
desc, SkBudgeted::kNo,
texels.get(),
@@ -134,6 +135,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
caps->mipMapSupport() &&
!GrPixelConfigIsSint(desc.fConfig)));
+ desc.fIsMipMapped = false;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
tex = resourceProvider->createTexture(desc, SkBudgeted::kNo);
REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigRenderable(config, false));
@@ -166,78 +168,76 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(InitialTextureClear, reporter, context_info)
continue;
}
desc.fFlags |= rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
- for (bool mipped : {false, true}) {
- desc.fIsMipMapped = mipped;
- for (GrSurfaceOrigin origin :
- {kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) {
- desc.fOrigin = origin;
- for (bool approx : {false, true}) {
- auto resourceProvider = context->resourceProvider();
- // Try directly creating the texture.
- // Do this twice in an attempt to hit the cache on the second time through.
- for (int i = 0; i < 2; ++i) {
- sk_sp<GrTexture> tex;
- if (approx) {
- tex = sk_sp<GrTexture>(
- resourceProvider->createApproxTexture(desc, 0));
- } else {
- tex = resourceProvider->createTexture(desc, SkBudgeted::kYes);
- }
- if (!tex) {
- continue;
- }
- auto proxy = GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
- auto texCtx = context->contextPriv().makeWrappedSurfaceContext(
- std::move(proxy), nullptr);
- SkImageInfo info = SkImageInfo::Make(
- kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- memset(data.get(), 0xAB, kSize * kSize * sizeof(uint32_t));
- if (texCtx->readPixels(info, data.get(), 0, 0, 0)) {
- uint32_t cmp = GrPixelConfigIsOpaque(desc.fConfig) ? 0xFF000000 : 0;
- for (int i = 0; i < kSize * kSize; ++i) {
- if (cmp != data.get()[i]) {
- ERRORF(reporter, "Failed on config %d", desc.fConfig);
- break;
- }
+ desc.fIsMipMapped = false;
+ for (GrSurfaceOrigin origin :
+ {kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) {
+ desc.fOrigin = origin;
+ for (bool approx : {false, true}) {
+ auto resourceProvider = context->resourceProvider();
+ // Try directly creating the texture.
+ // Do this twice in an attempt to hit the cache on the second time through.
+ for (int i = 0; i < 2; ++i) {
+ sk_sp<GrTexture> tex;
+ if (approx) {
+ tex = sk_sp<GrTexture>(
+ resourceProvider->createApproxTexture(desc, 0));
+ } else {
+ tex = resourceProvider->createTexture(desc, SkBudgeted::kYes);
+ }
+ if (!tex) {
+ continue;
+ }
+ auto proxy = GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
+ auto texCtx = context->contextPriv().makeWrappedSurfaceContext(
+ std::move(proxy), nullptr);
+ SkImageInfo info = SkImageInfo::Make(
+ kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
+ memset(data.get(), 0xAB, kSize * kSize * sizeof(uint32_t));
+ if (texCtx->readPixels(info, data.get(), 0, 0, 0)) {
+ uint32_t cmp = GrPixelConfigIsOpaque(desc.fConfig) ? 0xFF000000 : 0;
+ for (int i = 0; i < kSize * kSize; ++i) {
+ if (cmp != data.get()[i]) {
+ ERRORF(reporter, "Failed on config %d", desc.fConfig);
+ break;
}
}
- memset(data.get(), 0xBC, kSize * kSize * sizeof(uint32_t));
- // Here we overwrite the texture so that the second time through we
- // test against recycling without reclearing.
- if (0 == i) {
- texCtx->writePixels(info, data.get(), 0, 0, 0);
- }
}
- context->purgeAllUnlockedResources();
-
- // Try creating the texture as a deferred proxy.
- for (int i = 0; i < 2; ++i) {
- auto surfCtx = context->contextPriv().makeDeferredSurfaceContext(
- desc, approx ? SkBackingFit::kApprox : SkBackingFit::kExact,
- SkBudgeted::kYes);
- if (!surfCtx) {
- continue;
- }
- SkImageInfo info = SkImageInfo::Make(
- kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- memset(data.get(), 0xAB, kSize * kSize * sizeof(uint32_t));
- if (surfCtx->readPixels(info, data.get(), 0, 0, 0)) {
- uint32_t cmp = GrPixelConfigIsOpaque(desc.fConfig) ? 0xFF000000 : 0;
- for (int i = 0; i < kSize * kSize; ++i) {
- if (cmp != data.get()[i]) {
- ERRORF(reporter, "Failed on config %d", desc.fConfig);
- break;
- }
+ memset(data.get(), 0xBC, kSize * kSize * sizeof(uint32_t));
+ // Here we overwrite the texture so that the second time through we
+ // test against recycling without reclearing.
+ if (0 == i) {
+ texCtx->writePixels(info, data.get(), 0, 0, 0);
+ }
+ }
+ context->purgeAllUnlockedResources();
+
+ // Try creating the texture as a deferred proxy.
+ for (int i = 0; i < 2; ++i) {
+ auto surfCtx = context->contextPriv().makeDeferredSurfaceContext(
+ desc, approx ? SkBackingFit::kApprox : SkBackingFit::kExact,
+ SkBudgeted::kYes);
+ if (!surfCtx) {
+ continue;
+ }
+ SkImageInfo info = SkImageInfo::Make(
+ kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
+ memset(data.get(), 0xAB, kSize * kSize * sizeof(uint32_t));
+ if (surfCtx->readPixels(info, data.get(), 0, 0, 0)) {
+ uint32_t cmp = GrPixelConfigIsOpaque(desc.fConfig) ? 0xFF000000 : 0;
+ for (int i = 0; i < kSize * kSize; ++i) {
+ if (cmp != data.get()[i]) {
+ ERRORF(reporter, "Failed on config %d", desc.fConfig);
+ break;
}
}
- // Here we overwrite the texture so that the second time through we
- // test against recycling without reclearing.
- if (0 == i) {
- surfCtx->writePixels(info, data.get(), 0, 0, 0);
- }
}
- context->purgeAllUnlockedResources();
+ // Here we overwrite the texture so that the second time through we
+ // test against recycling without reclearing.
+ if (0 == i) {
+ surfCtx->writePixels(info, data.get(), 0, 0, 0);
+ }
}
+ context->purgeAllUnlockedResources();
}
}
}
diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp
index 3baded97cb..723d6b18b0 100644
--- a/tests/IntTextureTest.cpp
+++ b/tests/IntTextureTest.cpp
@@ -66,6 +66,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
levels[1].fPixels = testData.get();
levels[1].fRowBytes = (kS / 2) * sizeof(int32_t);
+ desc.fIsMipMapped = true;
+
sk_sp<GrTextureProxy> temp(GrSurfaceProxy::MakeDeferredMipMap(context->resourceProvider(),
desc,
SkBudgeted::kYes,
@@ -73,6 +75,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, !temp);
}
+ desc.fIsMipMapped = false;
// Test that we can create an integer texture.
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(context->resourceProvider(),
desc, SkBudgeted::kYes,