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

Unified Diff: dm/DMUtil.cpp

Issue 32613003: DM: add --serialize (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: no-find-copies Created 7 years, 2 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 | « dm/DMUtil.h ('k') | dm/DMWriteTask.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMUtil.cpp
diff --git a/dm/DMUtil.cpp b/dm/DMUtil.cpp
index dc652ebdbed55176db5c5d6f7aa066db3e138918..a227ca85841afe9e9c69352cb5dac205359a7e40 100644
--- a/dm/DMUtil.cpp
+++ b/dm/DMUtil.cpp
@@ -1,19 +1,21 @@
#include "DMUtil.h"
+#include "SkPicture.h"
+
namespace DM {
-SkString underJoin(const char* a, const char* b) {
+SkString UnderJoin(const char* a, const char* b) {
SkString s;
s.appendf("%s_%s", a, b);
return s;
}
-SkString png(SkString s) {
+SkString Png(SkString s) {
s.appendf(".png");
return s;
}
-bool meetsExpectations(const skiagm::Expectations& expectations, const SkBitmap bitmap) {
+bool MeetsExpectations(const skiagm::Expectations& expectations, const SkBitmap bitmap) {
if (expectations.ignoreFailure() || expectations.empty()) {
return true;
}
@@ -21,4 +23,33 @@ bool meetsExpectations(const skiagm::Expectations& expectations, const SkBitmap
return expectations.match(digest);
}
+void RecordPicture(skiagm::GM* gm, SkPicture* picture) {
+ SkCanvas* canvas = picture->beginRecording(SkScalarCeilToInt(gm->width()),
+ SkScalarCeilToInt(gm->height()),
+ 0 /*flags*/);
+ canvas->concat(gm->getInitialTransform());
+ gm->draw(canvas);
+ canvas->flush();
+ picture->endRecording();
+}
+
+void SetupBitmap(const SkBitmap::Config config, skiagm::GM* gm, SkBitmap* bitmap) {
+ bitmap->setConfig(config, SkScalarCeilToInt(gm->width()), SkScalarCeilToInt(gm->height()));
+ bitmap->allocPixels();
+ bitmap->eraseColor(0x00000000);
+}
+
+void DrawPicture(SkPicture* picture, SkBitmap* bitmap) {
+ SkASSERT(picture != NULL);
+ SkASSERT(bitmap != NULL);
+ SkCanvas canvas(*bitmap);
+ canvas.drawPicture(*picture);
+ canvas.flush();
+}
+
+bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) {
+ const SkAutoLockPixels lockA(a), lockB(b);
+ return a.getSize() == b.getSize() && 0 == memcmp(a.getPixels(), b.getPixels(), b.getSize());
+}
+
} // namespace DM
« no previous file with comments | « dm/DMUtil.h ('k') | dm/DMWriteTask.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698