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