OLD | NEW |
---|---|
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 DMSrcSinkAndroid_DEFINED | 8 #ifndef DMSrcSinkAndroid_DEFINED |
9 #define DMSrcSinkAndroid_DEFINED | 9 #define DMSrcSinkAndroid_DEFINED |
10 | 10 |
11 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 11 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
12 | 12 |
13 #include "DMSrcSink.h" | 13 #include "DMSrcSink.h" |
14 | 14 |
15 #include "SkDrawFilter.h" | |
16 | |
15 namespace DM { | 17 namespace DM { |
16 | 18 |
17 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | 19 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ |
18 | 20 |
21 // Draws to the Android Framework's HWUI API. | |
22 | |
19 class HWUISink : public Sink { | 23 class HWUISink : public Sink { |
20 public: | 24 public: |
21 HWUISink() { } | 25 HWUISink() { } |
22 | 26 |
23 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const SK_OVERRIDE; | 27 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const SK_OVERRIDE; |
24 int enclave() const SK_OVERRIDE { return kGPU_Enclave; } | 28 int enclave() const SK_OVERRIDE { return kGPU_Enclave; } |
25 const char* fileExtension() const SK_OVERRIDE { return "png"; } | 29 const char* fileExtension() const SK_OVERRIDE { return "png"; } |
26 | 30 |
27 private: | 31 private: |
28 const float kDensity = 1.0f; | 32 const float kDensity = 1.0f; |
29 inline float dp(int x) const { return x * kDensity; } | 33 inline float dp(int x) const { return x * kDensity; } |
30 }; | 34 }; |
31 | 35 |
32 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | 36 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ |
33 | 37 |
38 // Trims draw commands and paint fields to only include options exposed by Andro id's HWUI. | |
39 // (Some mix of what's exposed by the Java and native APIs.) | |
40 | |
41 class ViaAndroidSDK : public Sink { | |
42 public: | |
43 ViaAndroidSDK(Sink*); | |
mtklein
2015/03/03 15:55:14
Can't hurt to make this explicit.
tomhudson
2015/03/05 14:53:52
Done.
| |
44 | |
45 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const SK_OVERRIDE; | |
46 int enclave() const SK_OVERRIDE { return fSink->enclave(); } | |
47 const char* fileExtension() const SK_OVERRIDE { return fSink->fileExtension( ); } | |
48 | |
49 private: | |
50 SkAutoTDelete<Sink> fSink; | |
51 SkAutoTDelete<SkDrawFilter> fFilter; | |
djsollen
2015/03/03 16:50:52
just put the filter on the stack. No need to reus
tomhudson
2015/03/05 14:53:52
Done.
| |
52 }; | |
53 | |
54 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | |
55 | |
34 } // namespace DM | 56 } // namespace DM |
35 | 57 |
36 #endif // SK_BUILD_FOR_ANDROID_FRAMEWORK | 58 #endif // SK_BUILD_FOR_ANDROID_FRAMEWORK |
37 | 59 |
38 #endif // DMSrcSinkAndroid_DEFINED | 60 #endif // DMSrcSinkAndroid_DEFINED |
OLD | NEW |