From f013e1afd1e68af5e3b868c26a653bbfb39538f8 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Wed, 17 Dec 2008 18:05:43 -0800 Subject: Code drop from //branches/cupcake/...@124589 --- libs/ui/Overlay.cpp | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 libs/ui/Overlay.cpp (limited to 'libs/ui/Overlay.cpp') diff --git a/libs/ui/Overlay.cpp b/libs/ui/Overlay.cpp new file mode 100644 index 000000000000..2267c3e7686a --- /dev/null +++ b/libs/ui/Overlay.cpp @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include +#include + +namespace android { + +Overlay::Overlay(overlay_handle_t* handle, + const sp& o, const sp& heap, + uint32_t w, uint32_t h, int32_t f, uint32_t ws, uint32_t hs) + : mOverlay(o), mHeap(heap), mCurrentBufferOffset(0), mOverlayHandle(handle), + mWidth(w), mHeight(h), mFormat(f), mWidthStride(ws), mHeightStride(hs) +{ +} + +Overlay::Overlay(overlay_t* overlay, + const sp& o, const sp& heap) + : mOverlay(o), mHeap(heap) +{ + mCurrentBufferOffset = 0; + mOverlayHandle = overlay->getHandleRef(overlay); + mWidth = overlay->w; + mHeight = overlay->h; + mFormat = overlay->format; + mWidthStride = overlay->w_stride; + mHeightStride = overlay->h_stride; +} + + +Overlay::~Overlay() { +} + +void Overlay::destroy() { + mOverlay->destroy(); +} + +status_t Overlay::swapBuffers() { + ssize_t result = mOverlay->swapBuffers(); + if (result < 0) + return status_t(result); + mCurrentBufferOffset = result; + return NO_ERROR; +} + +overlay_handle_t const* Overlay::getHandleRef() const { + return mOverlayHandle; +} + +size_t Overlay::getBufferOffset() const { + return mCurrentBufferOffset; +} + +sp Overlay::getHeap() const { + return mHeap; +} + +uint32_t Overlay::getWidth() const { + return mWidth; +} + +uint32_t Overlay::getHeight() const { + return mHeight; +} + +int32_t Overlay::getFormat() const { + return mFormat; +} + +int32_t Overlay::getWidthStride() const { + return mWidthStride; +} + +int32_t Overlay::getHeightStride() const { + return mHeightStride; +} + +sp Overlay::readFromParcel(const Parcel& data) { + sp result; + sp overlay = IOverlay::asInterface(data.readStrongBinder()); + if (overlay != NULL) { + sp heap = IMemoryHeap::asInterface(data.readStrongBinder()); + uint32_t w = data.readInt32(); + uint32_t h = data.readInt32(); + uint32_t f = data.readInt32(); + uint32_t ws = data.readInt32(); + uint32_t hs = data.readInt32(); + /* FIXME: handles should be promoted to "real" API and be handled by + * the framework */ + int numfd = data.readInt32(); + int numint = data.readInt32(); + overlay_handle_t* handle = (overlay_handle_t*)malloc( + sizeof(overlay_handle_t) + numint*sizeof(int)); + for (int i=0 ; ifds[i] = data.readFileDescriptor(); + for (int i=0 ; idata[i] = data.readInt32(); + result = new Overlay(handle, overlay, heap, w, h, f, ws, hs); + } + return result; +} + +status_t Overlay::writeToParcel(Parcel* reply, const sp& o) { + if (o != NULL) { + reply->writeStrongBinder(o->mOverlay->asBinder()); + reply->writeStrongBinder(o->mHeap->asBinder()); + reply->writeInt32(o->mWidth); + reply->writeInt32(o->mHeight); + reply->writeInt32(o->mFormat); + reply->writeInt32(o->mWidthStride); + reply->writeInt32(o->mHeightStride); + /* FIXME: handles should be promoted to "real" API and be handled by + * the framework */ + reply->writeInt32(o->mOverlayHandle->numFds); + reply->writeInt32(o->mOverlayHandle->numInts); + for (int i=0 ; imOverlayHandle->numFds ; i++) + reply->writeFileDescriptor(o->mOverlayHandle->fds[i]); + for (int i=0 ; imOverlayHandle->numInts ; i++) + reply->writeInt32(o->mOverlayHandle->data[i]); + } else { + reply->writeStrongBinder(NULL); + } + return NO_ERROR; +} + +// ---------------------------------------------------------------------------- + +}; // namespace android + -- cgit v1.2.3-59-g8ed1b