2010-07-08 19:17:03 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2010-10-27 18:57:51 -07:00
|
|
|
#ifndef ANDROID_HWUI_PATCH_H
|
|
|
|
#define ANDROID_HWUI_PATCH_H
|
2010-07-08 19:17:03 -07:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2010-10-18 14:06:08 -07:00
|
|
|
#include <GLES2/gl2.h>
|
|
|
|
|
2010-10-27 18:57:51 -07:00
|
|
|
#include <utils/Vector.h>
|
|
|
|
|
|
|
|
#include "Rect.h"
|
2010-07-08 19:17:03 -07:00
|
|
|
#include "Vertex.h"
|
2010-10-12 15:59:26 -07:00
|
|
|
#include "utils/Compare.h"
|
2010-07-08 19:17:03 -07:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
namespace uirenderer {
|
|
|
|
|
2011-05-26 16:40:55 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Defines
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define EXPLODE_GAP 4
|
|
|
|
|
2010-10-12 15:59:26 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 9-patch structures
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-07-08 19:17:03 -07:00
|
|
|
/**
|
|
|
|
* An OpenGL patch. This contains an array of vertices and an array of
|
|
|
|
* indices to render the vertices.
|
|
|
|
*/
|
|
|
|
struct Patch {
|
2010-10-12 15:59:26 -07:00
|
|
|
Patch(const uint32_t xCount, const uint32_t yCount, const int8_t emptyQuads = 0);
|
2010-07-09 13:52:56 -07:00
|
|
|
~Patch();
|
2010-07-08 19:17:03 -07:00
|
|
|
|
2010-09-16 20:49:46 -07:00
|
|
|
void updateVertices(const float bitmapWidth, const float bitmapHeight,
|
2010-11-30 12:04:14 -08:00
|
|
|
float left, float top, float right, float bottom);
|
|
|
|
|
|
|
|
void updateColorKey(const uint32_t colorKey);
|
|
|
|
void copy(const int32_t* xDivs, const int32_t* yDivs);
|
|
|
|
bool matches(const int32_t* xDivs, const int32_t* yDivs, const uint32_t colorKey);
|
2010-07-08 19:17:03 -07:00
|
|
|
|
2010-10-18 14:06:08 -07:00
|
|
|
GLuint meshBuffer;
|
2010-07-08 19:17:03 -07:00
|
|
|
uint32_t verticesCount;
|
2010-10-27 18:57:51 -07:00
|
|
|
bool hasEmptyQuads;
|
2010-12-03 16:48:20 -08:00
|
|
|
Vector<Rect> quads;
|
2010-07-09 13:52:56 -07:00
|
|
|
|
|
|
|
private:
|
2010-10-18 14:06:08 -07:00
|
|
|
TextureVertex* mVertices;
|
2010-11-30 12:04:14 -08:00
|
|
|
bool mUploaded;
|
|
|
|
|
|
|
|
int32_t* mXDivs;
|
|
|
|
int32_t* mYDivs;
|
|
|
|
uint32_t mColorKey;
|
|
|
|
|
2010-12-03 16:48:20 -08:00
|
|
|
uint32_t mXCount;
|
|
|
|
uint32_t mYCount;
|
|
|
|
int8_t mEmptyQuads;
|
|
|
|
|
2010-11-30 12:04:14 -08:00
|
|
|
void copy(const int32_t* yDivs);
|
2010-10-18 14:06:08 -07:00
|
|
|
|
2010-10-27 18:57:51 -07:00
|
|
|
void generateRow(TextureVertex*& vertex, float y1, float y2,
|
2010-11-30 12:04:14 -08:00
|
|
|
float v1, float v2, float stretchX, float width, float bitmapWidth,
|
2011-01-18 14:02:16 -08:00
|
|
|
uint32_t& quadCount);
|
2011-01-17 10:53:31 -08:00
|
|
|
void generateQuad(TextureVertex*& vertex,
|
2010-09-16 20:49:46 -07:00
|
|
|
float x1, float y1, float x2, float y2,
|
2010-10-12 15:59:26 -07:00
|
|
|
float u1, float v1, float u2, float v2,
|
2011-01-18 14:02:16 -08:00
|
|
|
uint32_t& quadCount);
|
2010-07-08 19:17:03 -07:00
|
|
|
}; // struct Patch
|
|
|
|
|
|
|
|
}; // namespace uirenderer
|
|
|
|
}; // namespace android
|
|
|
|
|
2010-10-27 18:57:51 -07:00
|
|
|
#endif // ANDROID_HWUI_PATCH_H
|