blob: 17ad1e3fef553bf1f4f20732354a0650c6bd95b8 [file] [log] [blame]
Tom Hudsonb2f5bd22015-10-15 16:41:55 -04001/*
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 {
Tom Hudsonb2f5bd22015-10-15 16:41:55 -040034public:
Tom Hudsonb2f5bd22015-10-15 16:41:55 -040035 TestWindowContext();
Tom Hudson58862c92015-12-10 16:46:57 -050036 ~TestWindowContext();
Tom Hudsonb2f5bd22015-10-15 16:41:55 -040037
38 /// We need to know the size of the window.
39 void initialize(int width, int height);
40
41 /// Returns a canvas to draw into; NULL if not yet initialize()d.
42 SkCanvas* prepareToDraw();
43
44 /// Flushes all drawing commands to HWUI; no-op if not yet initialize()d.
45 void finishDrawing();
46
47 /// Blocks until HWUI has processed all pending drawing commands;
48 /// no-op if not yet initialize()d.
49 void fence();
50
51 /// Returns false if not yet initialize()d.
52 bool capturePixels(SkBitmap* bmp);
53
54private:
55 /// Hidden implementation.
56 class TestWindowData;
57
58 TestWindowData* mData;
Tom Hudsonb2f5bd22015-10-15 16:41:55 -040059};
60
61} // namespace uirenderer
62} // namespace android
63
64#endif // TESTWINDOWCONTEXT_H_