Change device factories to take SkImageInfo instead of SkBitmap::Config
patch from issue 167033002
BUG=skia:
R=reed@google.com
Author: reed@chromium.org
Review URL: https://codereview.chromium.org/168653002
git-svn-id: http://skia.googlecode.com/svn/trunk@13463 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/CanvasStateTest.cpp b/tests/CanvasStateTest.cpp
index 7c441a4..29e67f2 100644
--- a/tests/CanvasStateTest.cpp
+++ b/tests/CanvasStateTest.cpp
@@ -186,8 +186,9 @@
static void test_draw_filters(skiatest::Reporter* reporter) {
TestDrawFilter drawFilter;
- SkBitmapDevice device(SkBitmap::kARGB_8888_Config, 10, 10);
- SkCanvas canvas(&device);
+ SkBitmap bitmap;
+ bitmap.allocN32Pixels(10, 10);
+ SkCanvas canvas(bitmap);
canvas.setDrawFilter(&drawFilter);
@@ -209,8 +210,9 @@
static void error_callback(SkError code, void* ctx) {}
static void test_soft_clips(skiatest::Reporter* reporter) {
- SkBitmapDevice device(SkBitmap::kARGB_8888_Config, 10, 10);
- SkCanvas canvas(&device);
+ SkBitmap bitmap;
+ bitmap.allocN32Pixels(10, 10);
+ SkCanvas canvas(bitmap);
SkRRect roundRect;
roundRect.setOval(SkRect::MakeWH(5, 5));
diff --git a/tests/GpuBitmapCopyTest.cpp b/tests/GpuBitmapCopyTest.cpp
index fb81e2b..08ceff2 100644
--- a/tests/GpuBitmapCopyTest.cpp
+++ b/tests/GpuBitmapCopyTest.cpp
@@ -122,18 +122,32 @@
return;
}
static const Pair gPairs[] = {
- { SkBitmap::kNo_Config, "00" },
- { SkBitmap::kARGB_8888_Config, "01" },
+ // SkGpuDevice can no longer be Create()ed with kNo_Config
+ // (or kUnknown_SkColorType in the new world), hence much of this
+ // test will be skipped, since it was checking that calling
+ // copyTo or deepCopyTo with src or dst set to kUnknown/kNo would
+ // successfully fail.
+ //
+ // If we can declare that you can *never* create a texture with
+ // kUnknown, then perhaps we can remove this entire test...
+ //
+// { SkBitmap::kNo_Config, "00" },
+// { SkBitmap::kARGB_8888_Config, "01" },
+ { SkBitmap::kARGB_8888_Config, "1" },
};
const int W = 20;
const int H = 33;
for (size_t i = 0; i < SK_ARRAY_COUNT(gPairs); i++) {
+ SkImageInfo info = SkImageInfo::Make(W, H,
+ SkBitmapConfigToColorType(gPairs[i].fConfig),
+ kPremul_SkAlphaType);
SkBitmap src, dst;
- SkGpuDevice* device = SkNEW_ARGS(SkGpuDevice, (grContext, gPairs[i].fConfig, W, H));
- SkAutoUnref aur(device);
+ SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(grContext, info, 0));
+ SkASSERT(device.get());
+
src = device->accessBitmap(false);
device->clear(SK_ColorWHITE);
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 59504cf..41af243 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -296,7 +296,9 @@
#if SK_SUPPORT_GPU
DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) {
GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(0));
- SkGpuDevice device(context, SkBitmap::kARGB_8888_Config, 100, 100);
- test_crop_rects(&device, reporter);
+ SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
+ SkImageInfo::MakeN32Premul(100, 100),
+ 0));
+ test_crop_rects(device, reporter);
}
#endif
diff --git a/tests/LayerDrawLooperTest.cpp b/tests/LayerDrawLooperTest.cpp
index 8f8a6b6..68dd5e0 100644
--- a/tests/LayerDrawLooperTest.cpp
+++ b/tests/LayerDrawLooperTest.cpp
@@ -18,9 +18,15 @@
#include "SkXfermode.h"
#include "Test.h"
+static SkBitmap make_bm(int w, int h) {
+ SkBitmap bm;
+ bm.allocN32Pixels(w, h);
+ return bm;
+}
+
class FakeDevice : public SkBitmapDevice {
public:
- FakeDevice() : SkBitmapDevice(SkBitmap::kARGB_8888_Config, 100, 100, false) { }
+ FakeDevice() : SkBitmapDevice(make_bm(100, 100)) { }
virtual void drawRect(const SkDraw& draw, const SkRect& r,
const SkPaint& paint) SK_OVERRIDE {
diff --git a/tests/PremulAlphaRoundTripTest.cpp b/tests/PremulAlphaRoundTripTest.cpp
index 5e8e8bf..488d93e 100644
--- a/tests/PremulAlphaRoundTripTest.cpp
+++ b/tests/PremulAlphaRoundTripTest.cpp
@@ -36,6 +36,8 @@
};
DEF_GPUTEST(PremulAlphaRoundTrip, reporter, factory) {
+ const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256);
+
SkAutoTUnref<SkBaseDevice> device;
for (int dtype = 0; dtype < 2; ++dtype) {
@@ -47,10 +49,7 @@
#endif
for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) {
if (0 == dtype) {
- device.reset(new SkBitmapDevice(SkBitmap::kARGB_8888_Config,
- 256,
- 256,
- false));
+ device.reset(SkBitmapDevice::Create(info));
} else {
#if SK_SUPPORT_GPU
GrContextFactory::GLContextType type =
@@ -63,7 +62,7 @@
continue;
}
- device.reset(new SkGpuDevice(context, SkBitmap::kARGB_8888_Config, 256, 256));
+ device.reset(SkGpuDevice::Create(context, info, 0));
#else
continue;
#endif
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 8f1e0d6..d14e989 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -310,8 +310,8 @@
for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) {
SkAutoTUnref<SkBaseDevice> device;
if (0 == dtype) {
- device.reset(new SkBitmapDevice(SkBitmap::kARGB_8888_Config,
- DEV_W, DEV_H, false));
+ SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H);
+ device.reset(SkBitmapDevice::Create(info));
} else {
#if SK_SUPPORT_GPU
GrContextFactory::GLContextType type =