aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-20 17:49:04 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-20 17:49:04 +0000
commit3055b700189afdd02486ed8f2279cea1d8897243 (patch)
treea66e6ce6e9717464dd67eb206f76440da9bab059 /tests
parent4eaa6647e70c9404d1c920f674d706ca2d2a76b9 (diff)
Split SkDevice out of SkBitmapDevice
Diffstat (limited to 'tests')
-rw-r--r--tests/CanvasTest.cpp10
-rw-r--r--tests/DeferredCanvasTest.cpp26
-rw-r--r--tests/GradientTest.cpp2
-rw-r--r--tests/LayerDrawLooperTest.cpp9
-rw-r--r--tests/PremulAlphaRoundTripTest.cpp10
-rw-r--r--tests/ReadPixelsTest.cpp5
-rw-r--r--tests/ReadWriteAlphaTest.cpp2
-rw-r--r--tests/TileGridTest.cpp30
-rw-r--r--tests/WritePixelsTest.cpp8
9 files changed, 53 insertions, 49 deletions
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 26896fc425..24c3348d15 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -779,7 +779,7 @@ public:
SkBitmap deferredStore;
createBitmap(&deferredStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
- SkDevice deferredDevice(deferredStore);
+ SkBitmapDevice deferredDevice(deferredStore);
SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(&deferredDevice));
testStep->setAssertMessageFormat(kDeferredDrawAssertMessageFormat);
testStep->draw(deferredCanvas, reporter);
@@ -821,7 +821,7 @@ static void TestProxyCanvasStateConsistency(
SkBitmap indirectStore;
createBitmap(&indirectStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
- SkDevice indirectDevice(indirectStore);
+ SkBitmapDevice indirectDevice(indirectStore);
SkCanvas indirectCanvas(&indirectDevice);
SkProxyCanvas proxyCanvas(&indirectCanvas);
testStep->setAssertMessageFormat(kProxyDrawAssertMessageFormat);
@@ -844,12 +844,12 @@ static void TestNWayCanvasStateConsistency(
SkBitmap indirectStore1;
createBitmap(&indirectStore1, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
- SkDevice indirectDevice1(indirectStore1);
+ SkBitmapDevice indirectDevice1(indirectStore1);
SkCanvas indirectCanvas1(&indirectDevice1);
SkBitmap indirectStore2;
createBitmap(&indirectStore2, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
- SkDevice indirectDevice2(indirectStore2);
+ SkBitmapDevice indirectDevice2(indirectStore2);
SkCanvas indirectCanvas2(&indirectDevice2);
SkISize canvasSize = referenceCanvas.getDeviceSize();
@@ -882,7 +882,7 @@ static void TestOverrideStateConsistency(skiatest::Reporter* reporter,
CanvasTestStep* testStep) {
SkBitmap referenceStore;
createBitmap(&referenceStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
- SkDevice referenceDevice(referenceStore);
+ SkBitmapDevice referenceDevice(referenceStore);
SkCanvas referenceCanvas(&referenceDevice);
testStep->setAssertMessageFormat(kCanvasDrawAssertMessageFormat);
testStep->draw(&referenceCanvas, reporter);
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
index 15474f5bb4..d7ee761bd9 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -33,7 +33,7 @@ static void TestDeferredCanvasBitmapAccess(skiatest::Reporter* reporter) {
SkBitmap store;
create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
- SkDevice device(store);
+ SkBitmapDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->clear(0x00000000);
@@ -259,7 +259,7 @@ static void TestDeferredCanvasFlush(skiatest::Reporter* reporter) {
SkBitmap store;
create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
- SkDevice device(store);
+ SkBitmapDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->clear(0x00000000);
@@ -279,7 +279,7 @@ static void TestDeferredCanvasFreshFrame(skiatest::Reporter* reporter) {
partialRect.setXYWH(SkIntToScalar(0), SkIntToScalar(0),
SkIntToScalar(1), SkIntToScalar(1));
create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
- SkDevice device(store);
+ SkBitmapDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
// verify that frame is intially fresh
@@ -433,9 +433,9 @@ static void TestDeferredCanvasFreshFrame(skiatest::Reporter* reporter) {
}
}
-class MockDevice : public SkDevice {
+class MockDevice : public SkBitmapDevice {
public:
- MockDevice(const SkBitmap& bm) : SkDevice(bm) {
+ MockDevice(const SkBitmap& bm) : SkBitmapDevice(bm) {
fDrawBitmapCallCount = 0;
}
virtual void drawBitmap(const SkDraw&, const SkBitmap&,
@@ -502,7 +502,7 @@ static void TestDeferredCanvasBitmapCaching(skiatest::Reporter* reporter) {
SkBitmap store;
store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
store.allocPixels();
- SkDevice device(store);
+ SkBitmapDevice device(store);
NotificationCounter notificationCounter;
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setNotificationClient(&notificationCounter);
@@ -585,7 +585,7 @@ static void TestDeferredCanvasSkip(skiatest::Reporter* reporter) {
SkBitmap store;
store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
store.allocPixels();
- SkDevice device(store);
+ SkBitmapDevice device(store);
NotificationCounter notificationCounter;
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setNotificationClient(&notificationCounter);
@@ -606,7 +606,7 @@ static void TestDeferredCanvasBitmapShaderNoLeak(skiatest::Reporter* reporter) {
SkBitmap store;
store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
store.allocPixels();
- SkDevice device(store);
+ SkBitmapDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
// test will fail if nbIterations is not in sync with
// BITMAPS_TO_KEEP in SkGPipeWrite.cpp
@@ -652,7 +652,7 @@ static void TestDeferredCanvasBitmapSizeThreshold(skiatest::Reporter* reporter)
// 1 under : should not store the image
{
- SkDevice device(store);
+ SkBitmapDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setBitmapSizeThreshold(39999);
canvas->drawBitmap(sourceImage, 0, 0, NULL);
@@ -662,7 +662,7 @@ static void TestDeferredCanvasBitmapSizeThreshold(skiatest::Reporter* reporter)
// exact value : should store the image
{
- SkDevice device(store);
+ SkBitmapDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setBitmapSizeThreshold(40000);
canvas->drawBitmap(sourceImage, 0, 0, NULL);
@@ -672,7 +672,7 @@ static void TestDeferredCanvasBitmapSizeThreshold(skiatest::Reporter* reporter)
// 1 over : should still store the image
{
- SkDevice device(store);
+ SkBitmapDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setBitmapSizeThreshold(40001);
canvas->drawBitmap(sourceImage, 0, 0, NULL);
@@ -807,11 +807,11 @@ static void TestDeferredCanvasCreateCompatibleDevice(skiatest::Reporter* reporte
SkBitmap store;
store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
store.allocPixels();
- SkDevice device(store);
+ SkBitmapDevice device(store);
NotificationCounter notificationCounter;
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setNotificationClient(&notificationCounter);
- SkAutoTUnref<SkDevice> secondaryDevice(canvas->createCompatibleDevice(
+ SkAutoTUnref<SkBaseDevice> secondaryDevice(canvas->createCompatibleDevice(
SkBitmap::kARGB_8888_Config, 10, 10, device.isOpaque()));
SkCanvas secondaryCanvas(secondaryDevice.get());
SkRect rect = SkRect::MakeWH(5, 5);
diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp
index cf8fbee206..cd66a3ee3c 100644
--- a/tests/GradientTest.cpp
+++ b/tests/GradientTest.cpp
@@ -146,7 +146,7 @@ static void TestConstantGradient(skiatest::Reporter*) {
outBitmap.allocPixels();
SkPaint paint;
paint.setShader(s.get());
- SkDevice device(outBitmap);
+ SkBitmapDevice device(outBitmap);
SkCanvas canvas(&device);
canvas.drawPaint(paint);
SkAutoLockPixels alp(outBitmap);
diff --git a/tests/LayerDrawLooperTest.cpp b/tests/LayerDrawLooperTest.cpp
index daadc86e54..2e4642e6fe 100644
--- a/tests/LayerDrawLooperTest.cpp
+++ b/tests/LayerDrawLooperTest.cpp
@@ -19,17 +19,20 @@
namespace {
-class FakeDevice : public SkDevice {
+class FakeDevice : public SkBitmapDevice {
public:
- FakeDevice() : SkDevice(SkBitmap::kARGB_8888_Config, 100, 100) { }
+ FakeDevice() : SkBitmapDevice(SkBitmap::kARGB_8888_Config, 100, 100, false) { }
virtual void drawRect(const SkDraw& draw, const SkRect& r,
const SkPaint& paint) SK_OVERRIDE {
fLastMatrix = *draw.fMatrix;
- SkDevice::drawRect(draw, r, paint);
+ INHERITED::drawRect(draw, r, paint);
}
SkMatrix fLastMatrix;
+
+private:
+ typedef SkBitmapDevice INHERITED;
};
} // namespace
diff --git a/tests/PremulAlphaRoundTripTest.cpp b/tests/PremulAlphaRoundTripTest.cpp
index 28150d6240..79b32f91cb 100644
--- a/tests/PremulAlphaRoundTripTest.cpp
+++ b/tests/PremulAlphaRoundTripTest.cpp
@@ -41,7 +41,7 @@ static const SkCanvas::Config8888 gUnpremulConfigs[] = {
};
void PremulAlphaRoundTripTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
- SkAutoTUnref<SkDevice> device;
+ SkAutoTUnref<SkBaseDevice> device;
for (int dtype = 0; dtype < 2; ++dtype) {
int glCtxTypeCnt = 1;
@@ -52,10 +52,10 @@ void PremulAlphaRoundTripTest(skiatest::Reporter* reporter, GrContextFactory* fa
#endif
for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) {
if (0 == dtype) {
- device.reset(new SkDevice(SkBitmap::kARGB_8888_Config,
- 256,
- 256,
- false));
+ device.reset(new SkBitmapDevice(SkBitmap::kARGB_8888_Config,
+ 256,
+ 256,
+ false));
} else {
#if SK_SUPPORT_GPU
GrContextFactory::GLContextType type =
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 24f5954efe..9cc10740e8 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -311,9 +311,10 @@ void ReadPixelsTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
}
#endif
for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) {
- SkAutoTUnref<SkDevice> device;
+ SkAutoTUnref<SkBaseDevice> device;
if (0 == dtype) {
- device.reset(new SkDevice(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H, false));
+ device.reset(new SkBitmapDevice(SkBitmap::kARGB_8888_Config,
+ DEV_W, DEV_H, false));
} else {
#if SK_SUPPORT_GPU
GrContextFactory::GLContextType type =
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index 78306693db..8ae936e97b 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -82,7 +82,7 @@ static void ReadWriteAlphaTest(skiatest::Reporter* reporter, GrContextFactory* f
REPORTER_ASSERT(reporter, match);
// Now try writing on the single channel texture
- SkAutoTUnref<SkDevice> device(new SkGpuDevice(context, texture->asRenderTarget()));
+ SkAutoTUnref<SkBaseDevice> device(new SkGpuDevice(context, texture->asRenderTarget()));
SkCanvas canvas(device);
SkPaint paint;
diff --git a/tests/TileGridTest.cpp b/tests/TileGridTest.cpp
index f4a0af8c8b..f64365227a 100644
--- a/tests/TileGridTest.cpp
+++ b/tests/TileGridTest.cpp
@@ -24,7 +24,7 @@ enum Tile {
namespace {
class MockCanvas : public SkCanvas {
public:
- MockCanvas(SkDevice* device) : SkCanvas(device)
+ MockCanvas(SkBaseDevice* device) : SkCanvas(device)
{}
virtual void drawRect(const SkRect& rect, const SkPaint&)
@@ -80,14 +80,14 @@ public:
// Test parts of top-left tile
{
- SkDevice device(store);
+ SkBitmapDevice device(store);
MockCanvas mockCanvas(&device);
picture.draw(&mockCanvas);
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
}
{
- SkDevice device(store);
+ SkBitmapDevice device(store);
MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-7.99f), SkFloatToScalar(-7.99f));
picture.draw(&mockCanvas);
@@ -96,7 +96,7 @@ public:
}
// Corner overlap
{
- SkDevice device(store);
+ SkBitmapDevice device(store);
MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-9.5f), SkFloatToScalar(-9.5f));
picture.draw(&mockCanvas);
@@ -106,7 +106,7 @@ public:
}
// Intersect bottom right tile, but does not overlap rect 2
{
- SkDevice device(store);
+ SkBitmapDevice device(store);
MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-16.0f), SkFloatToScalar(-16.0f));
picture.draw(&mockCanvas);
@@ -115,7 +115,7 @@ public:
}
// Out of bounds queries, snap to border tiles
{
- SkDevice device(store);
+ SkBitmapDevice device(store);
MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(2.0f), SkFloatToScalar(0.0f));
picture.draw(&mockCanvas);
@@ -123,7 +123,7 @@ public:
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
}
{
- SkDevice device(store);
+ SkBitmapDevice device(store);
MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(0.0f), SkFloatToScalar(2.0f));
picture.draw(&mockCanvas);
@@ -131,7 +131,7 @@ public:
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
}
{
- SkDevice device(store);
+ SkBitmapDevice device(store);
MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-22.0f), SkFloatToScalar(-16.0f));
picture.draw(&mockCanvas);
@@ -139,7 +139,7 @@ public:
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
}
{
- SkDevice device(store);
+ SkBitmapDevice device(store);
MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-16.0f), SkFloatToScalar(-22.0f));
picture.draw(&mockCanvas);
@@ -185,7 +185,7 @@ public:
{
// The offset should cancel the top and left borders of the top left tile
// So a look-up at interval 0-10 should be grid aligned,
- SkDevice device(tileBitmap);
+ SkBitmapDevice device(tileBitmap);
MockCanvas mockCanvas(&device);
picture.draw(&mockCanvas);
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
@@ -193,7 +193,7 @@ public:
}
{
// Encroaching border by one pixel
- SkDevice device(moreThanATileBitmap);
+ SkBitmapDevice device(moreThanATileBitmap);
MockCanvas mockCanvas(&device);
picture.draw(&mockCanvas);
REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count());
@@ -204,7 +204,7 @@ public:
// Tile stride is 8 (tileWidth - 2 * border pixels
// so translating by 8, should make query grid-aligned
// with middle tile.
- SkDevice device(tileBitmap);
+ SkBitmapDevice device(tileBitmap);
MockCanvas mockCanvas(&device);
mockCanvas.translate(SkIntToScalar(-8), SkIntToScalar(-8));
picture.draw(&mockCanvas);
@@ -212,7 +212,7 @@ public:
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
}
{
- SkDevice device(tileBitmap);
+ SkBitmapDevice device(tileBitmap);
MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-7.9f), SkFloatToScalar(-7.9f));
picture.draw(&mockCanvas);
@@ -221,7 +221,7 @@ public:
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]);
}
{
- SkDevice device(tileBitmap);
+ SkBitmapDevice device(tileBitmap);
MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-8.1f), SkFloatToScalar(-8.1f));
picture.draw(&mockCanvas);
@@ -233,7 +233,7 @@ public:
// Regression test for crbug.com/234688
// Once the 2x2 device region is inset by margin, it yields an empty
// adjusted region, sitting right on top of the tile boundary.
- SkDevice device(tinyBitmap);
+ SkBitmapDevice device(tinyBitmap);
MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-8.0f), SkFloatToScalar(-8.0f));
picture.draw(&mockCanvas);
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index 202bfd6abf..3db3a2abe3 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -227,7 +227,7 @@ bool checkWrite(skiatest::Reporter* reporter,
const SkBitmap& bitmap,
int writeX, int writeY,
SkCanvas::Config8888 config8888) {
- SkDevice* dev = canvas->getDevice();
+ SkBaseDevice* dev = canvas->getDevice();
if (!dev) {
return false;
}
@@ -305,7 +305,7 @@ static const CanvasConfig gCanvasConfigs[] = {
#endif
};
-SkDevice* createDevice(const CanvasConfig& c, GrContext* grCtx) {
+SkBaseDevice* createDevice(const CanvasConfig& c, GrContext* grCtx) {
switch (c.fDevType) {
case kRaster_DevType: {
SkBitmap bmp;
@@ -320,7 +320,7 @@ SkDevice* createDevice(const CanvasConfig& c, GrContext* grCtx) {
SkAutoLockPixels alp(bmp);
memset(bmp.getPixels(), DEV_PAD, bmp.getSafeSize());
}
- return new SkDevice(bmp);
+ return new SkBitmapDevice(bmp);
}
#if SK_SUPPORT_GPU
case kGpu_BottomLeft_DevType:
@@ -435,7 +435,7 @@ void WritePixelsTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
}
#endif
- SkAutoTUnref<SkDevice> device(createDevice(gCanvasConfigs[i], context));
+ SkAutoTUnref<SkBaseDevice> device(createDevice(gCanvasConfigs[i], context));
SkCanvas canvas(device);
static const SkCanvas::Config8888 gSrcConfigs[] = {