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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/dm_flags.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "DMSrcSink.h" 8 #include "DMSrcSink.h"
9 #include "SamplePipeControllers.h" 9 #include "SamplePipeControllers.h"
10 #include "SkAndroidCodec.h" 10 #include "SkAndroidCodec.h"
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 : nullptr); 1077 : nullptr);
1078 SkAutoTDelete<SkCanvas> canvas(SkRemote::NewCanvas(cache ? cache : decod er)); 1078 SkAutoTDelete<SkCanvas> canvas(SkRemote::NewCanvas(cache ? cache : decod er));
1079 return src.draw(canvas); 1079 return src.draw(canvas);
1080 }); 1080 });
1081 } 1081 }
1082 1082
1083 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1083 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1084 1084
1085 Error ViaSerialization::draw( 1085 Error ViaSerialization::draw(
1086 const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) cons t { 1086 const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) cons t {
1087 // Draw the Src directly as a reference.
1088 SkBitmap reference;
1089 if (bitmap) {
1090 Error err = fSink->draw(src, &reference, nullptr, log);
1091 if (!err.isEmpty()) {
1092 return err;
1093 }
1094 }
1095
1087 // Record our Src into a picture. 1096 // Record our Src into a picture.
1088 auto size = src.size(); 1097 auto size = src.size();
1089 SkPictureRecorder recorder; 1098 SkPictureRecorder recorder;
1090 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()), 1099 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()),
1091 SkIntToScalar(size.height()))); 1100 SkIntToScalar(size.height())));
1092 if (!err.isEmpty()) { 1101 if (!err.isEmpty()) {
1093 return err; 1102 return err;
1094 } 1103 }
1095 SkAutoTUnref<SkPicture> pic(recorder.endRecording()); 1104 SkAutoTUnref<SkPicture> pic(recorder.endRecording());
1096 1105
1097 // Serialize it and then deserialize it. 1106 // Serialize it and then deserialize it.
1098 SkDynamicMemoryWStream wStream; 1107 SkDynamicMemoryWStream wStream;
1099 pic->serialize(&wStream); 1108 pic->serialize(&wStream);
1100 SkAutoTDelete<SkStream> rStream(wStream.detachAsStream()); 1109 SkAutoTDelete<SkStream> rStream(wStream.detachAsStream());
1101 SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream, &l azy_decode_bitmap)); 1110 SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream, &l azy_decode_bitmap));
1102 1111
1103 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) { 1112 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) {
1104 canvas->drawPicture(deserialized); 1113 canvas->drawPicture(deserialized);
1114 // Check against the reference if we have one.
1115 if (bitmap) {
1116 if (reference.getSize() != bitmap->getSize()) {
1117 return "Serialized and direct have different dimensions.";
1118 }
1119 if (0 != memcmp(reference.getPixels(), bitmap->getPixels(), referenc e.getSize())) {
1120 return "Serialized and direct have different pixels.";
1121 }
1122 }
1105 return ""; 1123 return "";
1106 }); 1124 });
1107 } 1125 }
1108 1126
1109 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1127 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1110 1128
1111 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink) 1129 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink)
1112 : Via(sink) 1130 : Via(sink)
1113 , fW(w) 1131 , fW(w)
1114 , fH(h) 1132 , fH(h)
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 skr.visit<void>(i, drawsAsSingletonPictures); 1282 skr.visit<void>(i, drawsAsSingletonPictures);
1265 } 1283 }
1266 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1284 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1267 1285
1268 canvas->drawPicture(macroPic); 1286 canvas->drawPicture(macroPic);
1269 return ""; 1287 return "";
1270 }); 1288 });
1271 } 1289 }
1272 1290
1273 } // namespace DM 1291 } // namespace DM
OLDNEW
« 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