6package org.mozilla.gecko.gfx;
8import android.graphics.RectF;
9import android.opengl.GLES20;
11import java.nio.FloatBuffer;
32 GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
33 GLES20.glEnable(GLES20.GL_BLEND);
35 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,
getTextureID());
64 page.right, page.top,
PATCH_SIZE, page.height());
68 page.left, page.bottom, page.width(),
PATCH_SIZE);
74 float tileX,
float tileY,
float tileWidth,
float tileHeight) {
76 float viewportHeight = viewport.height();
77 float drawX = tileX - viewport.left;
78 float drawY = viewportHeight - (tileY + tileHeight - viewport.top);
82 drawX/viewport.width(), drawY/viewport.height(), 0,
85 drawX/viewport.width(), (drawY+tileHeight)/viewport.height(), 0,
88 (drawX+tileWidth)/viewport.width(), drawY/viewport.height(), 0,
91 (drawX+tileWidth)/viewport.width(), (drawY+tileHeight)/viewport.height(), 0,
103 coordBuffer.position(0);
104 coordBuffer.put(coords);
107 GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
110 coordBuffer.position(0);
111 GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT,
false, 20, coordBuffer);
114 coordBuffer.position(3);
115 GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT,
false, 20, coordBuffer);
117 GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
118 GLES20.GL_CLAMP_TO_EDGE);
119 GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
120 GLES20.GL_CLAMP_TO_EDGE);
124 GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,
126 GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,
129 GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
final FloatBuffer coordBuffer
Encapsulates the logic needed to draw a nine-patch bitmap using OpenGL ES.
static final int TEXTURE_SIZE
void drawPatches(RenderContext context)
NinePatchTileLayer(CairoImage image)
static final int PATCH_SIZE
void draw(RenderContext context)
Subclasses override this function to draw the layer.
void drawPatch(RenderContext context, int textureX, int textureY, float tileX, float tileY, float tileWidth, float tileHeight)
Base class for tile layers, which encapsulate the logic needed to draw textured tiles in OpenGL ES.