The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | // tag as surfaceflinger |
| 18 | #define LOG_TAG "SurfaceFlinger" |
| 19 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | #include <stdint.h> |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 21 | #include <stdio.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | #include <sys/types.h> |
| 23 | |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 24 | #include <binder/IPCThreadState.h> |
| 25 | #include <binder/IServiceManager.h> |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 26 | #include <binder/Parcel.h> |
| 27 | #include <binder/SafeInterface.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 29 | #include <ui/FrameStats.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | #include <ui/Point.h> |
| 31 | #include <ui/Rect.h> |
| 32 | |
Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 33 | #include <gui/IGraphicBufferProducer.h> |
Mathias Agopian | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 34 | #include <gui/ISurfaceComposerClient.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | namespace android { |
| 37 | |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 38 | class BpSurfaceComposerClient : public SafeBpInterface<ISurfaceComposerClient> { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | public: |
Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame] | 40 | explicit BpSurfaceComposerClient(const sp<IBinder>& impl) |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 41 | : SafeBpInterface<ISurfaceComposerClient>(impl, "BpSurfaceComposerClient") {} |
| 42 | |
| 43 | ~BpSurfaceComposerClient() override; |
| 44 | |
| 45 | status_t createSurface(const String8& name, uint32_t width, uint32_t height, PixelFormat format, |
| 46 | uint32_t flags, const sp<IBinder>& parent, uint32_t windowType, |
| 47 | uint32_t ownerUid, sp<IBinder>* handle, |
| 48 | sp<IGraphicBufferProducer>* gbp) override { |
| 49 | return callRemote<decltype(&ISurfaceComposerClient::createSurface)>(Tag::CreateSurface, |
| 50 | name, width, height, |
| 51 | format, flags, parent, |
| 52 | windowType, ownerUid, |
| 53 | handle, gbp); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | } |
| 55 | |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 56 | status_t destroySurface(const sp<IBinder>& handle) override { |
| 57 | return callRemote<decltype(&ISurfaceComposerClient::destroySurface)>(Tag::DestroySurface, |
| 58 | handle); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | } |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 60 | |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 61 | status_t clearLayerFrameStats(const sp<IBinder>& handle) const override { |
| 62 | return callRemote<decltype( |
| 63 | &ISurfaceComposerClient::clearLayerFrameStats)>(Tag::ClearLayerFrameStats, handle); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | } |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 65 | |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 66 | status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const override { |
| 67 | return callRemote<decltype( |
| 68 | &ISurfaceComposerClient::getLayerFrameStats)>(Tag::GetLayerFrameStats, handle, |
| 69 | outStats); |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 70 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | }; |
| 72 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 73 | // Out-of-line virtual method definition to trigger vtable emission in this |
| 74 | // translation unit (see clang warning -Wweak-vtables) |
| 75 | BpSurfaceComposerClient::~BpSurfaceComposerClient() {} |
| 76 | |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 77 | IMPLEMENT_META_INTERFACE(SurfaceComposerClient, "android.ui.ISurfaceComposerClient"); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | |
| 79 | // ---------------------------------------------------------------------- |
| 80 | |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 81 | status_t BnSurfaceComposerClient::onTransact(uint32_t code, const Parcel& data, Parcel* reply, |
| 82 | uint32_t flags) { |
| 83 | if (code < IBinder::FIRST_CALL_TRANSACTION || code >= static_cast<uint32_t>(Tag::Last)) { |
| 84 | return BBinder::onTransact(code, data, reply, flags); |
| 85 | } |
| 86 | auto tag = static_cast<Tag>(code); |
| 87 | switch (tag) { |
| 88 | case Tag::CreateSurface: { |
| 89 | return callLocal(data, reply, &ISurfaceComposerClient::createSurface); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 90 | } |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 91 | case Tag::DestroySurface: { |
| 92 | return callLocal(data, reply, &ISurfaceComposerClient::destroySurface); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 93 | } |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 94 | case Tag::ClearLayerFrameStats: { |
| 95 | return callLocal(data, reply, &ISurfaceComposerClient::clearLayerFrameStats); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 96 | } |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 97 | case Tag::GetLayerFrameStats: { |
| 98 | return callLocal(data, reply, &ISurfaceComposerClient::getLayerFrameStats); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 99 | } |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 100 | case Tag::Last: |
| 101 | // Should not be possible because of the check at the beginning of the method |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 102 | return BBinder::onTransact(code, data, reply, flags); |
| 103 | } |
| 104 | } |
| 105 | |
Dan Stoza | a615e47 | 2017-03-23 14:41:55 -0700 | [diff] [blame] | 106 | } // namespace android |