Debian Codegraph @

libs/hwui/tests/common/TestContext.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2014 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
17 #ifndef TESTCONTEXT_H
18 #define TESTCONTEXT_H
19
20 #include <gui/BufferItemConsumer.h>
21 #include <gui/DisplayEventReceiver.h>
22 #include <gui/ISurfaceComposer.h>
23 #include <gui/Surface.h>
24 #include <gui/SurfaceComposerClient.h>
25 #include <gui/SurfaceControl.h>
26 #include <ui/DisplayMode.h>
27 #include <ui/StaticDisplayInfo.h>
28 #include <utils/Looper.h>
29
30 #include <atomic>
31 #include <thread>
32
33 #define dp(x) ((x) * android::uirenderer::test::getDisplayInfo().density)
34
35 namespace android {
36 namespace uirenderer {
37 namespace test {
38
39 const ui::StaticDisplayInfo& getDisplayInfo();
40 const ui::DisplayMode& getActiveDisplayMode();
41
42 inline const ui::Size& getActiveDisplayResolution() {
43 return getActiveDisplayMode().resolution;
44 }
45
46 class TestContext {
47 public:
48 TestContext();
49 ~TestContext();
50
51 // Must be called before surface();
52 void setRenderOffscreen(bool renderOffscreen) {
53 LOG_ALWAYS_FATAL_IF(mSurface.get(), "Must be called before surface is created");
54 mRenderOffscreen = renderOffscreen;
55 }
56
57 sp<Surface> surface();
58
59 void waitForVsync();
60
61 private:
62 void createSurface();
63 void createWindowSurface();
64 void createOffscreenSurface();
65
66 sp<SurfaceComposerClient> mSurfaceComposerClient;
67 sp<SurfaceControl> mSurfaceControl;
68 sp<BufferItemConsumer> mConsumer;
69 DisplayEventReceiver mDisplayEventReceiver;
70 sp<Looper> mLooper;
71 sp<Surface> mSurface;
72 bool mRenderOffscreen;
73 };
74
75 } // namespace test
76 } // namespace uirenderer
77 } // namespace android
78
79 #endif