blob: 369f523ea4c7893f80b2128f4ec0dbceedc0359f [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
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 Stoza0fe41e52017-04-03 15:16:27 -070020#include <gui/ISurfaceComposerClient.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080021
Dan Stoza0fe41e52017-04-03 15:16:27 -070022#include <gui/IGraphicBufferProducer.h>
23
Dan Stozaa615e472017-03-23 14:41:55 -070024#include <binder/SafeInterface.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080025
Dan Stozaa615e472017-03-23 14:41:55 -070026#include <ui/FrameStats.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080027
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080028namespace android {
29
Dan Stoza0fe41e52017-04-03 15:16:27 -070030namespace { // Anonymous
31
32enum class Tag : uint32_t {
33 CREATE_SURFACE = IBinder::FIRST_CALL_TRANSACTION,
Dan Stoza0fe41e52017-04-03 15:16:27 -070034 CLEAR_LAYER_FRAME_STATS,
35 GET_LAYER_FRAME_STATS,
36 LAST = GET_LAYER_FRAME_STATS,
37};
38
39} // Anonymous namespace
40
Dan Stozaa615e472017-03-23 14:41:55 -070041class BpSurfaceComposerClient : public SafeBpInterface<ISurfaceComposerClient> {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080042public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070043 explicit BpSurfaceComposerClient(const sp<IBinder>& impl)
Dan Stozaa615e472017-03-23 14:41:55 -070044 : SafeBpInterface<ISurfaceComposerClient>(impl, "BpSurfaceComposerClient") {}
45
46 ~BpSurfaceComposerClient() override;
47
48 status_t createSurface(const String8& name, uint32_t width, uint32_t height, PixelFormat format,
rongliucfb187b2018-03-14 12:26:23 -070049 uint32_t flags, const sp<IBinder>& parent, int32_t windowType,
50 int32_t ownerUid, sp<IBinder>* handle,
Dan Stozaa615e472017-03-23 14:41:55 -070051 sp<IGraphicBufferProducer>* gbp) override {
Dan Stoza0fe41e52017-04-03 15:16:27 -070052 return callRemote<decltype(&ISurfaceComposerClient::createSurface)>(Tag::CREATE_SURFACE,
Dan Stozaa615e472017-03-23 14:41:55 -070053 name, width, height,
54 format, flags, parent,
55 windowType, ownerUid,
56 handle, gbp);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080057 }
58
Dan Stozaa615e472017-03-23 14:41:55 -070059 status_t clearLayerFrameStats(const sp<IBinder>& handle) const override {
60 return callRemote<decltype(
Dan Stoza0fe41e52017-04-03 15:16:27 -070061 &ISurfaceComposerClient::clearLayerFrameStats)>(Tag::CLEAR_LAYER_FRAME_STATS,
62 handle);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080063 }
Svetoslavd85084b2014-03-20 10:28:31 -070064
Dan Stozaa615e472017-03-23 14:41:55 -070065 status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const override {
66 return callRemote<decltype(
Dan Stoza0fe41e52017-04-03 15:16:27 -070067 &ISurfaceComposerClient::getLayerFrameStats)>(Tag::GET_LAYER_FRAME_STATS, handle,
Dan Stozaa615e472017-03-23 14:41:55 -070068 outStats);
Svetoslavd85084b2014-03-20 10:28:31 -070069 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080070};
71
Dan Stozad723bd72014-11-18 10:24:03 -080072// Out-of-line virtual method definition to trigger vtable emission in this
73// translation unit (see clang warning -Wweak-vtables)
74BpSurfaceComposerClient::~BpSurfaceComposerClient() {}
75
Mathias Agopian7e27f052010-05-28 14:22:23 -070076IMPLEMENT_META_INTERFACE(SurfaceComposerClient, "android.ui.ISurfaceComposerClient");
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080077
78// ----------------------------------------------------------------------
79
Dan Stozaa615e472017-03-23 14:41:55 -070080status_t BnSurfaceComposerClient::onTransact(uint32_t code, const Parcel& data, Parcel* reply,
81 uint32_t flags) {
Dan Stoza0fe41e52017-04-03 15:16:27 -070082 if (code < IBinder::FIRST_CALL_TRANSACTION || code > static_cast<uint32_t>(Tag::LAST)) {
Dan Stozaa615e472017-03-23 14:41:55 -070083 return BBinder::onTransact(code, data, reply, flags);
84 }
85 auto tag = static_cast<Tag>(code);
86 switch (tag) {
Dan Stoza0fe41e52017-04-03 15:16:27 -070087 case Tag::CREATE_SURFACE:
Dan Stozaa615e472017-03-23 14:41:55 -070088 return callLocal(data, reply, &ISurfaceComposerClient::createSurface);
Dan Stoza0fe41e52017-04-03 15:16:27 -070089 case Tag::CLEAR_LAYER_FRAME_STATS:
Dan Stozaa615e472017-03-23 14:41:55 -070090 return callLocal(data, reply, &ISurfaceComposerClient::clearLayerFrameStats);
Dan Stoza0fe41e52017-04-03 15:16:27 -070091 case Tag::GET_LAYER_FRAME_STATS:
Dan Stozaa615e472017-03-23 14:41:55 -070092 return callLocal(data, reply, &ISurfaceComposerClient::getLayerFrameStats);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080093 }
94}
95
Dan Stozaa615e472017-03-23 14:41:55 -070096} // namespace android