aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-03-20 11:03:55 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-20 16:42:44 +0000
commited182d7c9020a0a533ada3e601183f34e4da7504 (patch)
tree1ca8417b2bff4252be8d0acd5dbdef003b68bec5
parentdcf0ab0dc5ba42a3bb8ec034abc5cf5d5f1faf5b (diff)
Remove SkImage::MakeTextureFromPixmap
Slight variation on https://skia-review.googlesource.com/c/7346/, which had to be reverted. This version also changes the non-mip upload path to use a GrTextureProxy. Hopefully this doesn't trigger the same perf regression that we saw last time. BUG=skia: Change-Id: Ic99bdd93904089942fb680c3af9c4c36310074c0 Reviewed-on: https://skia-review.googlesource.com/9892 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
-rw-r--r--include/core/SkImage.h2
-rw-r--r--src/image/SkImage.cpp4
-rw-r--r--src/image/SkImage_Gpu.cpp22
-rw-r--r--tests/ImageTest.cpp49
4 files changed, 7 insertions, 70 deletions
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 7235580481..f50489771e 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -169,8 +169,6 @@ public:
const SkMatrix*, const SkPaint*, BitDepth,
sk_sp<SkColorSpace>);
- static sk_sp<SkImage> MakeTextureFromPixmap(GrContext*, const SkPixmap&, SkBudgeted budgeted);
-
///////////////////////////////////////////////////////////////////////////////////////////////
int width() const { return fWidth; }
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 99b0be161b..6217f4ecda 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -332,10 +332,6 @@ sk_sp<SkImage> SkImage_Base::makeColorSpace(sk_sp<SkColorSpace> target) const {
#if !SK_SUPPORT_GPU
-sk_sp<SkImage> SkImage::MakeTextureFromPixmap(GrContext*, const SkPixmap&, SkBudgeted budgeted) {
- return nullptr;
-}
-
sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&, const GrMipLevel* texels,
int mipLevelCount, SkBudgeted, SkDestinationSurfaceColorMode) {
return nullptr;
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 3cc6e2d4a2..bcd7275279 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -497,20 +497,6 @@ sk_sp<SkImage> SkImage::makeNonTextureImage() const {
return MakeRasterData(info, data, rowBytes);
}
-sk_sp<SkImage> SkImage::MakeTextureFromPixmap(GrContext* ctx, const SkPixmap& pixmap,
- SkBudgeted budgeted) {
- if (!ctx) {
- return nullptr;
- }
- sk_sp<GrTexture> texture(GrUploadPixmapToTexture(ctx, pixmap, budgeted));
- if (!texture) {
- return nullptr;
- }
- return sk_make_sp<SkImage_Gpu>(kNeedNewImageUniqueID,
- pixmap.alphaType(), std::move(texture),
- sk_ref_sp(pixmap.info().colorSpace()), budgeted);
-}
-
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace {
@@ -809,7 +795,13 @@ sk_sp<SkImage> SkImage::MakeFromDeferredTextureImageData(GrContext* context, con
if (mipLevelCount == 1) {
SkPixmap pixmap;
pixmap.reset(info, dti->fMipMapLevelData[0].fPixelData, dti->fMipMapLevelData[0].fRowBytes);
- return SkImage::MakeTextureFromPixmap(context, pixmap, budgeted);
+ sk_sp<GrTextureProxy> proxy(GrUploadPixmapToTextureProxy(context->resourceProvider(),
+ pixmap, budgeted));
+ if (!proxy) {
+ return nullptr;
+ }
+ return sk_make_sp<SkImage_Gpu>(context, kNeedNewImageUniqueID, pixmap.alphaType(),
+ std::move(proxy), std::move(colorSpace), budgeted);
} else {
std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]);
for (int i = 0; i < mipLevelCount; i++) {
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 55f200a3d0..b16426ae25 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -101,13 +101,6 @@ static sk_sp<SkImage> create_data_image() {
return SkImage::MakeRasterData(info, std::move(data), info.minRowBytes());
}
#if SK_SUPPORT_GPU // not gpu-specific but currently only used in GPU tests
-static sk_sp<SkImage> create_image_565() {
- const SkImageInfo info = SkImageInfo::Make(20, 20, kRGB_565_SkColorType, kOpaque_SkAlphaType);
- auto surface(SkSurface::MakeRaster(info));
- draw_image_test_pattern(surface->getCanvas());
- return surface->makeImageSnapshot();
-}
-
static sk_sp<SkImage> create_image_large(int maxTextureSize) {
const SkImageInfo info = SkImageInfo::MakeN32(maxTextureSize + 1, 32, kOpaque_SkAlphaType);
auto surface(SkSurface::MakeRaster(info));
@@ -117,23 +110,6 @@ static sk_sp<SkImage> create_image_large(int maxTextureSize) {
surface->getCanvas()->drawRect(SkRect::MakeXYWH(4000, 2, 28000, 30), paint);
return surface->makeImageSnapshot();
}
-static sk_sp<SkImage> create_image_ct() {
- SkPMColor colors[] = {
- SkPreMultiplyARGB(0xFF, 0xFF, 0xFF, 0x00),
- SkPreMultiplyARGB(0x80, 0x00, 0xA0, 0xFF),
- SkPreMultiplyARGB(0xFF, 0xBB, 0x00, 0xBB)
- };
- sk_sp<SkColorTable> colorTable(new SkColorTable(colors, SK_ARRAY_COUNT(colors)));
- uint8_t data[] = {
- 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 0,
- 0, 1, 2, 1, 0,
- 0, 1, 1, 1, 0,
- 0, 0, 0, 0, 0
- };
- SkImageInfo info = SkImageInfo::Make(5, 5, kIndex_8_SkColorType, kPremul_SkAlphaType);
- return SkImage::MakeRasterCopy(SkPixmap(info, data, 5, colorTable.get()));
-}
static sk_sp<SkImage> create_picture_image() {
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(10, 10);
@@ -913,31 +889,6 @@ static void check_images_same(skiatest::Reporter* reporter, const SkImage* a, co
}
}
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(NewTextureFromPixmap, reporter, ctxInfo) {
- for (auto create : {&create_image,
- &create_image_565,
- &create_image_ct}) {
- sk_sp<SkImage> image((*create)());
- if (!image) {
- ERRORF(reporter, "Could not create image");
- return;
- }
-
- SkPixmap pixmap;
- if (!image->peekPixels(&pixmap)) {
- ERRORF(reporter, "peek failed");
- } else {
- sk_sp<SkImage> texImage(SkImage::MakeTextureFromPixmap(ctxInfo.grContext(), pixmap,
- SkBudgeted::kNo));
- if (!texImage) {
- ERRORF(reporter, "NewTextureFromPixmap failed.");
- } else {
- check_images_same(reporter, image.get(), texImage.get());
- }
- }
- }
-}
-
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredTextureImage, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
sk_gpu_test::TestContext* testContext = ctxInfo.testContext();