From c1cd9ba335b293f11e1082447ef08e474710a05f Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Sun, 23 Jan 2011 14:18:41 -0800 Subject: Add support for ovals and stroked rectangles. Change-Id: I1292e241386763c82e6622c8f7ed90b0f5b7bd4f --- libs/hwui/OpenGLRenderer.cpp | 46 ++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'libs/hwui/OpenGLRenderer.cpp') diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 9aa3e7cffc61..99c0600ae3eb 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -1360,14 +1360,7 @@ void OpenGLRenderer::drawColor(int color, SkXfermode::Mode mode) { drawColorRect(clip.left, clip.top, clip.right, clip.bottom, color, mode, true); } -void OpenGLRenderer::drawRoundRect(float left, float top, float right, float bottom, - float rx, float ry, SkPaint* paint) { - if (mSnapshot->isIgnored()) return; - - glActiveTexture(gTextureUnits[0]); - - const PathTexture* texture = mCaches.roundRectShapeCache.getRoundRect( - right - left, bottom - top, rx, ry, paint); +void OpenGLRenderer::drawShape(float left, float top, const PathTexture* texture, SkPaint* paint) { if (!texture) return; const AutoTexture autoCleanup(texture); @@ -1377,22 +1370,47 @@ void OpenGLRenderer::drawRoundRect(float left, float top, float right, float bot drawPathTexture(texture, x, y, paint); } -void OpenGLRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) { +void OpenGLRenderer::drawRoundRect(float left, float top, float right, float bottom, + float rx, float ry, SkPaint* paint) { if (mSnapshot->isIgnored()) return; glActiveTexture(gTextureUnits[0]); + const PathTexture* texture = mCaches.roundRectShapeCache.getRoundRect( + right - left, bottom - top, rx, ry, paint); + drawShape(left, top, texture, paint); +} +void OpenGLRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) { + if (mSnapshot->isIgnored()) return; + + glActiveTexture(gTextureUnits[0]); const PathTexture* texture = mCaches.circleShapeCache.getCircle(radius, paint); - if (!texture) return; - const AutoTexture autoCleanup(texture); + drawShape(x - radius, y - radius, texture, paint); +} - const float left = (x - radius) + texture->left - texture->offset; - const float top = (y - radius) + texture->top - texture->offset; +void OpenGLRenderer::drawOval(float left, float top, float right, float bottom, SkPaint* paint) { + if (mSnapshot->isIgnored()) return; - drawPathTexture(texture, left, top, paint); + glActiveTexture(gTextureUnits[0]); + const PathTexture* texture = mCaches.ovalShapeCache.getOval(right - left, bottom - top, paint); + drawShape(left, top, texture, paint); +} + +void OpenGLRenderer::drawRectAsShape(float left, float top, float right, float bottom, + SkPaint* paint) { + if (mSnapshot->isIgnored()) return; + + glActiveTexture(gTextureUnits[0]); + const PathTexture* texture = mCaches.rectShapeCache.getRect(right - left, bottom - top, paint); + drawShape(left, top, texture, paint); } void OpenGLRenderer::drawRect(float left, float top, float right, float bottom, SkPaint* p) { + if (p->getStyle() != SkPaint::kFill_Style) { + drawRectAsShape(left, top, right, bottom, p); + return; + } + if (quickReject(left, top, right, bottom)) { return; } -- cgit v1.2.3-59-g8ed1b