blob: 445a11b2d1e9491a0a9e8933f8a207880f88e044 [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 {
34
35public:
36
37 TestWindowContext();
38
39 /// We need to know the size of the window.
40 void initialize(int width, int height);
41
42 /// Returns a canvas to draw into; NULL if not yet initialize()d.
43 SkCanvas* prepareToDraw();
44
45 /// Flushes all drawing commands to HWUI; no-op if not yet initialize()d.
46 void finishDrawing();
47
48 /// Blocks until HWUI has processed all pending drawing commands;
49 /// no-op if not yet initialize()d.
50 void fence();
51
52 /// Returns false if not yet initialize()d.
53 bool capturePixels(SkBitmap* bmp);
54
55private:
56 /// Hidden implementation.
57 class TestWindowData;
58
59 TestWindowData* mData;
60
61};
62
63} // namespace uirenderer
64} // namespace android
65
66#endif // TESTWINDOWCONTEXT_H_
67