diff options
| author | 2011-01-23 14:18:41 -0800 | |
|---|---|---|
| committer | 2011-01-23 14:18:41 -0800 | |
| commit | c1cd9ba335b293f11e1082447ef08e474710a05f (patch) | |
| tree | 3f07bf1887e0cd5602c2f1e356e3efe92d7f766b /libs/hwui/OpenGLRenderer.cpp | |
| parent | f6834478b379856d3e5de92ddce7de0e6ba9fa4a (diff) | |
Add support for ovals and stroked rectangles.
Change-Id: I1292e241386763c82e6622c8f7ed90b0f5b7bd4f
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
| -rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 46 |
1 files changed, 32 insertions, 14 deletions
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; } |