diff options
-rw-r--r-- | include/core/SkImage.h | 4 | ||||
-rw-r--r-- | src/gpu/GrProxyProvider.cpp | 61 | ||||
-rw-r--r-- | src/gpu/GrProxyProvider.h | 13 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 16 | ||||
-rw-r--r-- | src/gpu/SkGr.h | 8 | ||||
-rw-r--r-- | src/image/SkImage.cpp | 12 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 29 | ||||
-rw-r--r-- | tests/GrSurfaceTest.cpp | 19 | ||||
-rw-r--r-- | tests/ResourceCacheTest.cpp | 25 |
9 files changed, 14 insertions, 173 deletions
diff --git a/include/core/SkImage.h b/include/core/SkImage.h index 041e11ec23..e1a43a97c7 100644 --- a/include/core/SkImage.h +++ b/include/core/SkImage.h @@ -572,10 +572,6 @@ private: SkImage(int width, int height, uint32_t uniqueID); friend class SkImage_Base; - static sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&, - const GrMipLevel texels[], int mipLevelCount, - SkBudgeted, SkDestinationSurfaceColorMode); - const int fWidth; const int fHeight; const uint32_t fUniqueID; diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp index dd2a1b7e13..e000dd4979 100644 --- a/src/gpu/GrProxyProvider.cpp +++ b/src/gpu/GrProxyProvider.cpp @@ -244,51 +244,31 @@ sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(sk_sp<SkImage> srcImag return proxy; } -sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy( - const GrSurfaceDesc& desc, SkBudgeted budgeted, - const GrMipLevel texels[], int mipLevelCount, - SkDestinationSurfaceColorMode mipColorMode) { +sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy(const GrSurfaceDesc& desc, + SkBudgeted budgeted) { ASSERT_SINGLE_OWNER if (this->isAbandoned()) { return nullptr; } - if (!mipLevelCount) { - if (texels) { - return nullptr; - } + // SkMipMap doesn't include the base level in the level count so we have to add 1 + int mipCount = SkMipMap::ComputeLevelCount(desc.fWidth, desc.fHeight) + 1; + if (1 == mipCount) { return this->createProxy(desc, SkBackingFit::kExact, budgeted); } - if (!texels) { - return nullptr; - } - if (1 == mipLevelCount) { - return this->createTextureProxy(desc, budgeted, texels[0].fPixels, texels[0].fRowBytes); - } + std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipCount]); -#ifdef SK_DEBUG - // There are only three states we want to be in when uploading data to a mipped surface. - // 1) We have data to upload to all layers - // 2) We are not uploading data to any layers - // 3) We are only uploading data to the base layer - // We check here to make sure we do not have any other state. - bool firstLevelHasData = SkToBool(texels[0].fPixels); - bool allOtherLevelsHaveData = true, allOtherLevelsLackData = true; - for (int i = 1; i < mipLevelCount; ++i) { - if (texels[i].fPixels) { - allOtherLevelsLackData = false; - } else { - allOtherLevelsHaveData = false; - } + // We don't want to upload any texel data + for (int i = 0; i < mipCount; i++) { + texels[i].fPixels = nullptr; + texels[i].fRowBytes = 0; } - SkASSERT((firstLevelHasData && allOtherLevelsHaveData) || allOtherLevelsLackData); -#endif sk_sp<GrTexture> tex(fResourceProvider->createTexture(desc, budgeted, - texels, mipLevelCount, - mipColorMode)); + texels.get(), mipCount, + SkDestinationSurfaceColorMode::kLegacy)); if (!tex) { return nullptr; } @@ -296,23 +276,6 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy( return this->createWrapped(std::move(tex), desc.fOrigin); } -sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy(const GrSurfaceDesc& desc, - SkBudgeted budgeted) { - // SkMipMap doesn't include the base level in the level count so we have to add 1 - int mipCount = SkMipMap::ComputeLevelCount(desc.fWidth, desc.fHeight) + 1; - - std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipCount]); - - // We don't want to upload any texel data - for (int i = 0; i < mipCount; i++) { - texels[i].fPixels = nullptr; - texels[i].fRowBytes = 0; - } - - return this->createMipMapProxy(desc, budgeted, texels.get(), mipCount, - SkDestinationSurfaceColorMode::kLegacy); -} - sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxyFromBitmap(const SkBitmap& bitmap, SkColorSpace* dstColorSpace) { SkDestinationSurfaceColorMode mipColorMode = dstColorSpace diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h index 0147485558..48037584c5 100644 --- a/src/gpu/GrProxyProvider.h +++ b/src/gpu/GrProxyProvider.h @@ -89,19 +89,6 @@ public: SkBackingFit fit); /* - * Create a mipmapped texture proxy with data. - * - * @param desc Description of the texture properties. - * @param budgeted Does the texture count against the resource cache budget? - * @param texels A contiguous array of mipmap levels - * @param mipLevelCount The amount of elements in the texels array - */ - sk_sp<GrTextureProxy> createMipMapProxy(const GrSurfaceDesc&, SkBudgeted, - const GrMipLevel texels[], int mipLevelCount, - SkDestinationSurfaceColorMode mipColorMode = - SkDestinationSurfaceColorMode::kLegacy); - - /* * Create a mipmapped texture proxy without any data. * * Like the call above but there are no texels to upload. A texture proxy is returned that diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 6cb93bdc2f..6359693f6d 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -156,22 +156,6 @@ sk_sp<GrTextureProxy> GrCopyBaseMipMapToTextureProxy(GrContext* ctx, GrTexturePr return proxy; } - -sk_sp<GrTextureProxy> GrUploadMipMapToTextureProxy(GrProxyProvider* proxyProvider, - const SkImageInfo& info, - const GrMipLevel texels[], - int mipLevelCount, - SkDestinationSurfaceColorMode colorMode) { - if (!SkImageInfoIsValid(info, colorMode)) { - return nullptr; - } - - GrSurfaceDesc desc(GrImageInfoToSurfaceDesc(info, *proxyProvider->caps())); - - return proxyProvider->createMipMapProxy(desc, SkBudgeted::kYes, - texels, mipLevelCount, colorMode); -} - sk_sp<GrTextureProxy> GrRefCachedBitmapTextureProxy(GrContext* ctx, const SkBitmap& bitmap, const GrSamplerState& params, diff --git a/src/gpu/SkGr.h b/src/gpu/SkGr.h index ea3221074c..bcefca80a1 100644 --- a/src/gpu/SkGr.h +++ b/src/gpu/SkGr.h @@ -220,14 +220,6 @@ sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxy(GrProxyProvider*, sk_sp<GrTextureProxy> GrCopyBaseMipMapToTextureProxy(GrContext*, GrTextureProxy* baseProxy); -/** - * Creates a new texture populated with the mipmap levels. - */ -sk_sp<GrTextureProxy> GrUploadMipMapToTextureProxy(GrProxyProvider*, const SkImageInfo&, - const GrMipLevel texels[], - int mipLevelCount, - SkDestinationSurfaceColorMode colorMode); - /* * Create a texture proxy from the provided bitmap by wrapping it in an image and calling * GrMakeCachedImageProxy. diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index ad70af7451..2337a36882 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -343,11 +343,6 @@ sk_sp<SkImage> SkImage::makeRasterImage() const { #if !SK_SUPPORT_GPU -sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&, const GrMipLevel texels[], - int mipLevelCount, SkBudgeted, SkDestinationSurfaceColorMode) { - return nullptr; -} - sk_sp<SkImage> SkImage::MakeFromTexture(GrContext* ctx, const GrBackendTexture& tex, GrSurfaceOrigin origin, SkAlphaType at, sk_sp<SkColorSpace> cs, @@ -399,13 +394,6 @@ sk_sp<SkImage> SkImage::makeTextureImage(GrContext*, SkColorSpace* dstColorSpace /////////////////////////////////////////////////////////////////////////////////////////////////// -sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&, const GrMipLevel texels[], - int mipLevelCount, SkBudgeted) { - return nullptr; -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// - bool SkImage_pinAsTexture(const SkImage* image, GrContext* ctx) { SkASSERT(image); SkASSERT(ctx); diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index d14f001caf..efafd6f32f 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -733,35 +733,6 @@ bool SkImage::MakeBackendTextureFromSkImage(GrContext* ctx, /////////////////////////////////////////////////////////////////////////////////////////////////// -sk_sp<SkImage> SkImage::MakeTextureFromMipMap(GrContext* ctx, const SkImageInfo& info, - const GrMipLevel texels[], int mipLevelCount, - SkBudgeted budgeted, - SkDestinationSurfaceColorMode colorMode) { - SkASSERT(mipLevelCount >= 1); - if (!ctx) { - return nullptr; - } - GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider(); - - // For images where the client is passing the mip data we require that all the mip levels have - // valid data. - for (int i = 0; i < mipLevelCount; ++i) { - if (!texels[i].fPixels) { - return nullptr; - } - } - sk_sp<GrTextureProxy> proxy(GrUploadMipMapToTextureProxy(proxyProvider, info, - texels, mipLevelCount, colorMode)); - if (!proxy) { - return nullptr; - } - - SkASSERT(proxy->priv().isExact()); - return sk_make_sp<SkImage_Gpu>(ctx, kNeedNewImageUniqueID, - info.alphaType(), std::move(proxy), - info.refColorSpace(), budgeted); -} - sk_sp<SkImage> SkImage_Gpu::onMakeColorSpace(sk_sp<SkColorSpace> target, SkColorType, SkTransferFunctionBehavior premulBehavior) const { if (SkTransferFunctionBehavior::kRespect == premulBehavior) { diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index 9c4359af2c..1a8072f3b0 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -104,16 +104,6 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) { desc.fWidth = 64; desc.fHeight = 64; - // Enough space for the first mip of our largest pixel config - const size_t pixelBufferSize = desc.fWidth * desc.fHeight * - GrBytesPerPixel(kRGBA_float_GrPixelConfig); - std::unique_ptr<char[]> pixelData(new char[pixelBufferSize]); - memset(pixelData.get(), 0, pixelBufferSize); - - // We re-use the same mip level objects (with updated pointers and rowBytes) for each config - const int levelCount = SkMipMap::ComputeLevelCount(desc.fWidth, desc.fHeight) + 1; - std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[levelCount]); - for (GrPixelConfig config : configs) { for (GrSurfaceOrigin origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) { desc.fFlags = kNone_GrSurfaceFlags; @@ -126,15 +116,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) { REPORTER_ASSERT(reporter, SkToBool(tex) == ict, "config:%d, tex:%d, isConfigTexturable:%d", config, SkToBool(tex), ict); - size_t rowBytes = desc.fWidth * GrBytesPerPixel(desc.fConfig); - for (int i = 0; i < levelCount; ++i) { - texels[i].fPixels = pixelData.get(); - texels[i].fRowBytes = rowBytes >> i; - } - sk_sp<GrTextureProxy> proxy = proxyProvider->createMipMapProxy( - desc, SkBudgeted::kNo, - texels.get(), levelCount); + desc, SkBudgeted::kNo); REPORTER_ASSERT(reporter, SkToBool(proxy.get()) == (caps->isConfigTexturable(desc.fConfig) && caps->mipMapSupport())); diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index 3bd6c4b4e3..f6ff21853b 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -1659,29 +1659,6 @@ static sk_sp<GrTextureProxy> make_mipmap_proxy(GrProxyProvider* proxyProvider, GrSurfaceFlags flags, int width, int height, int sampleCnt) { - SkBitmap bm; - - bm.allocN32Pixels(width, height, true); - bm.eraseColor(SK_ColorBLUE); - - sk_sp<SkMipMap> mipmaps(SkMipMap::Build(bm, SkDestinationSurfaceColorMode::kLegacy, nullptr)); - SkASSERT(mipmaps); - SkASSERT(mipmaps->countLevels() > 1); - - int mipLevelCount = mipmaps->countLevels() + 1; - - std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]); - - texels[0].fPixels = bm.getPixels(); - texels[0].fRowBytes = bm.rowBytes(); - - for (int i = 1; i < mipLevelCount; ++i) { - SkMipMap::Level generatedMipLevel; - mipmaps->getLevel(i - 1, &generatedMipLevel); - texels[i].fPixels = generatedMipLevel.fPixmap.addr(); - texels[i].fRowBytes = generatedMipLevel.fPixmap.rowBytes(); - } - GrSurfaceDesc desc; desc.fFlags = flags; desc.fOrigin = (flags & kRenderTarget_GrSurfaceFlag) ? kBottomLeft_GrSurfaceOrigin @@ -1691,7 +1668,7 @@ static sk_sp<GrTextureProxy> make_mipmap_proxy(GrProxyProvider* proxyProvider, desc.fConfig = kRGBA_8888_GrPixelConfig; desc.fSampleCnt = sampleCnt; - return proxyProvider->createMipMapProxy(desc, SkBudgeted::kYes, texels.get(), mipLevelCount); + return proxyProvider->createMipMapProxy(desc, SkBudgeted::kYes); } // Exercise GrSurface::gpuMemorySize for different combos of MSAA, RT-only, |