blob: 96155d7458b1b3b48450c0459450a8e4ce51d1c4 [file] [log] [blame]
The Android Open Source Project9066cfe2009-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
Mathias Agopian1473f462009-04-10 14:24:30 -070017#define LOG_TAG "ISurface"
18
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080019#include <stdio.h>
20#include <stdint.h>
21#include <sys/types.h>
22
Mathias Agopian07952722009-05-19 19:08:10 -070023#include <binder/Parcel.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024
Mathias Agopian7bb843c2011-04-20 14:20:59 -070025#include <gui/ISurfaceTexture.h>
Mathias Agopian000479f2010-02-09 17:46:37 -080026#include <surfaceflinger/ISurface.h>
27
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028namespace android {
29
Mathias Agopian1473f462009-04-10 14:24:30 -070030// ----------------------------------------------------------------------
31
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032class BpSurface : public BpInterface<ISurface>
33{
34public:
35 BpSurface(const sp<IBinder>& impl)
36 : BpInterface<ISurface>(impl)
37 {
38 }
39
Mathias Agopian7bb843c2011-04-20 14:20:59 -070040 virtual sp<ISurfaceTexture> getSurfaceTexture() const {
Mathias Agopian1473f462009-04-10 14:24:30 -070041 Parcel data, reply;
42 data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
Mathias Agopian7bb843c2011-04-20 14:20:59 -070043 remote()->transact(GET_SURFACE_TEXTURE, data, &reply);
44 return interface_cast<ISurfaceTexture>(reply.readStrongBinder());
Mathias Agopian59751db2010-05-07 15:58:44 -070045 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046};
47
48IMPLEMENT_META_INTERFACE(Surface, "android.ui.ISurface");
49
50// ----------------------------------------------------------------------
51
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052status_t BnSurface::onTransact(
53 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
54{
55 switch(code) {
Mathias Agopian7bb843c2011-04-20 14:20:59 -070056 case GET_SURFACE_TEXTURE: {
Mathias Agopian1473f462009-04-10 14:24:30 -070057 CHECK_INTERFACE(ISurface, data, reply);
Mathias Agopian7bb843c2011-04-20 14:20:59 -070058 reply->writeStrongBinder( getSurfaceTexture()->asBinder() );
Mathias Agopian59751db2010-05-07 15:58:44 -070059 return NO_ERROR;
60 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080061 default:
62 return BBinder::onTransact(code, data, reply, flags);
63 }
64}
65
66}; // namespace android