Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Unified Diff: tests/DeferredCanvasTest.cpp

Issue 199733016: implement readPixels and writePixels natively, w/o using the (deprecated) (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | tests/WritePixelsTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/DeferredCanvasTest.cpp
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
index aa360be4010c7fea3edea10c0239a36f564e8a13..0af0c51fede0db8c98dbf063cdf2794a94b583ee 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -26,21 +26,6 @@ class GrContextFactory;
static const int gWidth = 2;
static const int gHeight = 2;
-static void callWritePixels(SkCanvas* canvas, const SkBitmap& src, int x, int y,
- SkCanvas::Config8888 config) {
- SkBitmap bm(src);
- bm.lockPixels();
-
- SkImageInfo info = bm.info();
- sk_tool_utils::config8888_to_imagetypes(config, &info.fColorType, &info.fAlphaType);
-
- if (src.isOpaque()) {
- info.fAlphaType = kOpaque_SkAlphaType;
- }
-
- canvas->writePixels(info, bm.getPixels(), bm.rowBytes(), x, y);
-}
-
static void create(SkBitmap* bm, SkColor color) {
bm->allocN32Pixels(gWidth, gHeight);
bm->eraseColor(color);
@@ -122,7 +107,7 @@ static void TestDeferredCanvasWritePixelsToSurface(skiatest::Reporter* reporter)
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()));
SkBitmap srcBitmap;
- srcBitmap.allocN32Pixels(10, 10);
+ srcBitmap.allocPixels(SkImageInfo::Make(10, 10, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType));
srcBitmap.eraseColor(SK_ColorGREEN);
// Tests below depend on this bitmap being recognized as opaque
@@ -174,7 +159,7 @@ static void TestDeferredCanvasWritePixelsToSurface(skiatest::Reporter* reporter)
REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
- callWritePixels(canvas, srcBitmap, 0, 0, SkCanvas::kRGBA_Unpremul_Config8888);
+ canvas->writePixels(srcBitmap, 0, 0);
REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount);
REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
@@ -191,7 +176,7 @@ static void TestDeferredCanvasWritePixelsToSurface(skiatest::Reporter* reporter)
REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
- callWritePixels(canvas, srcBitmap, 5, 0, SkCanvas::kRGBA_Unpremul_Config8888);
+ canvas->writePixels(srcBitmap, 5, 0);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
REPORTER_ASSERT(reporter, 1 == surface->fRetainCount);
@@ -213,7 +198,7 @@ static void TestDeferredCanvasWritePixelsToSurface(skiatest::Reporter* reporter)
REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
- callWritePixels(canvas, srcBitmap, 0, 0, SkCanvas::kRGBA_Unpremul_Config8888);
+ canvas->writePixels(srcBitmap, 0, 0);
REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount);
REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
@@ -235,7 +220,7 @@ static void TestDeferredCanvasWritePixelsToSurface(skiatest::Reporter* reporter)
REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
- callWritePixels(canvas, srcBitmap, 5, 0, SkCanvas::kRGBA_Unpremul_Config8888);
+ canvas->writePixels(srcBitmap, 5, 0);
REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount); // because of the clear
REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
@@ -259,7 +244,7 @@ static void TestDeferredCanvasWritePixelsToSurface(skiatest::Reporter* reporter)
REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
surface->clearCounts();
- callWritePixels(canvas, srcBitmap, 5, 0, SkCanvas::kRGBA_Unpremul_Config8888);
+ canvas->writePixels(srcBitmap, 5, 0);
REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
REPORTER_ASSERT(reporter, 1 == surface->fRetainCount);
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | tests/WritePixelsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698