diff options
author | Chris Craik <ccraik@google.com> | 2015-02-12 10:41:39 -0800 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2015-02-12 16:16:57 -0800 |
commit | 30036092b40badecbe64d9c2bff4850132147f78 (patch) | |
tree | ea5a86b5bd90dd3c2fd0c16ce7676cdf2fcd678a /libs/hwui/OpenGLRenderer.cpp | |
parent | 5b14d9893aced2b3ba46f1d90a0752c1a9a43f2f (diff) | |
download | frameworks_base-30036092b40badecbe64d9c2bff4850132147f78.zip frameworks_base-30036092b40badecbe64d9c2bff4850132147f78.tar.gz frameworks_base-30036092b40badecbe64d9c2bff4850132147f78.tar.bz2 |
Glop path texture support
Change-Id: I505eb05991ca4c9b2e01e49988b8f962fad51462
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 0841124..a00a2bc 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -2505,7 +2505,7 @@ void OpenGLRenderer::drawColor(int color, SkXfermode::Mode mode) { mDirty = true; } -void OpenGLRenderer::drawShape(float left, float top, const PathTexture* texture, +void OpenGLRenderer::drawShape(float left, float top, PathTexture* texture, const SkPaint* paint) { if (!texture) return; const AutoTexture autoCleanup(texture); @@ -2528,7 +2528,7 @@ void OpenGLRenderer::drawRoundRect(float left, float top, float right, float bot if (p->getPathEffect() != nullptr) { mCaches.textureState().activateTexture(0); - const PathTexture* texture = mCaches.pathCache.getRoundRect( + PathTexture* texture = mCaches.pathCache.getRoundRect( right - left, bottom - top, rx, ry, p); drawShape(left, top, texture, p); } else { @@ -2546,7 +2546,7 @@ void OpenGLRenderer::drawCircle(float x, float y, float radius, const SkPaint* p } if (p->getPathEffect() != nullptr) { mCaches.textureState().activateTexture(0); - const PathTexture* texture = mCaches.pathCache.getCircle(radius, p); + PathTexture* texture = mCaches.pathCache.getCircle(radius, p); drawShape(x - radius, y - radius, texture, p); } else { SkPath path; @@ -2569,7 +2569,7 @@ void OpenGLRenderer::drawOval(float left, float top, float right, float bottom, if (p->getPathEffect() != nullptr) { mCaches.textureState().activateTexture(0); - const PathTexture* texture = mCaches.pathCache.getOval(right - left, bottom - top, p); + PathTexture* texture = mCaches.pathCache.getOval(right - left, bottom - top, p); drawShape(left, top, texture, p); } else { SkPath path; @@ -2593,7 +2593,7 @@ void OpenGLRenderer::drawArc(float left, float top, float right, float bottom, // TODO: support fills (accounting for concavity if useCenter && sweepAngle > 180) if (p->getStyle() != SkPaint::kStroke_Style || p->getPathEffect() != nullptr || useCenter) { mCaches.textureState().activateTexture(0); - const PathTexture* texture = mCaches.pathCache.getArc(right - left, bottom - top, + PathTexture* texture = mCaches.pathCache.getArc(right - left, bottom - top, startAngle, sweepAngle, useCenter, p); drawShape(left, top, texture, p); return; @@ -2630,7 +2630,7 @@ void OpenGLRenderer::drawRect(float left, float top, float right, float bottom, if (p->getPathEffect() != nullptr || p->getStrokeJoin() != SkPaint::kMiter_Join || p->getStrokeMiter() != SkPaintDefaults_MiterLimit) { mCaches.textureState().activateTexture(0); - const PathTexture* texture = + PathTexture* texture = mCaches.pathCache.getRect(right - left, bottom - top, p); drawShape(left, top, texture, p); } else { @@ -2974,7 +2974,7 @@ void OpenGLRenderer::drawPath(const SkPath* path, const SkPaint* paint) { mCaches.textureState().activateTexture(0); - const PathTexture* texture = mCaches.pathCache.get(path, paint); + PathTexture* texture = mCaches.pathCache.get(path, paint); if (!texture) return; const AutoTexture autoCleanup(texture); @@ -3107,12 +3107,26 @@ Texture* OpenGLRenderer::getTexture(const SkBitmap* bitmap) { return texture; } -void OpenGLRenderer::drawPathTexture(const PathTexture* texture, +void OpenGLRenderer::drawPathTexture(PathTexture* texture, float x, float y, const SkPaint* paint) { if (quickRejectSetupScissor(x, y, x + texture->width, y + texture->height)) { return; } + if (USE_GLOPS && !paint->getShader()) { + Glop glop; + GlopBuilder aBuilder(mRenderState, mCaches, &glop); + aBuilder.setMeshTexturedUnitQuad(nullptr, true) + .setFillPathTexturePaint(*texture, *paint, currentSnapshot()->alpha) + .setTransformClip(currentSnapshot()->getOrthoMatrix(), *currentTransform(), false) + .setModelViewMapUnitToRect(Rect(x, y, x + texture->width, y + texture->height)) + .setRoundRectClipState(currentSnapshot()->roundRectClipState) + .build(); + renderGlop(glop); + return; + } + + int alpha; SkXfermode::Mode mode; getAlphaAndMode(paint, &alpha, &mode); |