summaryrefslogtreecommitdiffstats
path: root/libs/hwui/OpenGLRenderer.cpp
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2011-03-21 13:11:28 -0700
committerRomain Guy <romainguy@google.com>2011-03-21 13:11:49 -0700
commited6fcb034b44d9a6ac2fc72fee6030417811f234 (patch)
tree42a469fd5b0eabb1fd3b6a34243d57c081eee764 /libs/hwui/OpenGLRenderer.cpp
parent67ac217a81f34ee3d35df84b38f3456843c40706 (diff)
downloadframeworks_base-ed6fcb034b44d9a6ac2fc72fee6030417811f234.zip
frameworks_base-ed6fcb034b44d9a6ac2fc72fee6030417811f234.tar.gz
frameworks_base-ed6fcb034b44d9a6ac2fc72fee6030417811f234.tar.bz2
Add support for drawPoint() and drawPoints().
Change-Id: I01bef50c08ec3160f8d40dc060b2cf6c2e4d7639
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
-rw-r--r--libs/hwui/OpenGLRenderer.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index a711289..6c454a4 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -879,6 +879,11 @@ void OpenGLRenderer::setupDrawWithTexture(bool isAlpha8) {
mDescription.hasAlpha8Texture = isAlpha8;
}
+void OpenGLRenderer::setupDrawPoint(float pointSize) {
+ mDescription.isPoint = true;
+ mDescription.pointSize = pointSize;
+}
+
void OpenGLRenderer::setupDrawColor(int color) {
setupDrawColor(color, (color >> 24) & 0xFF);
}
@@ -987,6 +992,11 @@ void OpenGLRenderer::setupDrawModelView(float left, float top, float right, floa
}
}
+void OpenGLRenderer::setupDrawPointUniforms() {
+ int slot = mCaches.currentProgram->getUniform("pointSize");
+ glUniform1f(slot, mDescription.pointSize);
+}
+
void OpenGLRenderer::setupDrawColorUniforms() {
if (mColorSet || (mShader && mSetShaderColor)) {
mCaches.currentProgram->setColor(mColorR, mColorG, mColorB, mColorA);
@@ -1446,6 +1456,48 @@ void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {
}
}
+void OpenGLRenderer::drawPoints(float* points, int count, SkPaint* paint) {
+ if (mSnapshot->isIgnored()) return;
+
+ // TODO: The paint's cap style defines whether the points are square or circular
+ // TODO: Handle AA for round points
+
+ // A stroke width of 0 has a special meaningin Skia:
+ // it draws an unscaled 1px point
+ const bool isHairLine = paint->getStrokeWidth() == 0.0f;
+
+ int alpha;
+ SkXfermode::Mode mode;
+ getAlphaAndMode(paint, &alpha, &mode);
+
+ int verticesCount = count >> 1;
+ int generatedVerticesCount = 0;
+
+ TextureVertex pointsData[verticesCount];
+ TextureVertex* vertex = &pointsData[0];
+
+ setupDraw();
+ setupDrawPoint(isHairLine ? 1.0f : paint->getStrokeWidth());
+ setupDrawColor(paint->getColor(), alpha);
+ setupDrawColorFilter();
+ setupDrawShader();
+ setupDrawBlending(mode);
+ setupDrawProgram();
+ setupDrawModelViewIdentity();
+ setupDrawColorUniforms();
+ setupDrawColorFilterUniforms();
+ setupDrawPointUniforms();
+ setupDrawShaderIdentityUniforms();
+ setupDrawMesh(vertex);
+
+ for (int i = 0; i < count; i += 2) {
+ TextureVertex::set(vertex++, points[i], points[i + 1], 0.0f, 0.0f);
+ generatedVerticesCount++;
+ }
+
+ glDrawArrays(GL_POINTS, 0, generatedVerticesCount);
+}
+
void OpenGLRenderer::drawColor(int color, SkXfermode::Mode mode) {
// No need to check against the clip, we fill the clip region
if (mSnapshot->isIgnored()) return;