Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_HWUI_PATCH_H |
| 18 | #define ANDROID_HWUI_PATCH_H |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 19 | |
| 20 | #include <sys/types.h> |
| 21 | |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 22 | #include <GLES2/gl2.h> |
| 23 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 24 | #include <utils/Vector.h> |
| 25 | |
| 26 | #include "Rect.h" |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 27 | #include "Vertex.h" |
Romain Guy | 4bb9420 | 2010-10-12 15:59:26 -0700 | [diff] [blame] | 28 | #include "utils/Compare.h" |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 29 | |
| 30 | namespace android { |
| 31 | namespace uirenderer { |
| 32 | |
Romain Guy | 4bb9420 | 2010-10-12 15:59:26 -0700 | [diff] [blame] | 33 | /////////////////////////////////////////////////////////////////////////////// |
Romain Guy | f504a2f | 2011-05-26 16:40:55 -0700 | [diff] [blame] | 34 | // Defines |
| 35 | /////////////////////////////////////////////////////////////////////////////// |
| 36 | |
| 37 | #define EXPLODE_GAP 4 |
| 38 | |
| 39 | /////////////////////////////////////////////////////////////////////////////// |
Romain Guy | 4bb9420 | 2010-10-12 15:59:26 -0700 | [diff] [blame] | 40 | // 9-patch structures |
| 41 | /////////////////////////////////////////////////////////////////////////////// |
| 42 | |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 43 | /** |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 44 | * An OpenGL patch. This contains an array of vertices and an array of |
| 45 | * indices to render the vertices. |
| 46 | */ |
| 47 | struct Patch { |
Romain Guy | 4bb9420 | 2010-10-12 15:59:26 -0700 | [diff] [blame] | 48 | Patch(const uint32_t xCount, const uint32_t yCount, const int8_t emptyQuads = 0); |
Romain Guy | fb5e23c | 2010-07-09 13:52:56 -0700 | [diff] [blame] | 49 | ~Patch(); |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 50 | |
Romain Guy | 759ea80 | 2010-09-16 20:49:46 -0700 | [diff] [blame] | 51 | void updateVertices(const float bitmapWidth, const float bitmapHeight, |
Romain Guy | 6f72beb | 2010-11-30 12:04:14 -0800 | [diff] [blame] | 52 | float left, float top, float right, float bottom); |
| 53 | |
| 54 | void updateColorKey(const uint32_t colorKey); |
| 55 | void copy(const int32_t* xDivs, const int32_t* yDivs); |
| 56 | bool matches(const int32_t* xDivs, const int32_t* yDivs, const uint32_t colorKey); |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 57 | |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 58 | GLuint meshBuffer; |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 59 | uint32_t verticesCount; |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 60 | bool hasEmptyQuads; |
Romain Guy | a5ef39a | 2010-12-03 16:48:20 -0800 | [diff] [blame] | 61 | Vector<Rect> quads; |
Romain Guy | fb5e23c | 2010-07-09 13:52:56 -0700 | [diff] [blame] | 62 | |
| 63 | private: |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 64 | TextureVertex* mVertices; |
Romain Guy | 6f72beb | 2010-11-30 12:04:14 -0800 | [diff] [blame] | 65 | bool mUploaded; |
| 66 | |
Romain Guy | 6f72beb | 2010-11-30 12:04:14 -0800 | [diff] [blame] | 67 | int32_t* mXDivs; |
Romain Guy | 6f72beb | 2010-11-30 12:04:14 -0800 | [diff] [blame] | 68 | int32_t* mYDivs; |
| 69 | uint32_t mColorKey; |
| 70 | |
Romain Guy | a5ef39a | 2010-12-03 16:48:20 -0800 | [diff] [blame] | 71 | uint32_t mXCount; |
| 72 | uint32_t mYCount; |
| 73 | int8_t mEmptyQuads; |
| 74 | |
Romain Guy | 6f72beb | 2010-11-30 12:04:14 -0800 | [diff] [blame] | 75 | void copy(const int32_t* yDivs); |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 76 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 77 | void generateRow(TextureVertex*& vertex, float y1, float y2, |
Romain Guy | 41d35ae | 2012-10-10 16:06:04 -0700 | [diff] [blame^] | 78 | float v1, float v2, float stretchX, float rescaleX, |
| 79 | float width, float bitmapWidth, uint32_t& quadCount); |
Romain Guy | 7444da5 | 2011-01-17 10:53:31 -0800 | [diff] [blame] | 80 | void generateQuad(TextureVertex*& vertex, |
Romain Guy | 759ea80 | 2010-09-16 20:49:46 -0700 | [diff] [blame] | 81 | float x1, float y1, float x2, float y2, |
Romain Guy | 4bb9420 | 2010-10-12 15:59:26 -0700 | [diff] [blame] | 82 | float u1, float v1, float u2, float v2, |
Romain Guy | eb6a4a1 | 2011-01-18 14:02:16 -0800 | [diff] [blame] | 83 | uint32_t& quadCount); |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 84 | }; // struct Patch |
| 85 | |
| 86 | }; // namespace uirenderer |
| 87 | }; // namespace android |
| 88 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 89 | #endif // ANDROID_HWUI_PATCH_H |