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>
This commit is contained in:
Brian Osman 2017-03-20 11:03:55 -04:00 committed by Skia Commit-Bot
parent dcf0ab0dc5
commit ed182d7c90
4 changed files with 7 additions and 70 deletions

View File

@ -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; }

View File

@ -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;

View File

@ -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++) {

View File

@ -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();