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 | |
| 17 | #ifndef ANDROID_LAYER_ORIENTATION_ANIM_H |
| 18 | #define ANDROID_LAYER_ORIENTATION_ANIM_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | #include <utils/threads.h> |
| 23 | #include <utils/Parcel.h> |
| 24 | |
| 25 | #include "LayerBase.h" |
| 26 | #include "LayerBitmap.h" |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | // --------------------------------------------------------------------------- |
| 31 | class OrientationAnimation; |
| 32 | |
Mathias Agopian | 89a1872 | 2009-03-27 15:36:09 -0700 | [diff] [blame] | 33 | |
| 34 | class LayerOrientationAnimBase : public LayerBase |
| 35 | { |
| 36 | public: |
| 37 | LayerOrientationAnimBase(SurfaceFlinger* flinger, DisplayID display) |
| 38 | : LayerBase(flinger, display) { |
| 39 | } |
| 40 | virtual void onOrientationCompleted() = 0; |
| 41 | }; |
| 42 | |
| 43 | // --------------------------------------------------------------------------- |
| 44 | |
| 45 | class LayerOrientationAnim : public LayerOrientationAnimBase |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | { |
| 47 | public: |
| 48 | static const uint32_t typeInfo; |
| 49 | static const char* const typeID; |
| 50 | virtual char const* getTypeID() const { return typeID; } |
| 51 | virtual uint32_t getTypeInfo() const { return typeInfo; } |
| 52 | |
| 53 | LayerOrientationAnim(SurfaceFlinger* flinger, DisplayID display, |
| 54 | OrientationAnimation* anim, |
Mathias Agopian | 89a1872 | 2009-03-27 15:36:09 -0700 | [diff] [blame] | 55 | const LayerBitmap& bitmapIn, |
| 56 | const LayerBitmap& bitmapOut); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | virtual ~LayerOrientationAnim(); |
| 58 | |
| 59 | void onOrientationCompleted(); |
| 60 | |
| 61 | virtual void onDraw(const Region& clip) const; |
| 62 | virtual Point getPhysicalSize() const; |
| 63 | virtual void validateVisibility(const Transform& globalTransform); |
| 64 | virtual bool needsBlending() const; |
| 65 | virtual bool isSecure() const { return false; } |
| 66 | private: |
Mathias Agopian | 89a1872 | 2009-03-27 15:36:09 -0700 | [diff] [blame] | 67 | void drawScaled(float scale, float alphaIn, float alphaOut) const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | |
Mathias Agopian | 89a1872 | 2009-03-27 15:36:09 -0700 | [diff] [blame] | 69 | class Lerp { |
| 70 | float in; |
| 71 | float outMinusIn; |
| 72 | public: |
| 73 | Lerp() : in(0), outMinusIn(0) { } |
| 74 | Lerp(float in, float out) : in(in), outMinusIn(out-in) { } |
| 75 | float getIn() const { return in; }; |
| 76 | float getOut() const { return in + outMinusIn; } |
| 77 | void set(float in, float out) { |
| 78 | this->in = in; |
| 79 | this->outMinusIn = out-in; |
| 80 | } |
| 81 | void setIn(float in) { |
| 82 | this->in = in; |
| 83 | } |
| 84 | void setOut(float out) { |
| 85 | this->outMinusIn = out - this->in; |
| 86 | } |
| 87 | float operator()(float t) const { |
| 88 | return outMinusIn*t + in; |
| 89 | } |
| 90 | }; |
| 91 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | OrientationAnimation* mAnim; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | LayerBitmap mBitmapIn; |
Mathias Agopian | 89a1872 | 2009-03-27 15:36:09 -0700 | [diff] [blame] | 94 | LayerBitmap mBitmapOut; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | nsecs_t mStartTime; |
| 96 | nsecs_t mFinishTime; |
| 97 | bool mOrientationCompleted; |
| 98 | mutable bool mFirstRedraw; |
| 99 | mutable float mLastNormalizedTime; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | mutable GLuint mTextureName; |
| 101 | mutable GLuint mTextureNameIn; |
| 102 | mutable bool mNeedsBlending; |
Mathias Agopian | 89a1872 | 2009-03-27 15:36:09 -0700 | [diff] [blame] | 103 | |
| 104 | mutable Lerp mAlphaInLerp; |
| 105 | mutable Lerp mAlphaOutLerp; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | // --------------------------------------------------------------------------- |
| 109 | |
| 110 | }; // namespace android |
| 111 | |
| 112 | #endif // ANDROID_LAYER_ORIENTATION_ANIM_H |