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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1563923003: Revert of DM: add a pixel check to serialize (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
1096 // Record our Src into a picture. 1087 // Record our Src into a picture.
1097 auto size = src.size(); 1088 auto size = src.size();
1098 SkPictureRecorder recorder; 1089 SkPictureRecorder recorder;
1099 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()), 1090 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()),
1100 SkIntToScalar(size.height()))); 1091 SkIntToScalar(size.height())));
1101 if (!err.isEmpty()) { 1092 if (!err.isEmpty()) {
1102 return err; 1093 return err;
1103 } 1094 }
1104 SkAutoTUnref<SkPicture> pic(recorder.endRecording()); 1095 SkAutoTUnref<SkPicture> pic(recorder.endRecording());
1105 1096
1106 // Serialize it and then deserialize it. 1097 // Serialize it and then deserialize it.
1107 SkDynamicMemoryWStream wStream; 1098 SkDynamicMemoryWStream wStream;
1108 pic->serialize(&wStream); 1099 pic->serialize(&wStream);
1109 SkAutoTDelete<SkStream> rStream(wStream.detachAsStream()); 1100 SkAutoTDelete<SkStream> rStream(wStream.detachAsStream());
1110 SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream, &l azy_decode_bitmap)); 1101 SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream, &l azy_decode_bitmap));
1111 1102
1112 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) { 1103 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) {
1113 canvas->drawPicture(deserialized); 1104 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 }
1123 return ""; 1105 return "";
1124 }); 1106 });
1125 } 1107 }
1126 1108
1127 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1109 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1128 1110
1129 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink) 1111 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink)
1130 : Via(sink) 1112 : Via(sink)
1131 , fW(w) 1113 , fW(w)
1132 , fH(h) 1114 , fH(h)
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 skr.visit<void>(i, drawsAsSingletonPictures); 1264 skr.visit<void>(i, drawsAsSingletonPictures);
1283 } 1265 }
1284 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1266 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1285 1267
1286 canvas->drawPicture(macroPic); 1268 canvas->drawPicture(macroPic);
1287 return ""; 1269 return "";
1288 }); 1270 });
1289 } 1271 }
1290 1272
1291 } // namespace DM 1273 } // 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