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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 2120333002: deferred canvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove prev change to dmsrcsink Created 4 years, 5 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
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 "Resources.h" 9 #include "Resources.h"
10 #include "SkAndroidCodec.h" 10 #include "SkAndroidCodec.h"
11 #include "SkCodec.h" 11 #include "SkCodec.h"
12 #include "SkCodecImageGenerator.h" 12 #include "SkCodecImageGenerator.h"
13 #include "SkColorSpace.h" 13 #include "SkColorSpace.h"
14 #include "SkColorSpace_Base.h" 14 #include "SkColorSpace_Base.h"
15 #include "SkColorSpaceXform.h" 15 #include "SkColorSpaceXform.h"
16 #include "SkCommonFlags.h" 16 #include "SkCommonFlags.h"
17 #include "SkData.h" 17 #include "SkData.h"
18 #include "SkDeferredCanvas.h"
18 #include "SkDocument.h" 19 #include "SkDocument.h"
19 #include "SkError.h" 20 #include "SkError.h"
20 #include "SkImageGenerator.h" 21 #include "SkImageGenerator.h"
21 #include "SkImageGeneratorCG.h" 22 #include "SkImageGeneratorCG.h"
22 #include "SkImageGeneratorWIC.h" 23 #include "SkImageGeneratorWIC.h"
23 #include "SkMallocPixelRef.h" 24 #include "SkMallocPixelRef.h"
24 #include "SkMultiPictureDraw.h" 25 #include "SkMultiPictureDraw.h"
25 #include "SkNullCanvas.h" 26 #include "SkNullCanvas.h"
26 #include "SkOSFile.h" 27 #include "SkOSFile.h"
27 #include "SkOpts.h" 28 #include "SkOpts.h"
(...skipping 14 matching lines...) Expand all
42 #endif 43 #endif
43 44
44 #if defined(SK_TEST_QCMS) 45 #if defined(SK_TEST_QCMS)
45 #include "qcms.h" 46 #include "qcms.h"
46 #endif 47 #endif
47 48
48 DEFINE_bool(multiPage, false, "For document-type backends, render the source" 49 DEFINE_bool(multiPage, false, "For document-type backends, render the source"
49 " into multiple pages"); 50 " into multiple pages");
50 DEFINE_bool(RAW_threading, true, "Allow RAW decodes to run on multiple threads?" ); 51 DEFINE_bool(RAW_threading, true, "Allow RAW decodes to run on multiple threads?" );
51 52
53 extern bool gUseDeferredCanvas;
54
52 using sk_gpu_test::GrContextFactory; 55 using sk_gpu_test::GrContextFactory;
53 56
54 namespace DM { 57 namespace DM {
55 58
56 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} 59 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {}
57 60
58 Error GMSrc::draw(SkCanvas* canvas) const { 61 Error GMSrc::draw(SkCanvas* canvas) const {
59 SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr)); 62 SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr));
60 canvas->concat(gm->getInitialTransform()); 63 canvas->concat(gm->getInitialTransform());
61 gm->draw(canvas); 64 gm->draw(canvas);
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 // If there's an appropriate alpha type for this color type, use it, otherwi se use premul. 1225 // If there's an appropriate alpha type for this color type, use it, otherwi se use premul.
1223 SkAlphaType alphaType = kPremul_SkAlphaType; 1226 SkAlphaType alphaType = kPremul_SkAlphaType;
1224 (void)SkColorTypeValidateAlphaType(fColorType, alphaType, &alphaType); 1227 (void)SkColorTypeValidateAlphaType(fColorType, alphaType, &alphaType);
1225 1228
1226 SkMallocPixelRef::ZeroedPRFactory factory; 1229 SkMallocPixelRef::ZeroedPRFactory factory;
1227 dst->allocPixels(SkImageInfo::Make(size.width(), size.height(), 1230 dst->allocPixels(SkImageInfo::Make(size.width(), size.height(),
1228 fColorType, alphaType, fColorSpace), 1231 fColorType, alphaType, fColorSpace),
1229 &factory, 1232 &factory,
1230 nullptr/*colortable*/); 1233 nullptr/*colortable*/);
1231 SkCanvas canvas(*dst); 1234 SkCanvas canvas(*dst);
1232 return src.draw(&canvas); 1235 SkDeferredCanvas deferred(&canvas);
1236 return src.draw(gUseDeferredCanvas ? &deferred : &canvas);
mtklein 2016/07/08 12:30:47 We would normally hook this into DM differently.
1233 } 1237 }
1234 1238
1235 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1239 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1236 1240
1237 // Handy for front-patching a Src. Do whatever up-front work you need, then cal l draw_to_canvas(), 1241 // Handy for front-patching a Src. Do whatever up-front work you need, then cal l draw_to_canvas(),
1238 // passing the Sink draw() arguments, a size, and a function draws into an SkCan vas. 1242 // passing the Sink draw() arguments, a size, and a function draws into an SkCan vas.
1239 // Several examples below. 1243 // Several examples below.
1240 1244
1241 template <typename Fn> 1245 template <typename Fn>
1242 static Error draw_to_canvas(Sink* sink, SkBitmap* bitmap, SkWStream* stream, SkS tring* log, 1246 static Error draw_to_canvas(Sink* sink, SkBitmap* bitmap, SkWStream* stream, SkS tring* log,
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 skr.visit(i, drawsAsSingletonPictures); 1547 skr.visit(i, drawsAsSingletonPictures);
1544 } 1548 }
1545 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture()); 1549 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture());
1546 1550
1547 canvas->drawPicture(macroPic); 1551 canvas->drawPicture(macroPic);
1548 return check_against_reference(bitmap, src, fSink); 1552 return check_against_reference(bitmap, src, fSink);
1549 }); 1553 });
1550 } 1554 }
1551 1555
1552 } // namespace DM 1556 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DM.cpp ('k') | gyp/utils.gypi » ('j') | src/utils/SkDeferredCanvas.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698