blob: 0b4835effd3acf90d6617020ac62217d503cdbbb [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_TRANSFORM_H
18#define ANDROID_TRANSFORM_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <ui/Point.h>
24#include <ui/Rect.h>
25
26#include <GLES/gl.h>
27
28#include <core/SkMatrix.h>
29
30namespace android {
31
32class Region;
33
34// ---------------------------------------------------------------------------
35
36class Transform
37{
38public:
39 Transform();
40 Transform(const Transform& other);
41 ~Transform();
42
43 enum orientation_flags {
44 ROT_0 = 0x00000000,
45 FLIP_H = 0x00000001,
46 FLIP_V = 0x00000002,
47 ROT_90 = 0x00000004,
48 ROT_180 = FLIP_H|FLIP_V,
49 ROT_270 = ROT_180|ROT_90,
50 ROT_INVALID = 0x80000000
51 };
52
53 bool transformed() const;
54 int32_t getOrientation() const;
55 bool preserveRects() const;
56
57 int tx() const;
58 int ty() const;
59
60 void reset();
61 void set(float xx, float xy, float yx, float yy);
62 void set(int tx, int ty);
Mathias Agopian7c143aa2009-03-24 22:50:50 -070063
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080064 Rect makeBounds(int w, int h) const;
65 void transform(GLfixed* point, int x, int y) const;
66 Region transform(const Region& reg) const;
67 Rect transform(const Rect& bounds) const;
68
69 Transform operator * (const Transform& rhs) const;
70 float operator [] (int i) const;
71
72 inline uint32_t getType() const { return type(); }
73
74 inline Transform(bool) : mType(0xFF) { };
75
76private:
77 uint8_t type() const;
78
79private:
80 SkMatrix mTransform;
81 mutable uint32_t mType;
82};
83
84// ---------------------------------------------------------------------------
85}; // namespace android
86
87#endif /* ANDROID_TRANSFORM_H */