| 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 |  | 
|  | 17 | #ifndef ANDROID_UI_PATCH_H | 
|  | 18 | #define ANDROID_UI_PATCH_H | 
|  | 19 |  | 
|  | 20 | #include <sys/types.h> | 
|  | 21 |  | 
| Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 22 | #include "Vertex.h" | 
|  | 23 |  | 
|  | 24 | namespace android { | 
|  | 25 | namespace uirenderer { | 
|  | 26 |  | 
|  | 27 | /** | 
|  | 28 | * Description of a patch. | 
|  | 29 | */ | 
|  | 30 | struct PatchDescription { | 
|  | 31 | PatchDescription(): xCount(0), yCount(0) { } | 
|  | 32 | PatchDescription(const uint32_t xCount, const uint32_t yCount): | 
|  | 33 | xCount(xCount), yCount(yCount) { } | 
|  | 34 | PatchDescription(const PatchDescription& description): | 
|  | 35 | xCount(description.xCount), yCount(description.yCount) { } | 
|  | 36 |  | 
|  | 37 | uint32_t xCount; | 
|  | 38 | uint32_t yCount; | 
|  | 39 |  | 
|  | 40 | bool operator<(const PatchDescription& rhs) const { | 
|  | 41 | if (xCount == rhs.xCount) { | 
|  | 42 | return yCount < rhs.yCount; | 
|  | 43 | } | 
|  | 44 | return xCount < rhs.xCount; | 
|  | 45 | } | 
|  | 46 |  | 
|  | 47 | bool operator==(const PatchDescription& rhs) const { | 
|  | 48 | return xCount == rhs.xCount && yCount == rhs.yCount; | 
|  | 49 | } | 
|  | 50 | }; // struct PatchDescription | 
|  | 51 |  | 
|  | 52 | /** | 
|  | 53 | * An OpenGL patch. This contains an array of vertices and an array of | 
|  | 54 | * indices to render the vertices. | 
|  | 55 | */ | 
|  | 56 | struct Patch { | 
| Romain Guy | fb5e23c | 2010-07-09 13:52:56 -0700 | [diff] [blame] | 57 | Patch(const uint32_t xCount, const uint32_t yCount); | 
|  | 58 | ~Patch(); | 
| Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 59 |  | 
| Romain Guy | 759ea80 | 2010-09-16 20:49:46 -0700 | [diff] [blame^] | 60 | void updateVertices(const float bitmapWidth, const float bitmapHeight, | 
|  | 61 | float left, float top, float right, float bottom, | 
|  | 62 | const int32_t* xDivs, const int32_t* yDivs, | 
| Romain Guy | fb5e23c | 2010-07-09 13:52:56 -0700 | [diff] [blame] | 63 | const uint32_t width, const uint32_t height); | 
| Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 64 |  | 
|  | 65 | TextureVertex* vertices; | 
|  | 66 | uint32_t verticesCount; | 
| Romain Guy | fb5e23c | 2010-07-09 13:52:56 -0700 | [diff] [blame] | 67 |  | 
|  | 68 | private: | 
| Romain Guy | 6820ac8 | 2010-09-15 18:11:50 -0700 | [diff] [blame] | 69 | static inline void generateRow(TextureVertex*& vertex, float y1, float y2, | 
|  | 70 | float v1, float v2, const int32_t xDivs[], uint32_t xCount, | 
|  | 71 | float stretchX, float width, float bitmapWidth); | 
| Romain Guy | 759ea80 | 2010-09-16 20:49:46 -0700 | [diff] [blame^] | 72 | static inline void generateQuad(TextureVertex*& vertex, | 
|  | 73 | float x1, float y1, float x2, float y2, | 
| Romain Guy | 6820ac8 | 2010-09-15 18:11:50 -0700 | [diff] [blame] | 74 | float u1, float v1, float u2, float v2); | 
| Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 75 | }; // struct Patch | 
|  | 76 |  | 
|  | 77 | }; // namespace uirenderer | 
|  | 78 | }; // namespace android | 
|  | 79 |  | 
|  | 80 | #endif // ANDROID_UI_PATCH_H |