aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-16 00:59:25 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-16 00:59:25 +0000
commit15a140599942f70e47380e3f700a825c7cece3b4 (patch)
tree58bd83fb723b2766d078c93eb947bedf055f391a /tests
parenta3b532743dbb1d54a4c17a2574083ef93c949d50 (diff)
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
Diffstat (limited to 'tests')
-rw-r--r--tests/CanvasStateTest.cpp10
-rw-r--r--tests/GpuBitmapCopyTest.cpp22
-rw-r--r--tests/ImageFilterTest.cpp6
-rw-r--r--tests/LayerDrawLooperTest.cpp8
-rw-r--r--tests/PremulAlphaRoundTripTest.cpp9
-rw-r--r--tests/ReadPixelsTest.cpp4
6 files changed, 41 insertions, 18 deletions
diff --git a/tests/CanvasStateTest.cpp b/tests/CanvasStateTest.cpp
index 7c441a40fe..29e67f2e14 100644
--- a/tests/CanvasStateTest.cpp
+++ b/tests/CanvasStateTest.cpp
@@ -186,8 +186,9 @@ public:
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 test_draw_filters(skiatest::Reporter* reporter) {
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 fb81e2b74c..08ceff23fb 100644
--- a/tests/GpuBitmapCopyTest.cpp
+++ b/tests/GpuBitmapCopyTest.cpp
@@ -122,18 +122,32 @@ DEF_GPUTEST(GpuBitmapCopy, reporter, factory) {
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 59504cf702..41af243782 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -296,7 +296,9 @@ DEF_TEST(ImageFilterMatrixTest, reporter) {
#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 8f8a6b6eb0..68dd5e06e7 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 5e8e8bf1dd..488d93e19d 100644
--- a/tests/PremulAlphaRoundTripTest.cpp
+++ b/tests/PremulAlphaRoundTripTest.cpp
@@ -36,6 +36,8 @@ static const SkCanvas::Config8888 gUnpremulConfigs[] = {
};
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 @@ DEF_GPUTEST(PremulAlphaRoundTrip, reporter, factory) {
#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 @@ DEF_GPUTEST(PremulAlphaRoundTrip, reporter, factory) {
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 8f1e0d6a3a..d14e989512 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -310,8 +310,8 @@ DEF_GPUTEST(ReadPixels, reporter, factory) {
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 =