OSDN Git Service

delete old and unused source files
authorMathias Agopian <mathias@google.com>
Mon, 7 Sep 2009 23:33:36 +0000 (16:33 -0700)
committerMathias Agopian <mathias@google.com>
Mon, 7 Sep 2009 23:33:36 +0000 (16:33 -0700)
libs/surfaceflinger/purgatory/GPUHardware/GPUHardware.cpp [deleted file]
libs/surfaceflinger/purgatory/GPUHardware/GPUHardware.h [deleted file]
libs/surfaceflinger/purgatory/LayerOrientationAnim.cpp [deleted file]
libs/surfaceflinger/purgatory/LayerOrientationAnim.h [deleted file]
libs/surfaceflinger/purgatory/LayerOrientationAnimRotate.cpp [deleted file]
libs/surfaceflinger/purgatory/LayerOrientationAnimRotate.h [deleted file]
libs/surfaceflinger/purgatory/OrientationAnimation.cpp [deleted file]
libs/surfaceflinger/purgatory/OrientationAnimation.h [deleted file]
libs/surfaceflinger/purgatory/VRamHeap.cpp [deleted file]
libs/surfaceflinger/purgatory/VRamHeap.h [deleted file]

diff --git a/libs/surfaceflinger/purgatory/GPUHardware/GPUHardware.cpp b/libs/surfaceflinger/purgatory/GPUHardware/GPUHardware.cpp
deleted file mode 100644 (file)
index 2de628b..0000000
+++ /dev/null
@@ -1,585 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-#define LOG_TAG "SurfaceFlinger"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <math.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-
-#include <cutils/log.h>
-#include <cutils/properties.h>
-
-#include <binder/IBinder.h>
-#include <binder/MemoryDealer.h>
-#include <binder/MemoryBase.h>
-#include <binder/MemoryHeapPmem.h>
-#include <binder/MemoryHeapBase.h>
-#include <binder/IPCThreadState.h>
-#include <utils/StopWatch.h>
-
-#include <ui/ISurfaceComposer.h>
-
-#include "VRamHeap.h"
-#include "GPUHardware.h"
-
-#if HAVE_ANDROID_OS
-#include <linux/android_pmem.h>
-#endif
-
-#include "GPUHardware/GPUHardware.h"
-
-
-/* 
- * Manage the GPU. This implementation is very specific to the G1.
- * There are no abstraction here. 
- * 
- * All this code will soon go-away and be replaced by a new architecture
- * for managing graphics accelerators.
- * 
- * In the meantime, it is conceptually possible to instantiate a
- * GPUHardwareInterface for another GPU (see GPUFactory at the bottom
- * of this file); practically... doubtful.
- * 
- */
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-class GPUClientHeap;
-class GPUAreaHeap;
-
-class GPUHardware : public GPUHardwareInterface, public IBinder::DeathRecipient
-{
-public:
-    static const int GPU_RESERVED_SIZE;
-    static const int GPUR_SIZE;
-
-            GPUHardware();
-    virtual ~GPUHardware();
-    
-    virtual void revoke(int pid);
-    virtual sp<MemoryDealer> request(int pid);
-    virtual status_t request(int pid, 
-            const sp<IGPUCallback>& callback,
-            ISurfaceComposer::gpu_info_t* gpu);
-
-    virtual status_t friendlyRevoke();
-    virtual void unconditionalRevoke();
-    
-    virtual pid_t getOwner() const { return mOwner; }
-
-    // used for debugging only...
-    virtual sp<SimpleBestFitAllocator> getAllocator() const;
-
-private:
-    
-    
-    enum {
-        NO_OWNER = -1,
-    };
-        
-    struct GPUArea {
-        sp<GPUAreaHeap>     heap;
-        sp<MemoryHeapPmem>  clientHeap;
-        sp<IMemory> map();
-    };
-    
-    struct Client {
-        pid_t       pid;
-        GPUArea     smi;
-        GPUArea     ebi;
-        GPUArea     reg;
-        void createClientHeaps();
-        void revokeAllHeaps();
-    };
-    
-    Client& getClientLocked(pid_t pid);
-    status_t requestLocked(int pid);
-    void releaseLocked();
-    void takeBackGPULocked();
-    void registerCallbackLocked(const sp<IGPUCallback>& callback,
-            Client& client);
-
-    virtual void binderDied(const wp<IBinder>& who);
-
-    mutable Mutex           mLock;
-    sp<GPUAreaHeap>         mSMIHeap;
-    sp<GPUAreaHeap>         mEBIHeap;
-    sp<GPUAreaHeap>         mREGHeap;
-
-    KeyedVector<pid_t, Client> mClients;
-    DefaultKeyedVector< wp<IBinder>, pid_t > mRegisteredClients;
-    
-    pid_t                   mOwner;
-
-    sp<MemoryDealer>        mCurrentAllocator;
-    sp<IGPUCallback>        mCallback;
-    
-    sp<SimpleBestFitAllocator>  mAllocator;
-
-    Condition               mCondition;
-};
-
-// size reserved for GPU surfaces
-// 1200 KB fits exactly:
-//  - two 320*480 16-bits double-buffered surfaces
-//  - one 320*480 32-bits double-buffered surface
-//  - one 320*240 16-bits double-buffered, 4x anti-aliased surface
-const int GPUHardware::GPU_RESERVED_SIZE  = 1200 * 1024;
-const int GPUHardware::GPUR_SIZE          = 1 * 1024 * 1024;
-
-// ---------------------------------------------------------------------------
-
-/* 
- * GPUHandle is a special IMemory given to the client. It represents their
- * handle to the GPU. Once they give it up, they loose GPU access, or if
- * they explicitly revoke their access through the binder code 1000.
- * In both cases, this triggers a callback to revoke()
- * first, and then actually powers down the chip.
- * 
- * In the case of a misbehaving app, GPUHardware can ask for an immediate
- * release of the GPU to the target process which should answer by calling
- * code 1000 on GPUHandle. If it doesn't in a timely manner, the GPU will
- * be revoked from under their feet.
- * 
- * We should never hold a strong reference on GPUHandle. In practice this
- * shouldn't be a big issue though because clients should use code 1000 and
- * not rely on the dtor being called.
- * 
- */
-
-class GPUClientHeap : public MemoryHeapPmem
-{
-public:
-    GPUClientHeap(const wp<GPUHardware>& gpu, 
-            const sp<MemoryHeapBase>& heap)
-        :  MemoryHeapPmem(heap), mGPU(gpu) { }
-protected:
-    wp<GPUHardware> mGPU;
-};
-
-class GPUAreaHeap : public MemoryHeapBase
-{
-public:
-    GPUAreaHeap(const wp<GPUHardware>& gpu,
-            const char* const vram, size_t size=0, size_t reserved=0)
-    : MemoryHeapBase(vram, size), mGPU(gpu) { 
-        if (base() != MAP_FAILED) {
-            if (reserved == 0)
-                reserved = virtualSize();
-            mAllocator = new SimpleBestFitAllocator(reserved);
-        }
-    }
-    virtual sp<MemoryHeapPmem> createClientHeap() {
-        sp<MemoryHeapBase> parentHeap(this);
-        return new GPUClientHeap(mGPU, parentHeap);
-    }
-    virtual const sp<SimpleBestFitAllocator>& getAllocator() const {
-        return mAllocator; 
-    }
-private:
-    sp<SimpleBestFitAllocator>  mAllocator;
-protected:
-    wp<GPUHardware> mGPU;
-};
-
-class GPURegisterHeap : public GPUAreaHeap
-{
-public:
-    GPURegisterHeap(const sp<GPUHardware>& gpu)
-        : GPUAreaHeap(gpu, "/dev/hw3d", GPUHardware::GPUR_SIZE) { }
-    virtual sp<MemoryHeapPmem> createClientHeap() {
-        sp<MemoryHeapBase> parentHeap(this);
-        return new MemoryHeapRegs(mGPU, parentHeap);
-    }
-private:
-    class MemoryHeapRegs : public GPUClientHeap  {
-    public:
-        MemoryHeapRegs(const wp<GPUHardware>& gpu, 
-             const sp<MemoryHeapBase>& heap)
-            : GPUClientHeap(gpu, heap) { }
-        sp<MemoryHeapPmem::MemoryPmem> createMemory(size_t offset, size_t size);
-        virtual void revoke();
-    private:
-        class GPUHandle : public MemoryHeapPmem::MemoryPmem {
-        public:
-            GPUHandle(const sp<GPUHardware>& gpu,
-                    const sp<MemoryHeapPmem>& heap)
-                : MemoryHeapPmem::MemoryPmem(heap), 
-                  mGPU(gpu), mOwner(gpu->getOwner()) { }
-            virtual ~GPUHandle();
-            virtual sp<IMemoryHeap> getMemory(
-                    ssize_t* offset, size_t* size) const;
-            virtual void revoke() { };
-            virtual status_t onTransact(
-                    uint32_t code, const Parcel& data, 
-                    Parcel* reply, uint32_t flags);
-        private:
-            void revokeNotification();
-            wp<GPUHardware> mGPU;
-            pid_t mOwner;
-        };
-    };
-};
-
-GPURegisterHeap::MemoryHeapRegs::GPUHandle::~GPUHandle() { 
-    //LOGD("GPUHandle %p released, revoking GPU", this);
-    revokeNotification(); 
-}
-void GPURegisterHeap::MemoryHeapRegs::GPUHandle::revokeNotification()  {
-    sp<GPUHardware> hw(mGPU.promote());
-    if (hw != 0) {
-        hw->revoke(mOwner);
-    }
-}
-sp<IMemoryHeap> GPURegisterHeap::MemoryHeapRegs::GPUHandle::getMemory(
-        ssize_t* offset, size_t* size) const
-{
-    sp<MemoryHeapPmem> heap = getHeap();
-    if (offset) *offset = 0;
-    if (size)   *size = heap !=0 ? heap->virtualSize() : 0;
-    return heap;
-}
-status_t GPURegisterHeap::MemoryHeapRegs::GPUHandle::onTransact(
-        uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
-{
-    status_t err = BnMemory::onTransact(code, data, reply, flags);
-    if (err == UNKNOWN_TRANSACTION && code == 1000) {
-        int callingPid = IPCThreadState::self()->getCallingPid();
-        //LOGD("pid %d voluntarily revoking gpu", callingPid);
-        if (callingPid == mOwner) {
-            revokeNotification();
-            // we've revoked the GPU, don't do it again later when we
-            // are destroyed.
-            mGPU.clear();
-        } else {
-            LOGW("%d revoking someone else's gpu? (owner=%d)",
-                    callingPid, mOwner);            
-        }
-        err = NO_ERROR;
-    }
-    return err;
-}
-
-// ---------------------------------------------------------------------------
-
-
-sp<MemoryHeapPmem::MemoryPmem> GPURegisterHeap::MemoryHeapRegs::createMemory(
-        size_t offset, size_t size)
-{
-    sp<GPUHandle> memory;
-    sp<GPUHardware> gpu = mGPU.promote();
-    if (heapID()>0 && gpu!=0) {
-#if HAVE_ANDROID_OS
-        /* this is where the GPU is powered on and the registers are mapped
-         * in the client */
-        //LOGD("ioctl(HW3D_GRANT_GPU)");
-        int err = ioctl(heapID(), HW3D_GRANT_GPU, base());
-        if (err) {
-            // it can happen if the master heap has been closed already
-            // in which case the GPU already is revoked (app crash for
-            // instance).
-            LOGW("HW3D_GRANT_GPU failed (%s), mFD=%d, base=%p",
-                    strerror(errno), heapID(), base());
-        }
-        memory = new GPUHandle(gpu, this);
-#endif
-    }
-    return memory;
-}
-
-void GPURegisterHeap::MemoryHeapRegs::revoke() 
-{
-    MemoryHeapPmem::revoke();
-#if HAVE_ANDROID_OS
-    if (heapID() > 0) {
-        //LOGD("ioctl(HW3D_REVOKE_GPU)");
-        int err = ioctl(heapID(), HW3D_REVOKE_GPU, base());
-        LOGE_IF(err, "HW3D_REVOKE_GPU failed (%s), mFD=%d, base=%p",
-                strerror(errno), heapID(), base());
-    }
-#endif
-}
-
-/*****************************************************************************/
-
-GPUHardware::GPUHardware()
-    : mOwner(NO_OWNER)
-{
-}
-
-GPUHardware::~GPUHardware()
-{
-}
-
-status_t GPUHardware::requestLocked(int pid)
-{
-    const int self_pid = getpid();
-    if (pid == self_pid) {
-        // can't use GPU from surfaceflinger's process
-        return PERMISSION_DENIED;
-    }
-
-    if (mOwner != pid) {
-        if (mREGHeap != 0) {
-            if (mOwner != NO_OWNER) {
-                // someone already has the gpu.
-                takeBackGPULocked();
-                releaseLocked();
-            }
-        } else {
-            // first time, initialize the stuff.
-            if (mSMIHeap == 0)
-                mSMIHeap = new GPUAreaHeap(this, "/dev/pmem_gpu0");
-            if (mEBIHeap == 0)
-                mEBIHeap = new GPUAreaHeap(this, 
-                        "/dev/pmem_gpu1", 0, GPU_RESERVED_SIZE);
-            mREGHeap = new GPURegisterHeap(this);
-            mAllocator = mEBIHeap->getAllocator();
-            if (mAllocator == NULL) {
-                // something went terribly wrong.
-                mSMIHeap.clear();
-                mEBIHeap.clear();
-                mREGHeap.clear();
-                return INVALID_OPERATION;
-            }
-        }
-        Client& client = getClientLocked(pid);
-        mCurrentAllocator = new MemoryDealer(client.ebi.clientHeap, mAllocator);
-        mOwner = pid;
-    }
-    return NO_ERROR;
-}
-
-sp<MemoryDealer> GPUHardware::request(int pid)
-{
-    sp<MemoryDealer> dealer;
-    Mutex::Autolock _l(mLock);
-    Client* client;
-    LOGD("pid %d requesting gpu surface (current owner = %d)", pid, mOwner);
-    if (requestLocked(pid) == NO_ERROR) {
-        dealer = mCurrentAllocator;
-        LOGD_IF(dealer!=0, "gpu surface granted to pid %d", mOwner);
-    }
-    return dealer;
-}
-
-status_t GPUHardware::request(int pid, const sp<IGPUCallback>& callback,
-        ISurfaceComposer::gpu_info_t* gpu)
-{
-    if (callback == 0)
-        return BAD_VALUE;
-
-    sp<IMemory> gpuHandle;
-    LOGD("pid %d requesting gpu core (owner = %d)", pid, mOwner);
-    Mutex::Autolock _l(mLock);
-    status_t err = requestLocked(pid);
-    if (err == NO_ERROR) {
-        // it's guaranteed to be there, be construction
-        Client& client = mClients.editValueFor(pid);
-        registerCallbackLocked(callback, client);
-        gpu->count = 2;
-        gpu->regions[0].region = client.smi.map();
-        gpu->regions[1].region = client.ebi.map();
-        gpu->regs              = client.reg.map();
-        gpu->regions[0].reserved = 0;
-        gpu->regions[1].reserved = GPU_RESERVED_SIZE;
-        if (gpu->regs != 0) {
-            //LOGD("gpu core granted to pid %d, handle base=%p",
-            //        mOwner, gpu->regs->pointer());
-        }
-        mCallback = callback;
-    } else {
-        LOGW("couldn't grant gpu core to pid %d", pid);
-    }
-    return err;
-}
-
-void GPUHardware::revoke(int pid)
-{
-    Mutex::Autolock _l(mLock);
-    if (mOwner > 0) {
-        if (pid != mOwner) {
-            LOGW("GPU owned by %d, revoke from %d", mOwner, pid);
-            return;
-        }
-        //LOGD("revoke pid=%d, owner=%d", pid, mOwner);
-        // mOwner could be <0 if the same process acquired the GPU
-        // several times without releasing it first.
-        mCondition.signal();
-        releaseLocked();
-    }
-}
-
-status_t GPUHardware::friendlyRevoke()
-{
-    Mutex::Autolock _l(mLock);
-    //LOGD("friendlyRevoke owner=%d", mOwner);
-    takeBackGPULocked();
-    releaseLocked();
-    return NO_ERROR;
-}
-
-void GPUHardware::takeBackGPULocked()
-{
-    sp<IGPUCallback> callback = mCallback;
-    mCallback.clear();
-    if (callback != 0) {
-        callback->gpuLost(); // one-way
-        mCondition.waitRelative(mLock, ms2ns(250));
-    }
-}
-
-void GPUHardware::releaseLocked()
-{
-    //LOGD("revoking gpu from pid %d", mOwner);
-    if (mOwner != NO_OWNER) {
-        // this may fail because the client might have died, and have
-        // been removed from the list.
-        ssize_t index = mClients.indexOfKey(mOwner);
-        if (index >= 0) {
-            Client& client(mClients.editValueAt(index));
-            client.revokeAllHeaps();
-        }
-        mOwner = NO_OWNER;
-        mCurrentAllocator.clear();
-        mCallback.clear();
-    }
-}
-
-GPUHardware::Client& GPUHardware::getClientLocked(pid_t pid)
-{
-    ssize_t index = mClients.indexOfKey(pid);
-    if (index < 0) {
-        Client client;
-        client.pid = pid;
-        client.smi.heap = mSMIHeap;
-        client.ebi.heap = mEBIHeap;
-        client.reg.heap = mREGHeap;
-        index = mClients.add(pid, client);
-    }
-    Client& client(mClients.editValueAt(index));
-    client.createClientHeaps();
-    return client;
-}
-
-// ----------------------------------------------------------------------------
-// for debugging / testing ...
-
-sp<SimpleBestFitAllocator> GPUHardware::getAllocator() const {
-    Mutex::Autolock _l(mLock);
-    return mAllocator;
-}
-
-void GPUHardware::unconditionalRevoke()
-{
-    Mutex::Autolock _l(mLock);
-    releaseLocked();
-}
-
-// ---------------------------------------------------------------------------
-
-sp<IMemory> GPUHardware::GPUArea::map() {
-    sp<IMemory> memory;
-    if (clientHeap != 0 && heap != 0) {
-        memory = clientHeap->mapMemory(0, heap->virtualSize());
-    }
-    return memory;
-}
-
-void GPUHardware::Client::createClientHeaps() 
-{
-    if (smi.clientHeap == 0)
-        smi.clientHeap = smi.heap->createClientHeap();
-    if (ebi.clientHeap == 0)
-        ebi.clientHeap = ebi.heap->createClientHeap();
-    if (reg.clientHeap == 0)
-        reg.clientHeap = reg.heap->createClientHeap();
-}
-
-void GPUHardware::Client::revokeAllHeaps() 
-{
-    if (smi.clientHeap != 0)
-        smi.clientHeap->revoke();
-    if (ebi.clientHeap != 0)
-        ebi.clientHeap->revoke();
-    if (reg.clientHeap != 0)
-        reg.clientHeap->revoke();
-}
-
-void GPUHardware::registerCallbackLocked(const sp<IGPUCallback>& callback,
-        Client& client)
-{
-    sp<IBinder> binder = callback->asBinder();
-    if (mRegisteredClients.add(binder, client.pid) >= 0) {
-        binder->linkToDeath(this);
-    }
-}
-
-void GPUHardware::binderDied(const wp<IBinder>& who)
-{
-    Mutex::Autolock _l(mLock);
-    pid_t pid = mRegisteredClients.valueFor(who);
-    if (pid != 0) {
-        ssize_t index = mClients.indexOfKey(pid);
-        if (index >= 0) {
-            //LOGD("*** removing client at %d", index);
-            Client& client(mClients.editValueAt(index));
-            client.revokeAllHeaps(); // not really needed in theory
-            mClients.removeItemsAt(index);
-            if (mClients.size() == 0) {
-                //LOGD("*** was last client closing everything");
-                mCallback.clear();
-                mAllocator.clear();
-                mCurrentAllocator.clear();
-                mSMIHeap.clear();
-                mREGHeap.clear();
-                
-                // NOTE: we cannot clear the EBI heap because surfaceflinger
-                // itself may be using it, since this is where surfaces
-                // are allocated. if we're in the middle of compositing 
-                // a surface (even if its process just died), we cannot
-                // rip the heap under our feet.
-                
-                mOwner = NO_OWNER;
-            }
-        }
-    }
-}
-
-// ---------------------------------------------------------------------------
-
-sp<GPUHardwareInterface> GPUFactory::getGPU()
-{
-    sp<GPUHardwareInterface> gpu;
-    if (access("/dev/hw3d", F_OK) == 0) {
-        gpu = new GPUHardware();
-    }
-    return gpu;
-}
-
-// ---------------------------------------------------------------------------
-}; // namespace android
-
diff --git a/libs/surfaceflinger/purgatory/GPUHardware/GPUHardware.h b/libs/surfaceflinger/purgatory/GPUHardware/GPUHardware.h
deleted file mode 100644 (file)
index 3354528..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-#ifndef ANDROID_GPU_HARDWARE_H
-#define ANDROID_GPU_HARDWARE_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/RefBase.h>
-#include <utils/threads.h>
-#include <utils/KeyedVector.h>
-
-#include <ui/ISurfaceComposer.h>
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-class IGPUCallback;
-
-class GPUHardwareInterface : public virtual RefBase
-{
-public:
-    virtual void                revoke(int pid) = 0;
-    virtual sp<MemoryDealer>    request(int pid) = 0;
-    virtual status_t            request(int pid, const sp<IGPUCallback>& callback,
-            ISurfaceComposer::gpu_info_t* gpu) = 0;
-
-    virtual status_t            friendlyRevoke() = 0;
-    
-    // used for debugging only...
-    virtual sp<SimpleBestFitAllocator> getAllocator() const  = 0;
-    virtual pid_t getOwner() const = 0;
-    virtual void unconditionalRevoke() = 0;
-};
-
-// ---------------------------------------------------------------------------
-
-class GPUFactory
-{    
-public:
-    // the gpu factory
-    static sp<GPUHardwareInterface> getGPU();
-};
-
-// ---------------------------------------------------------------------------
-}; // namespace android
-
-#endif // ANDROID_GPU_HARDWARE_H
diff --git a/libs/surfaceflinger/purgatory/LayerOrientationAnim.cpp b/libs/surfaceflinger/purgatory/LayerOrientationAnim.cpp
deleted file mode 100644 (file)
index 41c42d1..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * 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.
- */
-
-#define LOG_TAG "SurfaceFlinger"
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <utils/Log.h>
-#include <utils/StopWatch.h>
-
-#include "BlurFilter.h"
-#include "LayerBase.h"
-#include "LayerOrientationAnim.h"
-#include "SurfaceFlinger.h"
-#include "DisplayHardware/DisplayHardware.h"
-#include "OrientationAnimation.h"
-
-namespace android {
-// ---------------------------------------------------------------------------
-
-const uint32_t LayerOrientationAnim::typeInfo = LayerBase::typeInfo | 0x80;
-const char* const LayerOrientationAnim::typeID = "LayerOrientationAnim";
-
-// ---------------------------------------------------------------------------
-
-// Animation...
-const float DURATION = ms2ns(200);
-const float BOUNCES_PER_SECOND = 0.5f;
-//const float BOUNCES_AMPLITUDE = 1.0f/16.0f;
-const float BOUNCES_AMPLITUDE = 0;
-const float DIM_TARGET = 0.40f;
-//#define INTERPOLATED_TIME(_t)   ((_t)*(_t))
-#define INTERPOLATED_TIME(_t)   (_t)
-
-// ---------------------------------------------------------------------------
-
-LayerOrientationAnim::LayerOrientationAnim(
-        SurfaceFlinger* flinger, DisplayID display, 
-        OrientationAnimation* anim, 
-        const sp<Buffer>& bitmapIn,
-        const sp<Buffer>& bitmapOut)
-    : LayerOrientationAnimBase(flinger, display), mAnim(anim), 
-      mBitmapIn(bitmapIn), mBitmapOut(bitmapOut), 
-      mTextureName(-1), mTextureNameIn(-1)
-{
-    // blur that texture. 
-    mStartTime = systemTime();
-    mFinishTime = 0;
-    mOrientationCompleted = false;
-    mFirstRedraw = false;
-    mLastNormalizedTime = 0;
-    mNeedsBlending = false;
-    mAlphaInLerp.set(1.0f, DIM_TARGET);
-    mAlphaOutLerp.set(0.5f, 1.0f);
-}
-
-LayerOrientationAnim::~LayerOrientationAnim()
-{
-    if (mTextureName != -1U) {
-        glDeleteTextures(1, &mTextureName);
-    }
-    if (mTextureNameIn != -1U) {
-        glDeleteTextures(1, &mTextureNameIn);
-    }
-}
-
-bool LayerOrientationAnim::needsBlending() const 
-{
-    return mNeedsBlending; 
-}
-
-Point LayerOrientationAnim::getPhysicalSize() const
-{
-    const GraphicPlane& plane(graphicPlane(0));
-    const DisplayHardware& hw(plane.displayHardware());
-    return Point(hw.getWidth(), hw.getHeight());
-}
-
-void LayerOrientationAnim::validateVisibility(const Transform&)
-{
-    const Layer::State& s(drawingState());
-    const Transform tr(s.transform);
-    const Point size(getPhysicalSize());
-    uint32_t w = size.x;
-    uint32_t h = size.y;
-    mTransformedBounds = tr.makeBounds(w, h);
-    mLeft = tr.tx();
-    mTop  = tr.ty();
-    transparentRegionScreen.clear();
-    mTransformed = true;
-}
-
-void LayerOrientationAnim::onOrientationCompleted()
-{
-    mFinishTime = systemTime();
-    mOrientationCompleted = true;
-    mFirstRedraw = true;
-    mNeedsBlending = true;
-    mFlinger->invalidateLayerVisibility(this);
-}
-
-void LayerOrientationAnim::onDraw(const Region& clip) const
-{
-    const nsecs_t now = systemTime();
-    float alphaIn, alphaOut;
-    
-    if (mOrientationCompleted) {
-        if (mFirstRedraw) {
-            mFirstRedraw = false;
-            
-            // make a copy of what's on screen
-            copybit_image_t image;
-            mBitmapOut->getBitmapSurface(&image);
-            const DisplayHardware& hw(graphicPlane(0).displayHardware());
-            hw.copyBackToImage(image);
-
-            // and erase the screen for this round
-            glDisable(GL_BLEND);
-            glDisable(GL_DITHER);
-            glDisable(GL_SCISSOR_TEST);
-            glClearColor(0,0,0,0);
-            glClear(GL_COLOR_BUFFER_BIT);
-            
-            // FIXME: code below is gross
-            mNeedsBlending = false;
-            LayerOrientationAnim* self(const_cast<LayerOrientationAnim*>(this));
-            mFlinger->invalidateLayerVisibility(self);
-        }
-
-        // make sure pick-up where we left off
-        const float duration = DURATION * mLastNormalizedTime;
-        const float normalizedTime = (float(now - mFinishTime) / duration);
-        if (normalizedTime <= 1.0f) {
-            const float interpolatedTime = INTERPOLATED_TIME(normalizedTime);
-            alphaIn = mAlphaInLerp.getOut();
-            alphaOut = mAlphaOutLerp(interpolatedTime);
-        } else {
-            mAnim->onAnimationFinished();
-            alphaIn = mAlphaInLerp.getOut();
-            alphaOut = mAlphaOutLerp.getOut();
-        }
-    } else {
-        const float normalizedTime = float(now - mStartTime) / DURATION;
-        if (normalizedTime <= 1.0f) {
-            mLastNormalizedTime = normalizedTime;
-            const float interpolatedTime = INTERPOLATED_TIME(normalizedTime);
-            alphaIn = mAlphaInLerp(interpolatedTime);
-            alphaOut = 0.0f;
-        } else {
-            mLastNormalizedTime = 1.0f;
-            const float to_seconds = DURATION / seconds(1);
-            alphaIn = mAlphaInLerp.getOut();
-            if (BOUNCES_AMPLITUDE > 0.0f) {
-                const float phi = BOUNCES_PER_SECOND * 
-                        (((normalizedTime - 1.0f) * to_seconds)*M_PI*2);
-                if (alphaIn > 1.0f) alphaIn = 1.0f;
-                else if (alphaIn < 0.0f) alphaIn = 0.0f;
-                alphaIn += BOUNCES_AMPLITUDE * (1.0f - cosf(phi));
-            }
-            alphaOut = 0.0f;
-        }
-        mAlphaOutLerp.setIn(alphaIn);
-    }
-    drawScaled(1.0f, alphaIn, alphaOut);
-}
-
-void LayerOrientationAnim::drawScaled(float scale, float alphaIn, float alphaOut) const
-{
-    copybit_image_t dst;
-    const GraphicPlane& plane(graphicPlane(0));
-    const DisplayHardware& hw(plane.displayHardware());
-    //hw.getDisplaySurface(&dst);
-
-    // clear screen
-    // TODO: with update on demand, we may be able 
-    // to not erase the screen at all during the animation 
-    if (!mOrientationCompleted) {
-        if (scale==1.0f && (alphaIn>=1.0f || alphaOut>=1.0f)) {
-            // we don't need to erase the screen in that case
-        } else {
-            glDisable(GL_BLEND);
-            glDisable(GL_DITHER);
-            glDisable(GL_SCISSOR_TEST);
-            glClearColor(0,0,0,0);
-            glClear(GL_COLOR_BUFFER_BIT);
-        }
-    }
-    
-    copybit_image_t src;
-    mBitmapIn->getBitmapSurface(&src);
-
-    copybit_image_t srcOut;
-    mBitmapOut->getBitmapSurface(&srcOut);
-
-    const int w = dst.w*scale; 
-    const int h = dst.h*scale; 
-    const int xc = uint32_t(dst.w-w)/2;
-    const int yc = uint32_t(dst.h-h)/2;
-    const copybit_rect_t drect = { xc, yc, xc+w, yc+h }; 
-    const copybit_rect_t srect = { 0, 0, src.w, src.h };
-    const Region reg(Rect( drect.l, drect.t, drect.r, drect.b ));
-
-    GGLSurface t;
-    t.version = sizeof(GGLSurface);
-    t.width  = src.w;
-    t.height = src.h;
-    t.stride = src.w;
-    t.vstride= src.h;
-    t.format = src.format;
-    t.data = (GGLubyte*)(intptr_t(src.base) + src.offset);
-
-    Transform tr;
-    tr.set(scale,0,0,scale);
-    tr.set(xc, yc);
-    
-    // FIXME: we should not access mVertices and mDrawingState like that,
-    // but since we control the animation, we know it's going to work okay.
-    // eventually we'd need a more formal way of doing things like this.
-    LayerOrientationAnim& self(const_cast<LayerOrientationAnim&>(*this));
-    tr.transform(self.mVertices[0], 0, 0);
-    tr.transform(self.mVertices[1], 0, src.h);
-    tr.transform(self.mVertices[2], src.w, src.h);
-    tr.transform(self.mVertices[3], src.w, 0);
-    if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
-        // Too slow to do this in software
-        self.mDrawingState.flags |= ISurfaceComposer::eLayerFilter;
-    }
-
-    if (alphaIn > 0.0f) {
-        t.data = (GGLubyte*)(intptr_t(src.base) + src.offset);
-        if (UNLIKELY(mTextureNameIn == -1LU)) {
-            mTextureNameIn = createTexture();
-            GLuint w=0, h=0;
-            const Region dirty(Rect(t.width, t.height));
-            loadTexture(dirty, mTextureNameIn, t, w, h);
-        }
-        self.mDrawingState.alpha = int(alphaIn*255);
-        drawWithOpenGL(reg, mTextureNameIn, t);
-    }
-
-    if (alphaOut > 0.0f) {
-        t.data = (GGLubyte*)(intptr_t(srcOut.base) + srcOut.offset);
-        if (UNLIKELY(mTextureName == -1LU)) {
-            mTextureName = createTexture();
-            GLuint w=0, h=0;
-            const Region dirty(Rect(t.width, t.height));
-            loadTexture(dirty, mTextureName, t, w, h);
-        }
-        self.mDrawingState.alpha = int(alphaOut*255);
-        drawWithOpenGL(reg, mTextureName, t);
-    }
-}
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
diff --git a/libs/surfaceflinger/purgatory/LayerOrientationAnim.h b/libs/surfaceflinger/purgatory/LayerOrientationAnim.h
deleted file mode 100644 (file)
index a1a2654..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef ANDROID_LAYER_ORIENTATION_ANIM_H
-#define ANDROID_LAYER_ORIENTATION_ANIM_H
-
-#include <stdint.h>
-#include <sys/types.h>
-#include <utils/threads.h>
-#include <binder/Parcel.h>
-
-#include "LayerBase.h"
-#include "LayerBitmap.h"
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-class OrientationAnimation;
-
-
-class LayerOrientationAnimBase : public LayerBase
-{
-public:
-    LayerOrientationAnimBase(SurfaceFlinger* flinger, DisplayID display)
-        : LayerBase(flinger, display) {
-    }
-    virtual void onOrientationCompleted() = 0;
-};
-
-// ---------------------------------------------------------------------------
-
-class LayerOrientationAnim : public LayerOrientationAnimBase
-{
-public:    
-    static const uint32_t typeInfo;
-    static const char* const typeID;
-    virtual char const* getTypeID() const { return typeID; }
-    virtual uint32_t getTypeInfo() const { return typeInfo; }
-    
-                LayerOrientationAnim(SurfaceFlinger* flinger, DisplayID display,
-                        OrientationAnimation* anim, 
-                        const sp<Buffer>& bitmapIn,
-                        const sp<Buffer>& bitmapOut);
-        virtual ~LayerOrientationAnim();
-
-            void onOrientationCompleted();
-
-    virtual void onDraw(const Region& clip) const;
-    virtual Point getPhysicalSize() const;
-    virtual void validateVisibility(const Transform& globalTransform);
-    virtual bool needsBlending() const;
-    virtual bool isSecure() const       { return false; }
-private:
-    void drawScaled(float scale, float alphaIn, float alphaOut) const;
-
-    class Lerp {
-        float in;
-        float outMinusIn;
-    public:
-        Lerp() : in(0), outMinusIn(0) { }
-        Lerp(float in, float out) : in(in), outMinusIn(out-in) { }
-        float getIn() const { return in; };
-        float getOut() const { return in + outMinusIn; }
-        void set(float in, float out) { 
-            this->in = in; 
-            this->outMinusIn = out-in; 
-        }
-        void setIn(float in) { 
-            this->in = in; 
-        }
-        void setOut(float out) { 
-            this->outMinusIn = out - this->in; 
-        }
-        float operator()(float t) const { 
-            return outMinusIn*t + in; 
-        }
-    };
-    
-    OrientationAnimation* mAnim;
-    sp<Buffer> mBitmapIn;
-    sp<Buffer> mBitmapOut;
-    nsecs_t mStartTime;
-    nsecs_t mFinishTime;
-    bool mOrientationCompleted;
-    mutable bool mFirstRedraw;
-    mutable float mLastNormalizedTime;
-    mutable GLuint  mTextureName;
-    mutable GLuint  mTextureNameIn;
-    mutable bool mNeedsBlending;
-    
-    mutable Lerp mAlphaInLerp;
-    mutable Lerp mAlphaOutLerp;
-};
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_LAYER_ORIENTATION_ANIM_H
diff --git a/libs/surfaceflinger/purgatory/LayerOrientationAnimRotate.cpp b/libs/surfaceflinger/purgatory/LayerOrientationAnimRotate.cpp
deleted file mode 100644 (file)
index dc6b632..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * 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.
- */
-
-#define LOG_TAG "SurfaceFlinger"
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <utils/Log.h>
-
-#include "LayerBase.h"
-#include "LayerOrientationAnim.h"
-#include "LayerOrientationAnimRotate.h"
-#include "SurfaceFlinger.h"
-#include "DisplayHardware/DisplayHardware.h"
-#include "OrientationAnimation.h"
-
-namespace android {
-// ---------------------------------------------------------------------------
-
-const uint32_t LayerOrientationAnimRotate::typeInfo = LayerBase::typeInfo | 0x100;
-const char* const LayerOrientationAnimRotate::typeID = "LayerOrientationAnimRotate";
-
-// ---------------------------------------------------------------------------
-
-const float ROTATION = M_PI * 0.5f;
-const float ROTATION_FACTOR = 1.0f; // 1.0 or 2.0
-const float DURATION = ms2ns(200);
-const float BOUNCES_PER_SECOND = 0.8;
-const float BOUNCES_AMPLITUDE = (5.0f/180.f) * M_PI;
-
-LayerOrientationAnimRotate::LayerOrientationAnimRotate(
-        SurfaceFlinger* flinger, DisplayID display, 
-        OrientationAnimation* anim, 
-        const sp<Buffer>& bitmapIn,
-        const sp<Buffer>& bitmapOut)
-    : LayerOrientationAnimBase(flinger, display), mAnim(anim), 
-      mBitmapIn(bitmapIn), mBitmapOut(bitmapOut), 
-      mTextureName(-1), mTextureNameIn(-1)
-{
-    mStartTime = systemTime();
-    mFinishTime = 0;
-    mOrientationCompleted = false;
-    mFirstRedraw = false;
-    mLastNormalizedTime = 0;
-    mLastAngle = 0;
-    mLastScale = 0;
-    mNeedsBlending = false;
-    const GraphicPlane& plane(graphicPlane(0));
-    mOriginalTargetOrientation = plane.getOrientation(); 
-}
-
-LayerOrientationAnimRotate::~LayerOrientationAnimRotate()
-{
-    if (mTextureName != -1U) {
-        glDeleteTextures(1, &mTextureName);
-    }
-    if (mTextureNameIn != -1U) {
-        glDeleteTextures(1, &mTextureNameIn);
-    }
-}
-
-bool LayerOrientationAnimRotate::needsBlending() const 
-{
-    return mNeedsBlending; 
-}
-
-Point LayerOrientationAnimRotate::getPhysicalSize() const
-{
-    const GraphicPlane& plane(graphicPlane(0));
-    const DisplayHardware& hw(plane.displayHardware());
-    return Point(hw.getWidth(), hw.getHeight());
-}
-
-void LayerOrientationAnimRotate::validateVisibility(const Transform&)
-{
-    const Layer::State& s(drawingState());
-    const Transform tr(s.transform);
-    const Point size(getPhysicalSize());
-    uint32_t w = size.x;
-    uint32_t h = size.y;
-    mTransformedBounds = tr.makeBounds(w, h);
-    mLeft = tr.tx();
-    mTop  = tr.ty();
-    transparentRegionScreen.clear();
-    mTransformed = true;
-}
-
-void LayerOrientationAnimRotate::onOrientationCompleted()
-{
-    mFinishTime = systemTime();
-    mOrientationCompleted = true;
-    mFirstRedraw = true;
-    mNeedsBlending = true;
-    mFlinger->invalidateLayerVisibility(this);
-}
-
-void LayerOrientationAnimRotate::onDraw(const Region& clip) const
-{
-    // Animation...
-
-    const nsecs_t now = systemTime();
-    float angle, scale, alpha;
-    
-    if (mOrientationCompleted) {
-        if (mFirstRedraw) {
-            // make a copy of what's on screen
-            copybit_image_t image;
-            mBitmapIn->getBitmapSurface(&image);
-            const DisplayHardware& hw(graphicPlane(0).displayHardware());
-            hw.copyBackToImage(image);
-            
-            // FIXME: code below is gross
-            mFirstRedraw = false; 
-            mNeedsBlending = false;
-            LayerOrientationAnimRotate* self(const_cast<LayerOrientationAnimRotate*>(this));
-            mFlinger->invalidateLayerVisibility(self);
-        }
-
-        // make sure pick-up where we left off
-        const float duration = DURATION * mLastNormalizedTime;
-        const float normalizedTime = (float(now - mFinishTime) / duration);
-        if (normalizedTime <= 1.0f) {
-            const float squaredTime = normalizedTime*normalizedTime;
-            angle = (ROTATION*ROTATION_FACTOR - mLastAngle)*squaredTime + mLastAngle;
-            scale = (1.0f - mLastScale)*squaredTime + mLastScale;
-            alpha = normalizedTime;
-        } else {
-            mAnim->onAnimationFinished();
-            angle = ROTATION;
-            alpha = 1.0f;
-            scale = 1.0f;
-        }
-    } else {
-        // FIXME: works only for portrait framebuffers
-        const Point size(getPhysicalSize());
-        const float TARGET_SCALE = size.x * (1.0f / size.y);
-        const float normalizedTime = float(now - mStartTime) / DURATION;
-        if (normalizedTime <= 1.0f) {
-            mLastNormalizedTime = normalizedTime;
-            const float squaredTime = normalizedTime*normalizedTime;
-            angle = ROTATION * squaredTime;
-            scale = (TARGET_SCALE - 1.0f)*squaredTime + 1.0f;
-            alpha = 0;
-        } else {
-            mLastNormalizedTime = 1.0f;
-            angle = ROTATION;
-            if (BOUNCES_AMPLITUDE) {
-                const float to_seconds = DURATION / seconds(1);
-                const float phi = BOUNCES_PER_SECOND * 
-                (((normalizedTime - 1.0f) * to_seconds)*M_PI*2);
-                angle += BOUNCES_AMPLITUDE * sinf(phi);
-            }
-            scale = TARGET_SCALE;
-            alpha = 0;
-        }
-        mLastAngle = angle;
-        mLastScale = scale;
-    }
-    drawScaled(angle, scale, alpha);
-}
-
-void LayerOrientationAnimRotate::drawScaled(float f, float s, float alpha) const
-{
-    copybit_image_t dst;
-    const GraphicPlane& plane(graphicPlane(0));
-    const DisplayHardware& hw(plane.displayHardware());
-    //hw.getDisplaySurface(&dst);
-
-    // clear screen
-    // TODO: with update on demand, we may be able 
-    // to not erase the screen at all during the animation 
-    glDisable(GL_BLEND);
-    glDisable(GL_DITHER);
-    glDisable(GL_SCISSOR_TEST);
-    glClearColor(0,0,0,0);
-    glClear(GL_COLOR_BUFFER_BIT);
-    
-    const int w = dst.w; 
-    const int h = dst.h; 
-
-    copybit_image_t src;
-    mBitmapIn->getBitmapSurface(&src);
-    const copybit_rect_t srect = { 0, 0, src.w, src.h };
-
-
-    GGLSurface t;
-    t.version = sizeof(GGLSurface);
-    t.width  = src.w;
-    t.height = src.h;
-    t.stride = src.w;
-    t.vstride= src.h;
-    t.format = src.format;
-    t.data = (GGLubyte*)(intptr_t(src.base) + src.offset);
-
-    if (!mOriginalTargetOrientation) {
-        f = -f;
-    }
-
-    Transform tr;
-    tr.set(f, w*0.5f, h*0.5f);
-    tr.scale(s, w*0.5f, h*0.5f);
-
-    // FIXME: we should not access mVertices and mDrawingState like that,
-    // but since we control the animation, we know it's going to work okay.
-    // eventually we'd need a more formal way of doing things like this.
-    LayerOrientationAnimRotate& self(const_cast<LayerOrientationAnimRotate&>(*this));
-    tr.transform(self.mVertices[0], 0, 0);
-    tr.transform(self.mVertices[1], 0, src.h);
-    tr.transform(self.mVertices[2], src.w, src.h);
-    tr.transform(self.mVertices[3], src.w, 0);
-
-    if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
-        // Too slow to do this in software
-        self.mDrawingState.flags |= ISurfaceComposer::eLayerFilter;
-    }
-
-    if (UNLIKELY(mTextureName == -1LU)) {
-        mTextureName = createTexture();
-        GLuint w=0, h=0;
-        const Region dirty(Rect(t.width, t.height));
-        loadTexture(dirty, mTextureName, t, w, h);
-    }
-    self.mDrawingState.alpha = 255; //-int(alpha*255);
-    const Region clip(Rect( srect.l, srect.t, srect.r, srect.b ));
-    drawWithOpenGL(clip, mTextureName, t);
-    
-    if (alpha > 0) {
-        const float sign = (!mOriginalTargetOrientation) ? 1.0f : -1.0f;
-        tr.set(f + sign*(M_PI * 0.5f * ROTATION_FACTOR), w*0.5f, h*0.5f);
-        tr.scale(s, w*0.5f, h*0.5f);
-        tr.transform(self.mVertices[0], 0, 0);
-        tr.transform(self.mVertices[1], 0, src.h);
-        tr.transform(self.mVertices[2], src.w, src.h);
-        tr.transform(self.mVertices[3], src.w, 0);
-
-        copybit_image_t src;
-        mBitmapIn->getBitmapSurface(&src);
-        t.data = (GGLubyte*)(intptr_t(src.base) + src.offset);
-        if (UNLIKELY(mTextureNameIn == -1LU)) {
-            mTextureNameIn = createTexture();
-            GLuint w=0, h=0;
-            const Region dirty(Rect(t.width, t.height));
-            loadTexture(dirty, mTextureNameIn, t, w, h);
-        }
-        self.mDrawingState.alpha = int(alpha*255);
-        const Region clip(Rect( srect.l, srect.t, srect.r, srect.b ));
-        drawWithOpenGL(clip, mTextureNameIn, t);
-    }
-}
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
diff --git a/libs/surfaceflinger/purgatory/LayerOrientationAnimRotate.h b/libs/surfaceflinger/purgatory/LayerOrientationAnimRotate.h
deleted file mode 100644 (file)
index a88eec0..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef ANDROID_LAYER_ORIENTATION_ANIM_ROTATE_H
-#define ANDROID_LAYER_ORIENTATION_ANIM_ROTATE_H
-
-#include <stdint.h>
-#include <sys/types.h>
-#include <utils/threads.h>
-#include <binder/Parcel.h>
-
-#include "LayerBase.h"
-#include "LayerBitmap.h"
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-class OrientationAnimation;
-
-class LayerOrientationAnimRotate : public LayerOrientationAnimBase
-{
-public:    
-    static const uint32_t typeInfo;
-    static const char* const typeID;
-    virtual char const* getTypeID() const { return typeID; }
-    virtual uint32_t getTypeInfo() const { return typeInfo; }
-    
-    LayerOrientationAnimRotate(SurfaceFlinger* flinger, DisplayID display,
-                        OrientationAnimation* anim, 
-                        const sp<Buffer>& bitmapIn,
-                        const sp<Buffer>& bitmapOut);
-        virtual ~LayerOrientationAnimRotate();
-
-            void onOrientationCompleted();
-
-    virtual void onDraw(const Region& clip) const;
-    virtual Point getPhysicalSize() const;
-    virtual void validateVisibility(const Transform& globalTransform);
-    virtual bool needsBlending() const;
-    virtual bool isSecure() const       { return false; }
-private:
-    void drawScaled(float angle, float scale, float alpha) const;
-    
-    OrientationAnimation* mAnim;
-    sp<Buffer> mBitmapIn;
-    sp<Buffer> mBitmapOut;
-    nsecs_t mStartTime;
-    nsecs_t mFinishTime;
-    bool mOrientationCompleted;
-    int mOriginalTargetOrientation;
-    mutable bool mFirstRedraw;
-    mutable float mLastNormalizedTime;
-    mutable float mLastAngle;
-    mutable float mLastScale;
-    mutable GLuint  mTextureName;
-    mutable GLuint  mTextureNameIn;
-    mutable bool mNeedsBlending;
-};
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_LAYER_ORIENTATION_ANIM_ROTATE_H
diff --git a/libs/surfaceflinger/purgatory/OrientationAnimation.cpp b/libs/surfaceflinger/purgatory/OrientationAnimation.cpp
deleted file mode 100644 (file)
index a6c9c28..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * 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 <stdint.h>
-#include <sys/types.h>
-#include <limits.h>
-
-#include "LayerOrientationAnim.h"
-#include "LayerOrientationAnimRotate.h"
-#include "OrientationAnimation.h"
-#include "SurfaceFlinger.h"
-
-#include "DisplayHardware/DisplayHardware.h"
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-OrientationAnimation::OrientationAnimation(const sp<SurfaceFlinger>& flinger)
-    : mFlinger(flinger), mLayerOrientationAnim(NULL), mState(DONE)
-{
-}
-
-OrientationAnimation::~OrientationAnimation()
-{
-}
-
-void OrientationAnimation::onOrientationChanged(uint32_t type)
-{
-    if (mState == DONE) {
-        mType = type;
-        if (!(type & ISurfaceComposer::eOrientationAnimationDisable)) {
-            mState = PREPARE;
-        }
-    }
-}
-
-void OrientationAnimation::onAnimationFinished()
-{
-    if (mState != DONE)
-        mState = FINISH;
-}
-
-bool OrientationAnimation::run_impl()
-{
-    bool skip_frame;
-    switch (mState) {
-        default:
-        case DONE:
-            skip_frame = done();
-            break;
-        case PREPARE:
-            skip_frame = prepare();
-            break;
-        case PHASE1:
-            skip_frame = phase1();
-            break;
-        case PHASE2:
-            skip_frame = phase2();
-            break;
-        case FINISH:
-            skip_frame = finished();
-            break;
-    }
-    return skip_frame;
-}
-
-bool OrientationAnimation::done()
-{
-    return done_impl();
-}
-
-bool OrientationAnimation::prepare()
-{
-    mState = PHASE1;
-    
-    const GraphicPlane& plane(mFlinger->graphicPlane(0));
-    const DisplayHardware& hw(plane.displayHardware());
-    const uint32_t w = hw.getWidth();
-    const uint32_t h = hw.getHeight();
-
-    sp<Buffer> bitmap = new Buffer(w, h, hw.getFormat());
-    sp<Buffer> bitmapIn = new Buffer(w, h, hw.getFormat());
-
-    copybit_image_t front;
-    bitmap->getBitmapSurface(&front);
-    hw.copyFrontToImage(front); // FIXME: we need an extension to do this
-
-    sp<LayerOrientationAnimBase> l;
-    
-    if (mType & 0x80) {
-        l = new LayerOrientationAnimRotate(
-                mFlinger.get(), 0, this, bitmap, bitmapIn);
-    } else {
-        l = new LayerOrientationAnim(
-                mFlinger.get(), 0, this, bitmap, bitmapIn);
-    }
-
-    l->initStates(w, h, 0);
-    l->setLayer(INT_MAX-1);
-    mFlinger->addLayer(l);
-    mLayerOrientationAnim = l;
-    return true;
-}
-
-bool OrientationAnimation::phase1()
-{
-    if (mFlinger->isFrozen() == false) {
-        // start phase 2
-        mState = PHASE2;
-        mLayerOrientationAnim->onOrientationCompleted();
-        mLayerOrientationAnim->invalidate();
-        return true;
-        
-    }
-    mLayerOrientationAnim->invalidate();
-    return false;
-}
-
-bool OrientationAnimation::phase2()
-{
-    // do the 2nd phase of the animation
-    mLayerOrientationAnim->invalidate();
-    return false;
-}
-
-bool OrientationAnimation::finished()
-{
-    mState = DONE;
-    mFlinger->removeLayer(mLayerOrientationAnim);
-    mLayerOrientationAnim.clear();
-    return true;
-}
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
diff --git a/libs/surfaceflinger/purgatory/OrientationAnimation.h b/libs/surfaceflinger/purgatory/OrientationAnimation.h
deleted file mode 100644 (file)
index 8ba6621..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef ANDROID_ORIENTATION_ANIMATION_H
-#define ANDROID_ORIENTATION_ANIMATION_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "SurfaceFlinger.h"
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-class SurfaceFlinger;
-class MemoryDealer;
-class LayerOrientationAnim;
-
-class OrientationAnimation
-{
-public:    
-                 OrientationAnimation(const sp<SurfaceFlinger>& flinger);
-        virtual ~OrientationAnimation();
-
-   void onOrientationChanged(uint32_t type);
-   void onAnimationFinished();
-   inline bool run() {
-       if (LIKELY(mState == DONE))
-           return done_impl();
-       return run_impl();
-   }
-
-private:
-    enum {
-        DONE = 0,
-        PREPARE,
-        PHASE1,
-        PHASE2,
-        FINISH
-    };
-
-    bool run_impl();
-    inline bool done_impl() {
-        if (mFlinger->isFrozen()) {
-            // we are not allowed to draw, but pause a bit to make sure
-            // apps don't end up using the whole CPU, if they depend on
-            // surfaceflinger for synchronization.
-            usleep(8333); // 8.3ms ~ 120fps
-            return true;
-        }
-        return false;
-    }
-    
-    bool done();    
-    bool prepare();
-    bool phase1();
-    bool phase2();
-    bool finished();
-
-    sp<SurfaceFlinger> mFlinger;
-    sp< LayerOrientationAnimBase > mLayerOrientationAnim;
-    int mState;
-    uint32_t mType;
-};
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_ORIENTATION_ANIMATION_H
diff --git a/libs/surfaceflinger/purgatory/VRamHeap.cpp b/libs/surfaceflinger/purgatory/VRamHeap.cpp
deleted file mode 100644 (file)
index f3ed790..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2008 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 <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <math.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-
-#include <cutils/log.h>
-#include <cutils/properties.h>
-
-#include <utils/MemoryDealer.h>
-#include <utils/MemoryBase.h>
-#include <utils/MemoryHeapPmem.h>
-#include <utils/MemoryHeapBase.h>
-
-#include "GPUHardware/GPUHardware.h"
-#include "SurfaceFlinger.h"
-#include "VRamHeap.h"
-
-#if HAVE_ANDROID_OS
-#include <linux/android_pmem.h>
-#endif
-
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-/*
- * Amount of memory we reserve for surface, per client in PMEM
- * (PMEM is used for 2D acceleration)
- * 8 MB of address space per client should be enough.
- */
-static const int PMEM_SIZE = int(8 * 1024 * 1024);
-
-int SurfaceHeapManager::global_pmem_heap = 0;
-
-// ---------------------------------------------------------------------------
-
-SurfaceHeapManager::SurfaceHeapManager(const sp<SurfaceFlinger>& flinger, 
-        size_t clientHeapSize)
-    : mFlinger(flinger), mClientHeapSize(clientHeapSize)
-{
-    SurfaceHeapManager::global_pmem_heap = 1;
-}
-
-SurfaceHeapManager::~SurfaceHeapManager()
-{
-}
-
-void SurfaceHeapManager::onFirstRef()
-{
-    if (global_pmem_heap) {
-        const char* device = "/dev/pmem";
-        mPMemHeap = new PMemHeap(device, PMEM_SIZE);
-        if (mPMemHeap->base() == MAP_FAILED) {
-            mPMemHeap.clear();
-            global_pmem_heap = 0;
-        }
-    }
-}
-
-sp<MemoryDealer> SurfaceHeapManager::createHeap(
-        uint32_t flags,
-        pid_t client_pid,
-        const sp<MemoryDealer>& defaultAllocator)
-{
-    sp<MemoryDealer> dealer; 
-
-    if (flags & ISurfaceComposer::eGPU) {
-        // don't grant GPU memory if GPU is disabled
-        char value[PROPERTY_VALUE_MAX];
-        property_get("debug.egl.hw", value, "1");
-        if (atoi(value) == 0) {
-            flags &= ~ISurfaceComposer::eGPU;
-        }
-    }
-
-    if (flags & ISurfaceComposer::eGPU) {
-        // FIXME: this is msm7201A specific, where gpu surfaces may not be secure
-        if (!(flags & ISurfaceComposer::eSecure)) {
-            // if GPU doesn't work, we try eHardware
-            flags |= ISurfaceComposer::eHardware;
-            // asked for GPU memory, try that first
-            dealer = mFlinger->getGPU()->request(client_pid);
-        }
-    }
-
-    if (dealer == NULL) {
-        if (defaultAllocator != NULL)
-            // if a default allocator is given, use that
-            dealer = defaultAllocator;
-    }
-    
-    if (dealer == NULL) {
-        // always try h/w accelerated memory first
-        if (global_pmem_heap) {
-            const sp<PMemHeap>& heap(mPMemHeap);
-            if (dealer == NULL && heap != NULL) {
-                dealer = new MemoryDealer( 
-                        heap->createClientHeap(),
-                        heap->getAllocator());
-            }
-        }
-    }
-
-    if (dealer == NULL) {
-        // return the ashmem allocator (software rendering)
-        dealer = new MemoryDealer(mClientHeapSize, 0, "SFNativeHeap");
-    }
-    return dealer;
-}
-
-sp<SimpleBestFitAllocator> SurfaceHeapManager::getAllocator(int type) const 
-{
-    Mutex::Autolock _l(mLock);
-    sp<SimpleBestFitAllocator> allocator;
-
-    // this is only used for debugging
-    switch (type) {
-        case NATIVE_MEMORY_TYPE_PMEM:
-            if (mPMemHeap != 0) {
-                allocator = mPMemHeap->getAllocator();
-            }
-            break;
-    }
-    return allocator;
-}
-
-// ---------------------------------------------------------------------------
-
-PMemHeap::PMemHeap(const char* const device, size_t size, size_t reserved)
-    : MemoryHeapBase(device, size)
-{
-    //LOGD("%s, %p, mFD=%d", __PRETTY_FUNCTION__, this, heapID());
-    if (base() != MAP_FAILED) {
-        //LOGD("%s, %u bytes", device, virtualSize());
-        if (reserved == 0)
-            reserved = virtualSize();
-        mAllocator = new SimpleBestFitAllocator(reserved);
-    }
-}
-
-PMemHeap::~PMemHeap() {
-    //LOGD("%s, %p, mFD=%d", __PRETTY_FUNCTION__, this, heapID());
-}
-
-sp<MemoryHeapPmem> PMemHeap::createClientHeap() {
-    sp<MemoryHeapBase> parentHeap(this);
-    return new MemoryHeapPmem(parentHeap);
-}
-
-// ---------------------------------------------------------------------------
-}; // namespace android
diff --git a/libs/surfaceflinger/purgatory/VRamHeap.h b/libs/surfaceflinger/purgatory/VRamHeap.h
deleted file mode 100644 (file)
index 9140167..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-#ifndef ANDROID_VRAM_HEAP_H
-#define ANDROID_VRAM_HEAP_H
-
-#include <stdint.h>
-#include <sys/types.h>
-#include <utils/MemoryDealer.h>
-
-namespace android {
-
-// ---------------------------------------------------------------------------
-
-class PMemHeap;
-class MemoryHeapPmem;
-class SurfaceFlinger; 
-
-// ---------------------------------------------------------------------------
-
-class SurfaceHeapManager  : public RefBase
-{
-public:
-    SurfaceHeapManager(const sp<SurfaceFlinger>& flinger, size_t clientHeapSize);
-    virtual ~SurfaceHeapManager();
-    virtual void onFirstRef();
-    /* use ISurfaceComposer flags eGPU|eHArdware|eSecure */
-    sp<MemoryDealer> createHeap(uint32_t flags=0, pid_t client_pid = 0,
-            const sp<MemoryDealer>& defaultAllocator = 0);
-    
-    // used for debugging only...
-    sp<SimpleBestFitAllocator> getAllocator(int type) const;
-
-private:
-    sp<PMemHeap> getHeap(int type) const;
-
-    sp<SurfaceFlinger> mFlinger;
-    mutable Mutex   mLock;
-    size_t          mClientHeapSize;
-    sp<PMemHeap>    mPMemHeap;
-    static int global_pmem_heap;
-};
-
-// ---------------------------------------------------------------------------
-
-class PMemHeap : public MemoryHeapBase
-{
-public:
-                PMemHeap(const char* const vram,
-                        size_t size=0, size_t reserved=0);
-    virtual     ~PMemHeap();
-    
-    virtual const sp<SimpleBestFitAllocator>& getAllocator() const {
-        return mAllocator; 
-    }
-    virtual sp<MemoryHeapPmem> createClientHeap();
-    
-private:
-    sp<SimpleBestFitAllocator>  mAllocator;
-};
-
-// ---------------------------------------------------------------------------
-}; // namespace android
-
-#endif // ANDROID_VRAM_HEAP_H