Remove SkImage::MakeTextureFromPixmap
Another step towards reducing the number of texture upload paths. BUG=skia: Change-Id: Ica185e7334f52dc9ebf87e21fe6f60589ef87bb3 Reviewed-on: https://skia-review.googlesource.com/7346 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
5b2f579331
commit
8ccbbb455c
@ -175,8 +175,6 @@ public:
|
|||||||
const SkMatrix*, const SkPaint*, BitDepth,
|
const SkMatrix*, const SkPaint*, BitDepth,
|
||||||
sk_sp<SkColorSpace>);
|
sk_sp<SkColorSpace>);
|
||||||
|
|
||||||
static sk_sp<SkImage> MakeTextureFromPixmap(GrContext*, const SkPixmap&, SkBudgeted budgeted);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int width() const { return fWidth; }
|
int width() const { return fWidth; }
|
||||||
|
@ -333,10 +333,6 @@ bool SkImage::isAlphaOnly() const {
|
|||||||
|
|
||||||
#if !SK_SUPPORT_GPU
|
#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,
|
sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&, const GrMipLevel* texels,
|
||||||
int mipLevelCount, SkBudgeted, SkDestinationSurfaceColorMode) {
|
int mipLevelCount, SkBudgeted, SkDestinationSurfaceColorMode) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -354,20 +354,6 @@ sk_sp<SkImage> SkImage::makeNonTextureImage() const {
|
|||||||
return MakeRasterData(info, data, rowBytes);
|
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>(texture->width(), texture->height(), kNeedNewImageUniqueID,
|
|
||||||
pixmap.alphaType(), std::move(texture),
|
|
||||||
sk_ref_sp(pixmap.info().colorSpace()), budgeted);
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -663,21 +649,14 @@ sk_sp<SkImage> SkImage::MakeFromDeferredTextureImageData(GrContext* context, con
|
|||||||
}
|
}
|
||||||
SkImageInfo info = SkImageInfo::Make(dti->fWidth, dti->fHeight,
|
SkImageInfo info = SkImageInfo::Make(dti->fWidth, dti->fHeight,
|
||||||
dti->fColorType, dti->fAlphaType, colorSpace);
|
dti->fColorType, dti->fAlphaType, colorSpace);
|
||||||
if (mipLevelCount == 1) {
|
SkAutoSTArray<16, GrMipLevel> texels(mipLevelCount);
|
||||||
SkPixmap pixmap;
|
for (int i = 0; i < mipLevelCount; i++) {
|
||||||
pixmap.reset(info, dti->fMipMapLevelData[0].fPixelData, dti->fMipMapLevelData[0].fRowBytes);
|
texels[i].fPixels = dti->fMipMapLevelData[i].fPixelData;
|
||||||
return SkImage::MakeTextureFromPixmap(context, pixmap, budgeted);
|
texels[i].fRowBytes = dti->fMipMapLevelData[i].fRowBytes;
|
||||||
} else {
|
|
||||||
std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]);
|
|
||||||
for (int i = 0; i < mipLevelCount; i++) {
|
|
||||||
texels[i].fPixels = dti->fMipMapLevelData[i].fPixelData;
|
|
||||||
texels[i].fRowBytes = dti->fMipMapLevelData[i].fRowBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SkImage::MakeTextureFromMipMap(context, info, texels.get(),
|
|
||||||
mipLevelCount, SkBudgeted::kYes,
|
|
||||||
dti->fColorMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return SkImage::MakeTextureFromMipMap(context, info, texels.get(), mipLevelCount,
|
||||||
|
SkBudgeted::kYes, dti->fColorMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -92,13 +92,6 @@ static sk_sp<SkImage> create_data_image() {
|
|||||||
return SkImage::MakeRasterData(info, std::move(data), info.minRowBytes());
|
return SkImage::MakeRasterData(info, std::move(data), info.minRowBytes());
|
||||||
}
|
}
|
||||||
#if SK_SUPPORT_GPU // not gpu-specific but currently only used in GPU tests
|
#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) {
|
static sk_sp<SkImage> create_image_large(int maxTextureSize) {
|
||||||
const SkImageInfo info = SkImageInfo::MakeN32(maxTextureSize + 1, 32, kOpaque_SkAlphaType);
|
const SkImageInfo info = SkImageInfo::MakeN32(maxTextureSize + 1, 32, kOpaque_SkAlphaType);
|
||||||
auto surface(SkSurface::MakeRaster(info));
|
auto surface(SkSurface::MakeRaster(info));
|
||||||
@ -108,23 +101,6 @@ static sk_sp<SkImage> create_image_large(int maxTextureSize) {
|
|||||||
surface->getCanvas()->drawRect(SkRect::MakeXYWH(4000, 2, 28000, 30), paint);
|
surface->getCanvas()->drawRect(SkRect::MakeXYWH(4000, 2, 28000, 30), paint);
|
||||||
return surface->makeImageSnapshot();
|
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() {
|
static sk_sp<SkImage> create_picture_image() {
|
||||||
SkPictureRecorder recorder;
|
SkPictureRecorder recorder;
|
||||||
SkCanvas* canvas = recorder.beginRecording(10, 10);
|
SkCanvas* canvas = recorder.beginRecording(10, 10);
|
||||||
@ -800,31 +776,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) {
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredTextureImage, reporter, ctxInfo) {
|
||||||
GrContext* context = ctxInfo.grContext();
|
GrContext* context = ctxInfo.grContext();
|
||||||
sk_gpu_test::TestContext* testContext = ctxInfo.testContext();
|
sk_gpu_test::TestContext* testContext = ctxInfo.testContext();
|
||||||
|
Loading…
Reference in New Issue
Block a user