aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMSrcSinkAndroid.h
blob: 1a7459f6e81cea5bdee273c325d7c47d9b3e4e03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * Copyright 2015 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef DMSrcSinkAndroid_DEFINED
#define DMSrcSinkAndroid_DEFINED

#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK

#include "DMSrcSink.h"

namespace DM {

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

// Draws to the Android Framework's HWUI API.

class HWUISink : public Sink {
public:
    HWUISink() { }

    Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const SK_OVERRIDE;
    int enclave() const SK_OVERRIDE { return kGPU_Enclave; }
    const char* fileExtension() const SK_OVERRIDE { return "png"; }
};

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

// Trims draw commands to only include those supported by the Android Framework's HWUI API.

class ViaAndroidSDK : public Sink {
public:
    explicit ViaAndroidSDK(Sink*);

    Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const SK_OVERRIDE;
    int enclave() const SK_OVERRIDE { return fSink->enclave(); }
    const char* fileExtension() const SK_OVERRIDE { return fSink->fileExtension(); }

private:
    SkAutoTDelete<Sink> fSink;
};

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

}  // namespace DM

#endif  // SK_BUILD_FOR_ANDROID_FRAMEWORK

#endif  // DMSrcSinkAndroid_DEFINED