Remove (most) usage of MakeTextureFromPixmap
Planning to remove this API entirely, as it's not really needed. There is
one remaining call-site that requires a bigger change, so I want to land
these first.
BUG=skia:
Change-Id: I6c6ae88202291c4896c1ba8f47824596ac8a150f
Reviewed-on: https://skia-review.googlesource.com/7105
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index a1dabc2..3919c24 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -18,8 +18,6 @@
#include "SkDocument.h"
#include "SkGammaColorFilter.h"
#include "SkGraphics.h"
-#include "SkImage_Base.h"
-#include "SkImageEncoder.h"
#include "SkOSFile.h"
#include "SkOSPath.h"
#include "SkPaint.h"
@@ -345,10 +343,6 @@
SkBitmap bm;
bm.allocPixels(offscreenInfo);
renderingCanvas->readPixels(&bm, 0, 0);
- SkPixmap pm;
- bm.peekPixels(&pm);
- sk_sp<SkImage> image(SkImage::MakeTextureFromPixmap(fCurContext, pm,
- SkBudgeted::kNo));
SkCanvas* gpuCanvas = fGpuSurface->getCanvas();
@@ -363,7 +357,7 @@
gammaPaint.setColorFilter(SkGammaColorFilter::Make(1.0f / 2.2f));
}
- gpuCanvas->drawImage(image, 0, 0, &gammaPaint);
+ gpuCanvas->drawBitmap(bm, 0, 0, &gammaPaint);
}
fGpuSurface->prepareForExternalIO();
diff --git a/tests/ApplyGammaTest.cpp b/tests/ApplyGammaTest.cpp
index ec790f5..4f1f828 100644
--- a/tests/ApplyGammaTest.cpp
+++ b/tests/ApplyGammaTest.cpp
@@ -13,7 +13,6 @@
#include "SkCanvas.h"
#include "SkGammaColorFilter.h"
-#include "SkPixmap.h"
#include "SkSurface.h"
#include "SkUtils.h"
@@ -87,7 +86,8 @@
srcPixels.get()[i] = i;
}
- SkPixmap pm(ii, srcPixels.get(), kRowBytes);
+ SkBitmap bm;
+ bm.installPixels(ii, srcPixels.get(), kRowBytes);
SkAutoTMalloc<uint32_t> read(kW * kH);
@@ -96,12 +96,10 @@
for (auto dOrigin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
for (auto gamma : { 1.0f, 1.0f / 1.8f, 1.0f / 2.2f }) {
- sk_sp<SkImage> src(SkImage::MakeTextureFromPixmap(context, pm, SkBudgeted::kNo));
-
sk_sp<SkSurface> dst(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo,
ii, 0, dOrigin, nullptr));
- if (!src || !dst) {
+ if (!dst) {
ERRORF(reporter, "Could not create surfaces for copy surface test.");
continue;
}
@@ -115,7 +113,7 @@
gammaPaint.setBlendMode(SkBlendMode::kSrc);
gammaPaint.setColorFilter(SkGammaColorFilter::Make(gamma));
- dstCanvas->drawImage(src, 0, 0, &gammaPaint);
+ dstCanvas->drawBitmap(bm, 0, 0, &gammaPaint);
dstCanvas->flush();
sk_memset32(read.get(), 0, kW * kH);
diff --git a/tests/DeviceTest.cpp b/tests/DeviceTest.cpp
index 9fb4fa2..dd1a9f2 100644
--- a/tests/DeviceTest.cpp
+++ b/tests/DeviceTest.cpp
@@ -106,9 +106,8 @@
SkASSERT(SkIRect::MakeWH(kWidth, kHeight) == special->subset());
// Create a gpu-backed special image from a gpu-backed SkImage
- SkPixmap pixmap;
- bm.peekPixels(&pixmap);
- image = SkImage::MakeTextureFromPixmap(context, pixmap, SkBudgeted::kNo);
+ sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, bm.info()));
+ image = surface->makeImageSnapshot();
special = DeviceTestingAccess::MakeSpecial(gpuDev.get(), image.get());
SkASSERT(special->isTextureBacked());
SkASSERT(kWidth == special->width());