blob: 8c25f4513d5d0f11d3490b836afdbdde852f53db [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
Mathias Agopian076b1cc2009-04-10 14:24:30 -070017#define LOG_TAG "ISurface"
18
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080019#include <stdio.h>
20#include <stdint.h>
21#include <sys/types.h>
22
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070023#include <binder/Parcel.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080024
Mathias Agopian90ac7992012-02-25 18:48:35 -080025#include <gui/ISurface.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080026#include <gui/IGraphicBufferProducer.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080027
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080028namespace android {
29
Mathias Agopian076b1cc2009-04-10 14:24:30 -070030// ----------------------------------------------------------------------
31
The Android Open Source Projectedbf3b62009-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
Andy McFadden2adaf042012-12-18 09:49:45 -080040 virtual sp<IGraphicBufferProducer> getSurfaceTexture() const {
Mathias Agopian076b1cc2009-04-10 14:24:30 -070041 Parcel data, reply;
42 data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
Mathias Agopiana67932f2011-04-20 14:20:59 -070043 remote()->transact(GET_SURFACE_TEXTURE, data, &reply);
Andy McFadden2adaf042012-12-18 09:49:45 -080044 return interface_cast<IGraphicBufferProducer>(reply.readStrongBinder());
Mathias Agopianb5b7f262010-05-07 15:58:44 -070045 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080046};
47
48IMPLEMENT_META_INTERFACE(Surface, "android.ui.ISurface");
49
50// ----------------------------------------------------------------------
51
The Android Open Source Projectedbf3b62009-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 Agopiana67932f2011-04-20 14:20:59 -070056 case GET_SURFACE_TEXTURE: {
Mathias Agopian076b1cc2009-04-10 14:24:30 -070057 CHECK_INTERFACE(ISurface, data, reply);
Mathias Agopiana67932f2011-04-20 14:20:59 -070058 reply->writeStrongBinder( getSurfaceTexture()->asBinder() );
Mathias Agopianb5b7f262010-05-07 15:58:44 -070059 return NO_ERROR;
60 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080061 default:
62 return BBinder::onTransact(code, data, reply, flags);
63 }
64}
65
66}; // namespace android