The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 17 | #define LOG_TAG "ISurface" |
| 18 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | #include <stdio.h> |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
Mathias Agopian | 0795272 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 23 | #include <binder/Parcel.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 25 | #include <gui/ISurfaceTexture.h> |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 26 | #include <surfaceflinger/ISurface.h> |
| 27 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | namespace android { |
| 29 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 30 | // ---------------------------------------------------------------------- |
| 31 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | class BpSurface : public BpInterface<ISurface> |
| 33 | { |
| 34 | public: |
| 35 | BpSurface(const sp<IBinder>& impl) |
| 36 | : BpInterface<ISurface>(impl) |
| 37 | { |
| 38 | } |
| 39 | |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 40 | virtual sp<ISurfaceTexture> getSurfaceTexture() const { |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 41 | Parcel data, reply; |
| 42 | data.writeInterfaceToken(ISurface::getInterfaceDescriptor()); |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 43 | remote()->transact(GET_SURFACE_TEXTURE, data, &reply); |
| 44 | return interface_cast<ISurfaceTexture>(reply.readStrongBinder()); |
Mathias Agopian | 59751db | 2010-05-07 15:58:44 -0700 | [diff] [blame] | 45 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | IMPLEMENT_META_INTERFACE(Surface, "android.ui.ISurface"); |
| 49 | |
| 50 | // ---------------------------------------------------------------------- |
| 51 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | status_t BnSurface::onTransact( |
| 53 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 54 | { |
| 55 | switch(code) { |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 56 | case GET_SURFACE_TEXTURE: { |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 57 | CHECK_INTERFACE(ISurface, data, reply); |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 58 | reply->writeStrongBinder( getSurfaceTexture()->asBinder() ); |
Mathias Agopian | 59751db | 2010-05-07 15:58:44 -0700 | [diff] [blame] | 59 | return NO_ERROR; |
| 60 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | default: |
| 62 | return BBinder::onTransact(code, data, reply, flags); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | }; // namespace android |