1/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef TESTWINDOWCONTEXT_H_
17#define TESTWINDOWCONTEXT_H_
18
19#include <cutils/compiler.h>
20
21class SkBitmap;
22class SkCanvas;
23
24namespace android {
25
26namespace uirenderer {
27
28/**
29  Wraps all libui/libgui classes and types that external tests depend on,
30  exposing only primitive Skia types.
31*/
32
33class ANDROID_API TestWindowContext {
34
35public:
36
37    TestWindowContext();
38    ~TestWindowContext();
39
40    /// We need to know the size of the window.
41    void initialize(int width, int height);
42
43    /// Returns a canvas to draw into; NULL if not yet initialize()d.
44    SkCanvas* prepareToDraw();
45
46    /// Flushes all drawing commands to HWUI; no-op if not yet initialize()d.
47    void finishDrawing();
48
49    /// Blocks until HWUI has processed all pending drawing commands;
50    /// no-op if not yet initialize()d.
51    void fence();
52
53    /// Returns false if not yet initialize()d.
54    bool capturePixels(SkBitmap* bmp);
55
56private:
57    /// Hidden implementation.
58    class TestWindowData;
59
60    TestWindowData* mData;
61
62};
63
64}  // namespace uirenderer
65}  // namespace android
66
67#endif  // TESTWINDOWCONTEXT_H_
68
69