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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1269093002: remove SkDeferredCanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 | « dm/DM.cpp ('k') | gyp/utils.gypi » ('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 "SkCodec.h" 10 #include "SkCodec.h"
11 #include "SkCommonFlags.h" 11 #include "SkCommonFlags.h"
12 #include "SkData.h" 12 #include "SkData.h"
13 #include "SkDeferredCanvas.h"
14 #include "SkDocument.h" 13 #include "SkDocument.h"
15 #include "SkError.h" 14 #include "SkError.h"
16 #include "SkFunction.h" 15 #include "SkFunction.h"
17 #include "SkImageGenerator.h" 16 #include "SkImageGenerator.h"
18 #include "SkMultiPictureDraw.h" 17 #include "SkMultiPictureDraw.h"
19 #include "SkNullCanvas.h" 18 #include "SkNullCanvas.h"
20 #include "SkOSFile.h" 19 #include "SkOSFile.h"
21 #include "SkPictureData.h" 20 #include "SkPictureData.h"
22 #include "SkPictureRecorder.h" 21 #include "SkPictureRecorder.h"
23 #include "SkRandom.h" 22 #include "SkRandom.h"
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 return ""; 866 return "";
868 } 867 }
869 868
870 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 869 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
871 870
872 Error ViaPipe::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStrin g* log) const { 871 Error ViaPipe::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStrin g* log) const {
873 auto size = src.size(); 872 auto size = src.size();
874 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) { 873 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) {
875 PipeController controller(canvas, &SkImageDecoder::DecodeMemory); 874 PipeController controller(canvas, &SkImageDecoder::DecodeMemory);
876 SkGPipeWriter pipe; 875 SkGPipeWriter pipe;
877 const uint32_t kFlags = 0; // We mirror SkDeferredCanvas, which doesn't use any flags. 876 const uint32_t kFlags = 0;
878 return src.draw(pipe.startRecording(&controller, kFlags, size.width(), s ize.height())); 877 return src.draw(pipe.startRecording(&controller, kFlags, size.width(), s ize.height()));
879 }); 878 });
880 } 879 }
881 880
882 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 881 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
883 882
884 Error ViaDeferred::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkS tring* log) const {
885 // We draw via a deferred canvas into a surface that's compatible with the o riginal canvas,
886 // then snap that surface as an image and draw it into the original canvas.
887 return draw_to_canvas(fSink, bitmap, stream, log, src.size(), [&](SkCanvas* canvas) -> Error {
888 SkAutoTUnref<SkSurface> surface(canvas->newSurface(canvas->imageInfo())) ;
889 if (!surface.get()) {
890 return "can't make surface for deferred canvas";
891 }
892 SkAutoTDelete<SkDeferredCanvas> defcan(SkDeferredCanvas::Create(surface) );
893 Error err = src.draw(defcan);
894 if (!err.isEmpty()) {
895 return err;
896 }
897 SkAutoTUnref<SkImage> image(defcan->newImageSnapshot());
898 if (!image) {
899 return "failed to create deferred image snapshot";
900 }
901 canvas->drawImage(image, 0, 0, NULL);
902 return "";
903 });
904 }
905
906 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
907
908 Error ViaSerialization::draw( 883 Error ViaSerialization::draw(
909 const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) cons t { 884 const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) cons t {
910 // Record our Src into a picture. 885 // Record our Src into a picture.
911 auto size = src.size(); 886 auto size = src.size();
912 SkPictureRecorder recorder; 887 SkPictureRecorder recorder;
913 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()), 888 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()),
914 SkIntToScalar(size.height()))); 889 SkIntToScalar(size.height())));
915 if (!err.isEmpty()) { 890 if (!err.isEmpty()) {
916 return err; 891 return err;
917 } 892 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 skr.visit<void>(i, drawsAsSingletonPictures); 1064 skr.visit<void>(i, drawsAsSingletonPictures);
1090 } 1065 }
1091 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); 1066 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
1092 1067
1093 canvas->drawPicture(macroPic); 1068 canvas->drawPicture(macroPic);
1094 return ""; 1069 return "";
1095 }); 1070 });
1096 } 1071 }
1097 1072
1098 } // namespace DM 1073 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DM.cpp ('k') | gyp/utils.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698