/libs/hwui/Patch.h

http://github.com/CyanogenMod/android_frameworks_base · C Header · 74 lines · 36 code · 17 blank · 21 comment · 0 complexity · 2ff0a218edbe8612a619583633404a5d MD5 · raw file

  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. #ifndef ANDROID_HWUI_PATCH_H
  17. #define ANDROID_HWUI_PATCH_H
  18. #include <sys/types.h>
  19. #include <GLES2/gl2.h>
  20. #include <androidfw/ResourceTypes.h>
  21. #include "Rect.h"
  22. #include "UvMapper.h"
  23. #include <vector>
  24. namespace android {
  25. namespace uirenderer {
  26. struct TextureVertex;
  27. ///////////////////////////////////////////////////////////////////////////////
  28. // 9-patch structures
  29. ///////////////////////////////////////////////////////////////////////////////
  30. class Patch {
  31. public:
  32. Patch(const float bitmapWidth, const float bitmapHeight,
  33. float width, float height,
  34. const UvMapper& mapper, const Res_png_9patch* patch);
  35. /**
  36. * Returns the size of this patch's mesh in bytes.
  37. */
  38. uint32_t getSize() const;
  39. std::unique_ptr<TextureVertex[]> vertices;
  40. uint32_t verticesCount = 0;
  41. uint32_t indexCount = 0;
  42. bool hasEmptyQuads = false;
  43. std::vector<Rect> quads;
  44. GLintptr positionOffset = 0;
  45. GLintptr textureOffset = 0;
  46. private:
  47. void generateRow(const int32_t* xDivs, uint32_t xCount, TextureVertex*& vertex,
  48. float y1, float y2, float v1, float v2, float stretchX, float rescaleX,
  49. float width, float bitmapWidth, uint32_t& quadCount);
  50. void generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2,
  51. float u1, float v1, float u2, float v2, uint32_t& quadCount);
  52. const uint32_t* mColors;
  53. UvMapper mUvMapper;
  54. }; // struct Patch
  55. }; // namespace uirenderer
  56. }; // namespace android
  57. #endif // ANDROID_HWUI_PATCH_H