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

Unified Diff: dm/DMSrcSink.cpp

Issue 1561993003: DM: add a pixel check to serialize (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more on windows Created 4 years, 11 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 | « no previous file | tools/dm_flags.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index fa600ff4eb33bc07ba22c6d0eebe46e435085b52..82962ff6920e873eb54ea6c7751e88368557ef19 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -1084,6 +1084,15 @@ Error ViaRemote::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStr
Error ViaSerialization::draw(
const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
+ // Draw the Src directly as a reference.
+ SkBitmap reference;
+ if (bitmap) {
+ Error err = fSink->draw(src, &reference, nullptr, log);
+ if (!err.isEmpty()) {
+ return err;
+ }
+ }
+
// Record our Src into a picture.
auto size = src.size();
SkPictureRecorder recorder;
@@ -1102,6 +1111,15 @@ Error ViaSerialization::draw(
return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) {
canvas->drawPicture(deserialized);
+ // Check against the reference if we have one.
+ if (bitmap) {
+ if (reference.getSize() != bitmap->getSize()) {
+ return "Serialized and direct have different dimensions.";
+ }
+ if (0 != memcmp(reference.getPixels(), bitmap->getPixels(), reference.getSize())) {
+ return "Serialized and direct have different pixels.";
+ }
+ }
return "";
});
}
« no previous file with comments | « no previous file | tools/dm_flags.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698