blob: 02eb1c98c1b07a1fe4c55d4e8452e0abe3d1b316 [file] [log] [blame]
tomhudsoneebc39a2015-02-23 12:18:05 -08001/*
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
15namespace DM {
16
17/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
18
tomhudson64de1e12015-03-05 08:01:07 -080019// Draws to the Android Framework's HWUI API.
20
tomhudsoneebc39a2015-02-23 12:18:05 -080021class HWUISink : public Sink {
22public:
23 HWUISink() { }
24
mtklein36352bf2015-03-25 18:17:31 -070025 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
26 int enclave() const override { return kGPU_Enclave; }
27 const char* fileExtension() const override { return "png"; }
mtkleinf2319002015-08-03 10:20:28 -070028 SinkFlags flags() const override { return SinkFlags{ SinkFlags::kGPU, SinkFlags::kDirect }; }
tomhudsoneebc39a2015-02-23 12:18:05 -080029};
30
31/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
32
tomhudson64de1e12015-03-05 08:01:07 -080033// Trims draw commands to only include those supported by the Android Framework's HWUI API.
34
35class ViaAndroidSDK : public Sink {
36public:
37 explicit ViaAndroidSDK(Sink*);
38
mtklein36352bf2015-03-25 18:17:31 -070039 Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
40 int enclave() const override { return fSink->enclave(); }
41 const char* fileExtension() const override { return fSink->fileExtension(); }
mtkleinf2319002015-08-03 10:20:28 -070042 SinkFlags flags() const override {
43 SinkFlags flags = fSink->flags();
44 flags.approach = SinkFlags::kIndirect;
45 return flags;
46 }
tomhudson64de1e12015-03-05 08:01:07 -080047
48private:
49 SkAutoTDelete<Sink> fSink;
50};
51
52/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
53
tomhudsoneebc39a2015-02-23 12:18:05 -080054} // namespace DM
55
56#endif // SK_BUILD_FOR_ANDROID_FRAMEWORK
57
58#endif // DMSrcSinkAndroid_DEFINED