blob: 853e23a8cdd961452f4a6539b1983aa03ff26e13 [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 }
71
Dan Stozaa615e472017-03-23 14:41:55 -070072 status_t getTransformToDisplayInverse(const sp<IBinder>& handle,
73 bool* outTransformToDisplayInverse) const override {
74 return callRemote<decltype(
75 &ISurfaceComposerClient::
76 getTransformToDisplayInverse)>(Tag::GetTransformToDisplayInverse, handle,
77 outTransformToDisplayInverse);
Robert Carr367c5682016-06-20 11:55:28 -070078 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080079};
80
Dan Stozad723bd72014-11-18 10:24:03 -080081// Out-of-line virtual method definition to trigger vtable emission in this
82// translation unit (see clang warning -Wweak-vtables)
83BpSurfaceComposerClient::~BpSurfaceComposerClient() {}
84
Mathias Agopian7e27f052010-05-28 14:22:23 -070085IMPLEMENT_META_INTERFACE(SurfaceComposerClient, "android.ui.ISurfaceComposerClient");
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080086
87// ----------------------------------------------------------------------
88
Dan Stozaa615e472017-03-23 14:41:55 -070089status_t BnSurfaceComposerClient::onTransact(uint32_t code, const Parcel& data, Parcel* reply,
90 uint32_t flags) {
91 if (code < IBinder::FIRST_CALL_TRANSACTION || code >= static_cast<uint32_t>(Tag::Last)) {
92 return BBinder::onTransact(code, data, reply, flags);
93 }
94 auto tag = static_cast<Tag>(code);
95 switch (tag) {
96 case Tag::CreateSurface: {
97 return callLocal(data, reply, &ISurfaceComposerClient::createSurface);
Dan Stozad723bd72014-11-18 10:24:03 -080098 }
Dan Stozaa615e472017-03-23 14:41:55 -070099 case Tag::DestroySurface: {
100 return callLocal(data, reply, &ISurfaceComposerClient::destroySurface);
Dan Stozad723bd72014-11-18 10:24:03 -0800101 }
Dan Stozaa615e472017-03-23 14:41:55 -0700102 case Tag::ClearLayerFrameStats: {
103 return callLocal(data, reply, &ISurfaceComposerClient::clearLayerFrameStats);
Dan Stozad723bd72014-11-18 10:24:03 -0800104 }
Dan Stozaa615e472017-03-23 14:41:55 -0700105 case Tag::GetLayerFrameStats: {
106 return callLocal(data, reply, &ISurfaceComposerClient::getLayerFrameStats);
Dan Stozad723bd72014-11-18 10:24:03 -0800107 }
Dan Stozaa615e472017-03-23 14:41:55 -0700108 case Tag::GetTransformToDisplayInverse: {
109 return callLocal(data, reply, &ISurfaceComposerClient::getTransformToDisplayInverse);
Robert Carr367c5682016-06-20 11:55:28 -0700110 }
Dan Stozaa615e472017-03-23 14:41:55 -0700111 case Tag::Last:
112 // Should not be possible because of the check at the beginning of the method
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800113 return BBinder::onTransact(code, data, reply, flags);
114 }
115}
116
Dan Stozaa615e472017-03-23 14:41:55 -0700117} // namespace android