1/*
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#define LOG_TAG "ISurface"
18
19#include <stdio.h>
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <binder/Parcel.h>
24
25#include <gui/ISurface.h>
26#include <gui/ISurfaceTexture.h>
27
28namespace android {
29
30// ----------------------------------------------------------------------
31
32class BpSurface : public BpInterface<ISurface>
33{
34public:
35    BpSurface(const sp<IBinder>& impl)
36        : BpInterface<ISurface>(impl)
37    {
38    }
39
40    virtual sp<ISurfaceTexture> getSurfaceTexture() const {
41        Parcel data, reply;
42        data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
43        remote()->transact(GET_SURFACE_TEXTURE, data, &reply);
44        return interface_cast<ISurfaceTexture>(reply.readStrongBinder());
45    }
46};
47
48IMPLEMENT_META_INTERFACE(Surface, "android.ui.ISurface");
49
50// ----------------------------------------------------------------------
51
52status_t BnSurface::onTransact(
53    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
54{
55    switch(code) {
56        case GET_SURFACE_TEXTURE: {
57            CHECK_INTERFACE(ISurface, data, reply);
58            reply->writeStrongBinder( getSurfaceTexture()->asBinder() );
59            return NO_ERROR;
60        }
61        default:
62            return BBinder::onTransact(code, data, reply, flags);
63    }
64}
65
66}; // namespace android
67