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 | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 24 | #include <androidfw/ResourceTypes.h> |
| 25 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 26 | #include "Rect.h" |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 27 | #include "UvMapper.h" |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 28 | |
John Reck | 272a685 | 2015-07-29 16:48:58 -0700 | [diff] [blame] | 29 | #include <vector> |
| 30 | |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 31 | namespace android { |
| 32 | namespace uirenderer { |
| 33 | |
Chris Craik | e84a208 | 2014-12-22 14:28:49 -0800 | [diff] [blame] | 34 | struct TextureVertex; |
Tom Hudson | 2dc236b | 2014-10-15 15:46:42 -0400 | [diff] [blame] | 35 | |
Romain Guy | 4bb9420 | 2010-10-12 15:59:26 -0700 | [diff] [blame] | 36 | /////////////////////////////////////////////////////////////////////////////// |
| 37 | // 9-patch structures |
| 38 | /////////////////////////////////////////////////////////////////////////////// |
| 39 | |
Chris Craik | 564acf7 | 2014-01-02 16:46:18 -0800 | [diff] [blame] | 40 | class Patch { |
| 41 | public: |
Chris Craik | 8820fd1 | 2015-03-03 14:20:47 -0800 | [diff] [blame] | 42 | Patch(const float bitmapWidth, const float bitmapHeight, |
| 43 | float width, float height, |
| 44 | const UvMapper& mapper, const Res_png_9patch* patch); |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 45 | |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Returns the size of this patch's mesh in bytes. |
| 48 | */ |
| 49 | uint32_t getSize() const; |
Romain Guy | 6f72beb | 2010-11-30 12:04:14 -0800 | [diff] [blame] | 50 | |
Chris Craik | 51d6a3d | 2014-12-22 17:16:56 -0800 | [diff] [blame] | 51 | std::unique_ptr<TextureVertex[]> vertices; |
Chris Craik | e5c6584 | 2015-03-02 17:50:26 -0800 | [diff] [blame] | 52 | uint32_t verticesCount = 0; |
| 53 | uint32_t indexCount = 0; |
| 54 | bool hasEmptyQuads = false; |
John Reck | 272a685 | 2015-07-29 16:48:58 -0700 | [diff] [blame] | 55 | std::vector<Rect> quads; |
Romain Guy | fb5e23c | 2010-07-09 13:52:56 -0700 | [diff] [blame] | 56 | |
Chris Craik | 8820fd1 | 2015-03-03 14:20:47 -0800 | [diff] [blame] | 57 | GLintptr positionOffset = 0; |
Chris Craik | e5c6584 | 2015-03-02 17:50:26 -0800 | [diff] [blame] | 58 | GLintptr textureOffset = 0; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 59 | |
Romain Guy | fb5e23c | 2010-07-09 13:52:56 -0700 | [diff] [blame] | 60 | private: |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 61 | void generateRow(const int32_t* xDivs, uint32_t xCount, TextureVertex*& vertex, |
| 62 | float y1, float y2, float v1, float v2, float stretchX, float rescaleX, |
Romain Guy | 41d35ae | 2012-10-10 16:06:04 -0700 | [diff] [blame] | 63 | float width, float bitmapWidth, uint32_t& quadCount); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 64 | void generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2, |
| 65 | float u1, float v1, float u2, float v2, uint32_t& quadCount); |
| 66 | |
Chris Craik | 8820fd1 | 2015-03-03 14:20:47 -0800 | [diff] [blame] | 67 | const uint32_t* mColors; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 68 | UvMapper mUvMapper; |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 69 | }; // struct Patch |
| 70 | |
| 71 | }; // namespace uirenderer |
| 72 | }; // namespace android |
| 73 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 74 | #endif // ANDROID_HWUI_PATCH_H |