tomhudson | eebc39a | 2015-02-23 12:18:05 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef DMSrcSinkAndroid_DEFINED |
| 9 | #define DMSrcSinkAndroid_DEFINED |
| 10 | |
| 11 | #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 12 | |
| 13 | #include "DMSrcSink.h" |
| 14 | |
| 15 | namespace DM { |
| 16 | |
| 17 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 18 | |
tomhudson | 64de1e1 | 2015-03-05 08:01:07 -0800 | [diff] [blame] | 19 | // Draws to the Android Framework's HWUI API. |
| 20 | |
tomhudson | eebc39a | 2015-02-23 12:18:05 -0800 | [diff] [blame] | 21 | class HWUISink : public Sink { |
| 22 | public: |
| 23 | HWUISink() { } |
| 24 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 25 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
mtklein | fc57a33 | 2016-02-08 14:30:25 -0800 | [diff] [blame] | 26 | bool serial() const override { return true; } |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 27 | const char* fileExtension() const override { return "png"; } |
mtklein | f231900 | 2015-08-03 10:20:28 -0700 | [diff] [blame] | 28 | SinkFlags flags() const override { return SinkFlags{ SinkFlags::kGPU, SinkFlags::kDirect }; } |
tomhudson | eebc39a | 2015-02-23 12:18:05 -0800 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 32 | |
tomhudson | 64de1e1 | 2015-03-05 08:01:07 -0800 | [diff] [blame] | 33 | // Trims draw commands to only include those supported by the Android Framework's HWUI API. |
| 34 | |
| 35 | class ViaAndroidSDK : public Sink { |
| 36 | public: |
| 37 | explicit ViaAndroidSDK(Sink*); |
| 38 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 39 | Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
mtklein | fc57a33 | 2016-02-08 14:30:25 -0800 | [diff] [blame] | 40 | bool serial() const override { return fSink->serial(); } |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 41 | const char* fileExtension() const override { return fSink->fileExtension(); } |
mtklein | f231900 | 2015-08-03 10:20:28 -0700 | [diff] [blame] | 42 | SinkFlags flags() const override { |
| 43 | SinkFlags flags = fSink->flags(); |
| 44 | flags.approach = SinkFlags::kIndirect; |
| 45 | return flags; |
| 46 | } |
tomhudson | 64de1e1 | 2015-03-05 08:01:07 -0800 | [diff] [blame] | 47 | |
| 48 | private: |
| 49 | SkAutoTDelete<Sink> fSink; |
| 50 | }; |
| 51 | |
| 52 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 53 | |
tomhudson | eebc39a | 2015-02-23 12:18:05 -0800 | [diff] [blame] | 54 | } // namespace DM |
| 55 | |
| 56 | #endif // SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 57 | |
| 58 | #endif // DMSrcSinkAndroid_DEFINED |