Remove MakeCrossContextFromEncoded, unused argument from ...FromPixmap
Change-Id: I962e923a4994eb549a9c1002323f33d05b936b84
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/234912
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 79843c0..acd9f6a 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -30,6 +30,9 @@
* Add SkCodec::SelectionPolicy for distinguishing between decoding a still image
or an image sequence for a container format that has both (e.g. HEIF).
-* SkImage::makeTextureImage no longer takes an SkColorSpace parameter. It was unused.
+* SkImage::makeTextureImage and SkImage::MakeCrossContextFromPixmap no longer take an
+ SkColorSpace parameter. It was unused.
* SkImage::reinterpretColorSpace - to reinterpret image contents in a new color space.
+
+* Removed SkImage::MakeCrossContextFromEncoded.
diff --git a/docs/examples/Image_MakeCrossContextFromEncoded.cpp b/docs/examples/Image_MakeCrossContextFromEncoded.cpp
deleted file mode 100644
index 871950b..0000000
--- a/docs/examples/Image_MakeCrossContextFromEncoded.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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 "tools/fiddle/examples.h"
-// HASH=069c7b116479e3ca46f953f07dcbdd36
-REG_FIDDLE(Image_MakeCrossContextFromEncoded, 256, 64, false, 4) {
-void draw(SkCanvas* canvas) {
- GrContext* context = canvas->getGrContext();
- sk_sp<SkData> encodedData = image->encodeToData(SkEncodedImageFormat::kJPEG, 100);
- sk_sp<SkImage> image = SkImage::MakeCrossContextFromEncoded(context,
- encodedData, false, nullptr);
- canvas->drawImage(image, 0, 0);
-}
-} // END FIDDLE
diff --git a/docs/examples/Image_MakeCrossContextFromPixmap.cpp b/docs/examples/Image_MakeCrossContextFromPixmap.cpp
index 09c3389..846e0b7 100644
--- a/docs/examples/Image_MakeCrossContextFromPixmap.cpp
+++ b/docs/examples/Image_MakeCrossContextFromPixmap.cpp
@@ -7,8 +7,7 @@
GrContext* context = canvas->getGrContext();
SkPixmap pixmap;
if (source.peekPixels(&pixmap)) {
- sk_sp<SkImage> image = SkImage::MakeCrossContextFromPixmap(context, pixmap,
- false, nullptr);
+ sk_sp<SkImage> image = SkImage::MakeCrossContextFromPixmap(context, pixmap, false);
canvas->drawImage(image, 0, 0);
}
}
diff --git a/gm/crosscontextimage.cpp b/gm/crosscontextimage.cpp
index dd61c2a..8afbf6d 100644
--- a/gm/crosscontextimage.cpp
+++ b/gm/crosscontextimage.cpp
@@ -23,14 +23,14 @@
class GrRenderTargetContext;
DEF_SIMPLE_GPU_GM_CAN_FAIL(cross_context_image, context, rtc, canvas, errorMsg,
- 5 * 256 + 60, 256 + 128 + 30) {
+ 3 * 256 + 40, 256 + 128 + 30) {
sk_sp<SkData> encodedData = GetResourceAsData("images/mandrill_256.png");
if (!encodedData) {
*errorMsg = "Could not load mandrill_256.png. Did you forget to set the resourcePath?";
return skiagm::DrawResult::kFail;
}
- sk_sp<SkImage> images[5];
+ sk_sp<SkImage> images[3];
images[0] = SkImage::MakeFromEncoded(encodedData);
SkBitmap bmp;
@@ -38,10 +38,8 @@
SkAssertResult(images[0]->asLegacyBitmap(&bmp) &&
bmp.peekPixels(&pixmap));
- images[1] = SkImage::MakeCrossContextFromEncoded(context, encodedData, false, nullptr);
- images[2] = SkImage::MakeCrossContextFromEncoded(context, encodedData, true, nullptr);
- images[3] = SkImage::MakeCrossContextFromPixmap(context, pixmap, false, nullptr);
- images[4] = SkImage::MakeCrossContextFromPixmap(context, pixmap, true, nullptr);
+ images[1] = SkImage::MakeCrossContextFromPixmap(context, pixmap, false);
+ images[2] = SkImage::MakeCrossContextFromPixmap(context, pixmap, true);
canvas->translate(10, 10);
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 34d2f5a..8d31faf 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -315,35 +315,6 @@
TextureReleaseProc textureReleaseProc,
ReleaseContext releaseContext);
- /** Creates SkImage from encoded data. SkImage is uploaded to GPU back-end using context.
-
- Created SkImage is available to other GPU contexts, and is available across thread
- boundaries. All contexts must be in the same GPU share group, or otherwise
- share resources.
-
- When SkImage is no longer referenced, context releases texture memory
- asynchronously.
-
- GrBackendTexture decoded from data is uploaded to match SkSurface created with
- dstColorSpace. SkColorSpace of SkImage is determined by encoded data.
-
- SkImage is returned if format of data is recognized and supported, and if context
- supports moving resources. Recognized formats vary by platform and GPU back-end.
-
- SkImage is returned using MakeFromEncoded() if context is nullptr or does not support
- moving resources between contexts.
-
- @param context GPU context
- @param data SkImage to decode
- @param buildMips create SkImage as mip map if true
- @param dstColorSpace range of colors of matching SkSurface on GPU
- @param limitToMaxTextureSize downscale image to GPU maximum texture size, if necessary
- @return created SkImage, or nullptr
- */
- static sk_sp<SkImage> MakeCrossContextFromEncoded(GrContext* context, sk_sp<SkData> data,
- bool buildMips, SkColorSpace* dstColorSpace,
- bool limitToMaxTextureSize = false);
-
/** Creates SkImage from pixmap. SkImage is uploaded to GPU back-end using context.
Created SkImage is available to other GPU contexts, and is available across thread
@@ -370,9 +341,15 @@
@return created SkImage, or nullptr
*/
static sk_sp<SkImage> MakeCrossContextFromPixmap(GrContext* context, const SkPixmap& pixmap,
- bool buildMips, SkColorSpace* dstColorSpace,
+ bool buildMips,
bool limitToMaxTextureSize = false);
+ static sk_sp<SkImage> MakeCrossContextFromPixmap(GrContext* context, const SkPixmap& pixmap,
+ bool buildMips, SkColorSpace*,
+ bool limitToMaxTextureSize = false) {
+ return MakeCrossContextFromPixmap(context, pixmap, buildMips, limitToMaxTextureSize);
+ }
+
/** Creates SkImage from backendTexture associated with context. backendTexture and
returned SkImage are managed internally, and are released when no longer needed.
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 511af5a..0623ada 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -462,72 +462,8 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
-sk_sp<SkImage> SkImage::MakeCrossContextFromEncoded(GrContext* context, sk_sp<SkData> encoded,
- bool buildMips, SkColorSpace* dstColorSpace,
- bool limitToMaxTextureSize) {
- sk_sp<SkImage> codecImage = SkImage::MakeFromEncoded(std::move(encoded));
- if (!codecImage) {
- return nullptr;
- }
-
- // Some backends or drivers don't support (safely) moving resources between contexts
- if (!context || !context->priv().caps()->crossContextTextureSupport()) {
- return codecImage;
- }
-
- // If non-power-of-two mipmapping isn't supported, ignore the client's request
- if (!context->priv().caps()->mipMapSupport()) {
- buildMips = false;
- }
-
- auto maxTextureSize = context->priv().caps()->maxTextureSize();
- if (limitToMaxTextureSize &&
- (codecImage->width() > maxTextureSize || codecImage->height() > maxTextureSize)) {
- SkAutoPixmapStorage pmap;
- SkImageInfo info = codecImage->imageInfo();
- if (!dstColorSpace) {
- info = info.makeColorSpace(nullptr);
- }
- if (!pmap.tryAlloc(info) || !codecImage->readPixels(pmap, 0, 0, kDisallow_CachingHint)) {
- return nullptr;
- }
- return MakeCrossContextFromPixmap(context, pmap, buildMips, dstColorSpace, true);
- }
-
- // Turn the codec image into a GrTextureProxy
- GrImageTextureMaker maker(context, codecImage.get(), kDisallow_CachingHint);
- GrSamplerState samplerState(
- GrSamplerState::WrapMode::kClamp,
- buildMips ? GrSamplerState::Filter::kMipMap : GrSamplerState::Filter::kBilerp);
- SkScalar scaleAdjust[2] = { 1.0f, 1.0f };
- sk_sp<GrTextureProxy> proxy(maker.refTextureProxyForParams(samplerState, scaleAdjust));
- // Given that we disable mipmaps if non-power-of-two mipmapping isn't supported, we always
- // expect the created texture to be unscaled.
- SkASSERT(scaleAdjust[0] == 1.0f && scaleAdjust[1] == 1.0f);
- if (!proxy) {
- return codecImage;
- }
-
- // Flush any writes or uploads
- context->priv().flushSurface(proxy.get());
- if (!proxy->isInstantiated()) {
- return codecImage;
- }
-
- sk_sp<GrTexture> texture = sk_ref_sp(proxy->peekTexture());
-
- GrGpu* gpu = context->priv().getGpu();
- sk_sp<GrSemaphore> sema = gpu->prepareTextureForCrossContextUsage(texture.get());
-
- auto gen = GrBackendTextureImageGenerator::Make(
- std::move(texture), proxy->origin(), std::move(sema), codecImage->colorType(),
- codecImage->alphaType(), codecImage->refColorSpace());
- return SkImage::MakeFromGenerator(std::move(gen));
-}
-
sk_sp<SkImage> SkImage::MakeCrossContextFromPixmap(GrContext* context,
const SkPixmap& originalPixmap, bool buildMips,
- SkColorSpace* dstColorSpace,
bool limitToMaxTextureSize) {
// Some backends or drivers don't support (safely) moving resources between contexts
if (!context || !context->priv().caps()->crossContextTextureSupport()) {
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 07e756e..68fe6ee 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -1010,19 +1010,6 @@
}
}
-DEF_GPUTEST(SkImage_MakeCrossContextFromEncodedRelease, reporter, options) {
- sk_sp<SkData> data = GetResourceAsData("images/mandrill_128.png");
- if (!data) {
- ERRORF(reporter, "missing resource");
- return;
- }
-
- test_cross_context_image(reporter, options, "SkImage_MakeCrossContextFromEncodedRelease",
- [&data](GrContext* ctx) {
- return SkImage::MakeCrossContextFromEncoded(ctx, data, false, nullptr);
- });
-}
-
DEF_GPUTEST(SkImage_MakeCrossContextFromPixmapRelease, reporter, options) {
SkBitmap bitmap;
SkPixmap pixmap;
@@ -1032,7 +1019,7 @@
}
test_cross_context_image(reporter, options, "SkImage_MakeCrossContextFromPixmapRelease",
[&pixmap](GrContext* ctx) {
- return SkImage::MakeCrossContextFromPixmap(ctx, pixmap, false, nullptr);
+ return SkImage::MakeCrossContextFromPixmap(ctx, pixmap, false);
});
}
@@ -1051,7 +1038,7 @@
continue;
}
- sk_sp<SkImage> image = SkImage::MakeCrossContextFromPixmap(ctx, pixmap, false, nullptr);
+ sk_sp<SkImage> image = SkImage::MakeCrossContextFromPixmap(ctx, pixmap, false);
REPORTER_ASSERT(reporter, image);
sk_sp<GrTextureProxy> proxy = as_IB(image)->asTextureProxyRef(
diff --git a/tools/fiddle/all_examples.cpp b/tools/fiddle/all_examples.cpp
index b7710c2..07cc4c3 100644
--- a/tools/fiddle/all_examples.cpp
+++ b/tools/fiddle/all_examples.cpp
@@ -372,7 +372,6 @@
#include "../../docs/examples/ImageInfo_width.cpp"
#include "../../docs/examples/Image_Filter_Methods.cpp"
#include "../../docs/examples/Image_MakeBackendTextureFromSkImage.cpp"
-#include "../../docs/examples/Image_MakeCrossContextFromEncoded.cpp"
#include "../../docs/examples/Image_MakeCrossContextFromPixmap.cpp"
#include "../../docs/examples/Image_MakeFromAdoptedTexture.cpp"
#include "../../docs/examples/Image_MakeFromBitmap.cpp"
diff --git a/tools/fiddle/documumentation_examples_map.txt b/tools/fiddle/documumentation_examples_map.txt
index fc22d34..a1acd1c 100644
--- a/tools/fiddle/documumentation_examples_map.txt
+++ b/tools/fiddle/documumentation_examples_map.txt
@@ -1208,13 +1208,9 @@
SkImage
static bool MakeBackendTextureFromSkImage(GrContext* context, sk_sp<SkImage> image, GrBackendTexture* backendTexture, BackendTextureReleaseProc* backendTextureReleaseProc);
-[Image_MakeCrossContextFromEncoded]
-SkImage
-static sk_sp<SkImage> MakeCrossContextFromEncoded(GrContext* context, sk_sp<SkData> data, bool buildMips, SkColorSpace* dstColorSpace, bool limitToMaxTextureSize = false);
-
[Image_MakeCrossContextFromPixmap]
SkImage
-static sk_sp<SkImage> MakeCrossContextFromPixmap(GrContext* context, const SkPixmap& pixmap, bool buildMips, SkColorSpace* dstColorSpace, bool limitToMaxTextureSize = false);
+static sk_sp<SkImage> MakeCrossContextFromPixmap(GrContext* context, const SkPixmap& pixmap, bool buildMips, bool limitToMaxTextureSize = false);
[Image_MakeFromAdoptedTexture]
SkImage