|
1 /* |
|
2 * Copyright (C) 2007 The Android Open Source Project |
|
3 * Copyright (C) 2013 Mozilla Foundation |
|
4 * |
|
5 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
6 * you may not use this file except in compliance with the License. |
|
7 * You may obtain a copy of the License at |
|
8 * |
|
9 * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 * |
|
11 * Unless required by applicable law or agreed to in writing, software |
|
12 * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 * See the License for the specific language governing permissions and |
|
15 * limitations under the License. |
|
16 */ |
|
17 |
|
18 #ifndef NATIVEWINDOW_FAKE_SURFACE_COMPOSER_H |
|
19 #define NATIVEWINDOW_FAKE_SURFACE_COMPOSER_H |
|
20 |
|
21 #include <stdint.h> |
|
22 #include <sys/types.h> |
|
23 |
|
24 #include <utils/Errors.h> |
|
25 |
|
26 #include <binder/BinderService.h> |
|
27 |
|
28 #include <gui/ISurfaceComposer.h> |
|
29 #include <gui/ISurfaceComposerClient.h> |
|
30 |
|
31 namespace android { |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 |
|
35 class IGraphicBufferAlloc; |
|
36 |
|
37 class FakeSurfaceComposer : public BinderService<FakeSurfaceComposer>, |
|
38 public BnSurfaceComposer |
|
39 { |
|
40 public: |
|
41 static char const* getServiceName() { |
|
42 return "FakeSurfaceComposer"; |
|
43 } |
|
44 |
|
45 // Instantiate MediaResourceManagerService and register to service manager. |
|
46 // If service manager is not present, wait until service manager becomes present. |
|
47 static void instantiate(); |
|
48 #if ANDROID_VERSION >= 19 |
|
49 virtual void destroyDisplay(const sp<android::IBinder>& display); |
|
50 virtual status_t captureScreen(const sp<IBinder>& display, const sp<IGraphicBufferProducer>& producer, |
|
51 uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ, uint32_t maxLayerZ); |
|
52 #endif |
|
53 |
|
54 private: |
|
55 FakeSurfaceComposer(); |
|
56 // We're reference counted, never destroy FakeSurfaceComposer directly |
|
57 virtual ~FakeSurfaceComposer(); |
|
58 |
|
59 /* ------------------------------------------------------------------------ |
|
60 * ISurfaceComposer interface |
|
61 */ |
|
62 virtual sp<ISurfaceComposerClient> createConnection(); |
|
63 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc(); |
|
64 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure); |
|
65 virtual sp<IBinder> getBuiltInDisplay(int32_t id); |
|
66 virtual void setTransactionState(const Vector<ComposerState>& state, |
|
67 const Vector<DisplayState>& displays, uint32_t flags); |
|
68 virtual void bootFinished(); |
|
69 virtual bool authenticateSurfaceTexture( |
|
70 const sp<IGraphicBufferProducer>& bufferProducer) const; |
|
71 virtual sp<IDisplayEventConnection> createDisplayEventConnection(); |
|
72 virtual status_t captureScreen(const sp<IBinder>& display, |
|
73 const sp<IGraphicBufferProducer>& producer, |
|
74 uint32_t reqWidth, uint32_t reqHeight, |
|
75 uint32_t minLayerZ, uint32_t maxLayerZ, bool isCpuConsumer); |
|
76 // called when screen needs to turn off |
|
77 virtual void blank(const sp<IBinder>& display); |
|
78 // called when screen is turning back on |
|
79 virtual void unblank(const sp<IBinder>& display); |
|
80 virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info); |
|
81 |
|
82 }; |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 }; // namespace android |
|
86 |
|
87 #endif // NATIVEWINDOW_FAKE_SURFACE_COMPOSER_H |