Add SkCanvas::writePixels that takes info+pixels directly
add corresponding methods to device (w/ diff name to avoid colliding with exising virtuals)
BUG=skia:
R=bsalomon@google.com, robertphillips@google.com, junov@google.com, junov@chromium.org
Author: reed@google.com
Review URL: https://codereview.chromium.org/180113010
git-svn-id: http://skia.googlecode.com/svn/trunk@13697 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index e2e4a0c..7adcf02 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -11,6 +11,7 @@
#include "SkMathPriv.h"
#include "SkRegion.h"
#include "Test.h"
+#include "sk_tool_utils.h"
#if SK_SUPPORT_GPU
#include "GrContextFactory.h"
@@ -134,16 +135,13 @@
}
static void fillCanvas(SkCanvas* canvas) {
- static SkBitmap bmp;
+ SkBitmap bmp;
if (bmp.isNull()) {
SkDEBUGCODE(bool alloc = ) bmp.allocN32Pixels(DEV_W, DEV_H);
SkASSERT(alloc);
- SkAutoLockPixels alp(bmp);
- intptr_t pixels = reinterpret_cast<intptr_t>(bmp.getPixels());
for (int y = 0; y < DEV_H; ++y) {
for (int x = 0; x < DEV_W; ++x) {
- SkPMColor* pixel = reinterpret_cast<SkPMColor*>(pixels + y * bmp.rowBytes() + x * bmp.bytesPerPixel());
- *pixel = getCanvasColor(x, y);
+ *bmp.getAddr32(x, y) = getCanvasColor(x, y);
}
}
}
@@ -468,7 +466,12 @@
SkBitmap bmp;
REPORTER_ASSERT(reporter, setupBitmap(&bmp, config8888, rect.width(), rect.height(), SkToBool(tightBmp)));
uint32_t idBefore = canvas.getDevice()->accessBitmap(false).getGenerationID();
- canvas.writePixels(bmp, rect.fLeft, rect.fTop, config8888);
+
+ SkColorType ct;
+ SkAlphaType at;
+ sk_tool_utils::config8888_to_imagetypes(config8888, &ct, &at);
+ sk_tool_utils::write_pixels(&canvas, bmp, rect.fLeft, rect.fTop, ct, at);
+
uint32_t idAfter = canvas.getDevice()->accessBitmap(false).getGenerationID();
REPORTER_ASSERT(reporter, checkWrite(reporter, &canvas, bmp, rect.fLeft, rect.fTop, config8888));