blob: 2d2146b3563a698827af4ca8715b9301a14f5055 [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
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080020#include <stdint.h>
Dan Stozaa615e472017-03-23 14:41:55 -070021#include <stdio.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080022#include <sys/types.h>
23
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070024#include <binder/IPCThreadState.h>
25#include <binder/IServiceManager.h>
Dan Stozaa615e472017-03-23 14:41:55 -070026#include <binder/Parcel.h>
27#include <binder/SafeInterface.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080028
Dan Stozaa615e472017-03-23 14:41:55 -070029#include <ui/FrameStats.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080030#include <ui/Point.h>
31#include <ui/Rect.h>
32
Mathias Agopian4d9b8222013-03-12 17:11:48 -070033#include <gui/IGraphicBufferProducer.h>
Mathias Agopian90ac7992012-02-25 18:48:35 -080034#include <gui/ISurfaceComposerClient.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080035
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080036namespace android {
37
Dan Stozaa615e472017-03-23 14:41:55 -070038class BpSurfaceComposerClient : public SafeBpInterface<ISurfaceComposerClient> {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080039public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070040 explicit BpSurfaceComposerClient(const sp<IBinder>& impl)
Dan Stozaa615e472017-03-23 14:41:55 -070041 : 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 Projectedbf3b62009-03-03 19:31:44 -080054 }
55
Dan Stozaa615e472017-03-23 14:41:55 -070056 status_t destroySurface(const sp<IBinder>& handle) override {
57 return callRemote<decltype(&ISurfaceComposerClient::destroySurface)>(Tag::DestroySurface,
58 handle);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080059 }
Mathias Agopian7e27f052010-05-28 14:22:23 -070060
Dan Stozaa615e472017-03-23 14:41:55 -070061 status_t clearLayerFrameStats(const sp<IBinder>& handle) const override {
62 return callRemote<decltype(
63 &ISurfaceComposerClient::clearLayerFrameStats)>(Tag::ClearLayerFrameStats, handle);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080064 }
Svetoslavd85084b2014-03-20 10:28:31 -070065
Dan Stozaa615e472017-03-23 14:41:55 -070066 status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const override {
67 return callRemote<decltype(
68 &ISurfaceComposerClient::getLayerFrameStats)>(Tag::GetLayerFrameStats, handle,
69 outStats);
Svetoslavd85084b2014-03-20 10:28:31 -070070 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080071};
72
Dan Stozad723bd72014-11-18 10:24:03 -080073// Out-of-line virtual method definition to trigger vtable emission in this
74// translation unit (see clang warning -Wweak-vtables)
75BpSurfaceComposerClient::~BpSurfaceComposerClient() {}
76
Mathias Agopian7e27f052010-05-28 14:22:23 -070077IMPLEMENT_META_INTERFACE(SurfaceComposerClient, "android.ui.ISurfaceComposerClient");
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080078
79// ----------------------------------------------------------------------
80
Dan Stozaa615e472017-03-23 14:41:55 -070081status_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 Stozad723bd72014-11-18 10:24:03 -080090 }
Dan Stozaa615e472017-03-23 14:41:55 -070091 case Tag::DestroySurface: {
92 return callLocal(data, reply, &ISurfaceComposerClient::destroySurface);
Dan Stozad723bd72014-11-18 10:24:03 -080093 }
Dan Stozaa615e472017-03-23 14:41:55 -070094 case Tag::ClearLayerFrameStats: {
95 return callLocal(data, reply, &ISurfaceComposerClient::clearLayerFrameStats);
Dan Stozad723bd72014-11-18 10:24:03 -080096 }
Dan Stozaa615e472017-03-23 14:41:55 -070097 case Tag::GetLayerFrameStats: {
98 return callLocal(data, reply, &ISurfaceComposerClient::getLayerFrameStats);
Dan Stozad723bd72014-11-18 10:24:03 -080099 }
Dan Stozaa615e472017-03-23 14:41:55 -0700100 case Tag::Last:
101 // Should not be possible because of the check at the beginning of the method
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800102 return BBinder::onTransact(code, data, reply, flags);
103 }
104}
105
Dan Stozaa615e472017-03-23 14:41:55 -0700106} // namespace android