blob: e86156dbc8b99a3a4596c6966374265f8d1a7f47 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
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>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070023#include <binder/Parcel.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080024
25#include "LayerBase.h"
26#include "LayerBitmap.h"
27
28namespace android {
29
30// ---------------------------------------------------------------------------
31class OrientationAnimation;
32
Mathias Agopian0d1318b2009-03-27 17:58:20 -070033
34class LayerOrientationAnimBase : public LayerBase
35{
36public:
37 LayerOrientationAnimBase(SurfaceFlinger* flinger, DisplayID display)
38 : LayerBase(flinger, display) {
39 }
40 virtual void onOrientationCompleted() = 0;
41};
42
43// ---------------------------------------------------------------------------
44
45class LayerOrientationAnim : public LayerOrientationAnimBase
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080046{
47public:
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 Agopian0d1318b2009-03-27 17:58:20 -070055 const LayerBitmap& bitmapIn,
56 const LayerBitmap& bitmapOut);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080057 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; }
66private:
Mathias Agopian0d1318b2009-03-27 17:58:20 -070067 void drawScaled(float scale, float alphaIn, float alphaOut) const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080068
Mathias Agopian0d1318b2009-03-27 17:58:20 -070069 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 Projectedbf3b62009-03-03 19:31:44 -080092 OrientationAnimation* mAnim;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080093 LayerBitmap mBitmapIn;
Mathias Agopian0d1318b2009-03-27 17:58:20 -070094 LayerBitmap mBitmapOut;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080095 nsecs_t mStartTime;
96 nsecs_t mFinishTime;
97 bool mOrientationCompleted;
98 mutable bool mFirstRedraw;
99 mutable float mLastNormalizedTime;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800100 mutable GLuint mTextureName;
101 mutable GLuint mTextureNameIn;
102 mutable bool mNeedsBlending;
Mathias Agopian0d1318b2009-03-27 17:58:20 -0700103
104 mutable Lerp mAlphaInLerp;
105 mutable Lerp mAlphaOutLerp;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800106};
107
108// ---------------------------------------------------------------------------
109
110}; // namespace android
111
112#endif // ANDROID_LAYER_ORIENTATION_ANIM_H