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); - static sk_sp 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_Base::makeColorSpace(sk_sp target) const { #if !SK_SUPPORT_GPU -sk_sp SkImage::MakeTextureFromPixmap(GrContext*, const SkPixmap&, SkBudgeted budgeted) { - return nullptr; -} - sk_sp 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::makeNonTextureImage() const { return MakeRasterData(info, data, rowBytes); } -sk_sp SkImage::MakeTextureFromPixmap(GrContext* ctx, const SkPixmap& pixmap, - SkBudgeted budgeted) { - if (!ctx) { - return nullptr; - } - sk_sp texture(GrUploadPixmapToTexture(ctx, pixmap, budgeted)); - if (!texture) { - return nullptr; - } - return sk_make_sp(kNeedNewImageUniqueID, - pixmap.alphaType(), std::move(texture), - sk_ref_sp(pixmap.info().colorSpace()), budgeted); -} - /////////////////////////////////////////////////////////////////////////////////////////////////// namespace { @@ -809,7 +795,13 @@ sk_sp 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 proxy(GrUploadPixmapToTextureProxy(context->resourceProvider(), + pixmap, budgeted)); + if (!proxy) { + return nullptr; + } + return sk_make_sp(context, kNeedNewImageUniqueID, pixmap.alphaType(), + std::move(proxy), std::move(colorSpace), budgeted); } else { std::unique_ptr 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 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 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 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 create_image_large(int maxTextureSize) { surface->getCanvas()->drawRect(SkRect::MakeXYWH(4000, 2, 28000, 30), paint); return surface->makeImageSnapshot(); } -static sk_sp create_image_ct() { - SkPMColor colors[] = { - SkPreMultiplyARGB(0xFF, 0xFF, 0xFF, 0x00), - SkPreMultiplyARGB(0x80, 0x00, 0xA0, 0xFF), - SkPreMultiplyARGB(0xFF, 0xBB, 0x00, 0xBB) - }; - sk_sp 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 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 image((*create)()); - if (!image) { - ERRORF(reporter, "Could not create image"); - return; - } - - SkPixmap pixmap; - if (!image->peekPixels(&pixmap)) { - ERRORF(reporter, "peek failed"); - } else { - sk_sp 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();