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

Side by Side Diff: dm/DMSrcSink.h

Issue 1681553003: Optionally run RAW images serially (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 #ifndef DMSrcSink_DEFINED 8 #ifndef DMSrcSink_DEFINED
9 #define DMSrcSink_DEFINED 9 #define DMSrcSink_DEFINED
10 10
11 #include "DMGpuSupport.h" 11 #include "DMGpuSupport.h"
12 #include "SkBBHFactory.h" 12 #include "SkBBHFactory.h"
13 #include "SkBBoxHierarchy.h" 13 #include "SkBBoxHierarchy.h"
14 #include "SkBitmap.h" 14 #include "SkBitmap.h"
15 #include "SkBitmapRegionDecoder.h" 15 #include "SkBitmapRegionDecoder.h"
16 #include "SkCanvas.h" 16 #include "SkCanvas.h"
17 #include "SkData.h" 17 #include "SkData.h"
18 #include "SkPicture.h" 18 #include "SkPicture.h"
19 #include "gm.h" 19 #include "gm.h"
20 20
21 namespace DM { 21 namespace DM {
22 22
23 // Return the extension of the provided SkString. Returns a pointer into the SkS tring's
24 // data, so its lifetime is the same as the SkString.
25 const char* SkStringExtension(const SkString&);
scroggo 2016/02/08 18:57:52 I needed this in more than one place, and both of
mtklein 2016/02/08 21:26:55 Better call this FileExtension() or FileNameExtens
26
23 // This is just convenience. It lets you use either return "foo" or return SkSt ringPrintf(...). 27 // This is just convenience. It lets you use either return "foo" or return SkSt ringPrintf(...).
24 struct ImplicitString : public SkString { 28 struct ImplicitString : public SkString {
25 template <typename T> 29 template <typename T>
26 ImplicitString(const T& s) : SkString(s) {} 30 ImplicitString(const T& s) : SkString(s) {}
27 ImplicitString() : SkString("") {} 31 ImplicitString() : SkString("") {}
28 }; 32 };
29 typedef ImplicitString Name; 33 typedef ImplicitString Name;
30 typedef ImplicitString Path; 34 typedef ImplicitString Path;
31 35
32 class Error { 36 class Error {
(...skipping 18 matching lines...) Expand all
51 private: 55 private:
52 SkString fMsg; 56 SkString fMsg;
53 bool fFatal; 57 bool fFatal;
54 }; 58 };
55 59
56 struct SinkFlags { 60 struct SinkFlags {
57 enum { kNull, kGPU, kVector, kRaster } type; 61 enum { kNull, kGPU, kVector, kRaster } type;
58 enum { kDirect, kIndirect } approach; 62 enum { kDirect, kIndirect } approach;
59 }; 63 };
60 64
65 enum { kAnyThread_Enclave,
66 kGPU_Enclave,
67 #ifdef SK_CODEC_DECODES_RAW
mtklein 2016/02/08 21:26:55 Why the #ifdef?
68 kRAW_Enclave,
69 #endif
70 kNumEnclaves,
71 };
72
61 struct Src { 73 struct Src {
62 // All Srcs must be thread safe. 74 // All Srcs must be thread safe.
mtklein 2016/02/08 21:26:55 Better update / remove this.
63 virtual ~Src() {} 75 virtual ~Src() {}
64 virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0; 76 virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0;
65 virtual SkISize size() const = 0; 77 virtual SkISize size() const = 0;
66 virtual Name name() const = 0; 78 virtual Name name() const = 0;
67 virtual void modifyGrContextOptions(GrContextOptions* options) const {} 79 virtual void modifyGrContextOptions(GrContextOptions* options) const {}
68 virtual bool veto(SinkFlags) const { return false; } 80 virtual bool veto(SinkFlags) const { return false; }
81 // If not kAnyThread_Enclave, overrides the Sink's enclave
82 virtual int enclave() const { return kAnyThread_Enclave; }
69 }; 83 };
70 84
71 struct Sink { 85 struct Sink {
72 virtual ~Sink() {} 86 virtual ~Sink() {}
73 // You may write to either the bitmap or stream. If you write to log, we'll print that out. 87 // You may write to either the bitmap or stream. If you write to log, we'll print that out.
74 virtual Error SK_WARN_UNUSED_RESULT draw(const Src&, SkBitmap*, SkWStream*, SkString* log) 88 virtual Error SK_WARN_UNUSED_RESULT draw(const Src&, SkBitmap*, SkWStream*, SkString* log)
75 const = 0; 89 const = 0;
76 // Sinks in the same enclave (except kAnyThread_Enclave) will run serially o n the same thread. 90 // Sinks in the same enclave (except kAnyThread_Enclave) will run serially o n the same thread.
77 virtual int enclave() const = 0; 91 virtual int enclave() const = 0;
78 92
79 // File extension for the content draw() outputs, e.g. "png", "pdf". 93 // File extension for the content draw() outputs, e.g. "png", "pdf".
80 virtual const char* fileExtension() const = 0; 94 virtual const char* fileExtension() const = 0;
81 95
82 virtual SinkFlags flags() const = 0; 96 virtual SinkFlags flags() const = 0;
83 }; 97 };
84 98
85 enum { kAnyThread_Enclave, kGPU_Enclave };
86 static const int kNumEnclaves = kGPU_Enclave + 1;
87
88 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 99 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
89 100
90 class GMSrc : public Src { 101 class GMSrc : public Src {
91 public: 102 public:
92 explicit GMSrc(skiagm::GMRegistry::Factory); 103 explicit GMSrc(skiagm::GMRegistry::Factory);
93 104
94 Error draw(SkCanvas*) const override; 105 Error draw(SkCanvas*) const override;
95 SkISize size() const override; 106 SkISize size() const override;
96 Name name() const override; 107 Name name() const override;
97 void modifyGrContextOptions(GrContextOptions* options) const override; 108 void modifyGrContextOptions(GrContextOptions* options) const override;
(...skipping 19 matching lines...) Expand all
117 kGetFromCanvas_DstColorType, 128 kGetFromCanvas_DstColorType,
118 kIndex8_Always_DstColorType, 129 kIndex8_Always_DstColorType,
119 kGrayscale_Always_DstColorType, 130 kGrayscale_Always_DstColorType,
120 }; 131 };
121 CodecSrc(Path, Mode, DstColorType, SkAlphaType, float); 132 CodecSrc(Path, Mode, DstColorType, SkAlphaType, float);
122 133
123 Error draw(SkCanvas*) const override; 134 Error draw(SkCanvas*) const override;
124 SkISize size() const override; 135 SkISize size() const override;
125 Name name() const override; 136 Name name() const override;
126 bool veto(SinkFlags) const override; 137 bool veto(SinkFlags) const override;
138 int enclave() const override;
127 private: 139 private:
128 Path fPath; 140 Path fPath;
129 Mode fMode; 141 Mode fMode;
130 DstColorType fDstColorType; 142 DstColorType fDstColorType;
131 SkAlphaType fDstAlphaType; 143 SkAlphaType fDstAlphaType;
132 float fScale; 144 float fScale;
133 }; 145 };
134 146
135 class AndroidCodecSrc : public Src { 147 class AndroidCodecSrc : public Src {
136 public: 148 public:
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 371
360 class ViaMojo : public Via { 372 class ViaMojo : public Via {
361 public: 373 public:
362 explicit ViaMojo(Sink* sink) : Via(sink) {} 374 explicit ViaMojo(Sink* sink) : Via(sink) {}
363 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; 375 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
364 }; 376 };
365 377
366 } // namespace DM 378 } // namespace DM
367 379
368 #endif//DMSrcSink_DEFINED 380 #endif//DMSrcSink_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698