diff options
Diffstat (limited to 'libs/hwui')
| -rwxr-xr-x | libs/hwui/OpenGLRenderer.cpp | 31 | ||||
| -rw-r--r-- | libs/hwui/TessellationCache.cpp | 2 |
2 files changed, 23 insertions, 10 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index dbd273d..0415efa 100755 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -54,10 +54,6 @@ namespace android { namespace uirenderer { -/////////////////////////////////////////////////////////////////////////////// -// Defines -/////////////////////////////////////////////////////////////////////////////// - static GLenum getFilter(const SkPaint* paint) { if (!paint || paint->getFilterLevel() != SkPaint::kNone_FilterLevel) { return GL_LINEAR; @@ -1748,10 +1744,13 @@ void OpenGLRenderer::setupDrawProgram() { glUniform4f(mCaches.currentProgram->getUniform("roundRectInnerRectLTRB"), innerRect.left, innerRect.top, innerRect.right, innerRect.bottom); - glUniform1f(mCaches.currentProgram->getUniform("roundRectRadius"), - state->radius); glUniformMatrix4fv(mCaches.currentProgram->getUniform("roundRectInvTransform"), 1, GL_FALSE, &state->matrix.data[0]); + + // add half pixel to round out integer rect space to cover pixel centers + float roundedOutRadius = state->radius + 0.5f; + glUniform1f(mCaches.currentProgram->getUniform("roundRectRadius"), + roundedOutRadius); } } @@ -3044,21 +3043,35 @@ void OpenGLRenderer::resetPaintFilter() { } void OpenGLRenderer::setupPaintFilter(int clearBits, int setBits) { + // TODO: don't bother with boolean, it's redundant with clear/set bits mDrawModifiers.mHasDrawFilter = true; mDrawModifiers.mPaintFilterClearBits = clearBits & SkPaint::kAllFlags; mDrawModifiers.mPaintFilterSetBits = setBits & SkPaint::kAllFlags; } const SkPaint* OpenGLRenderer::filterPaint(const SkPaint* paint) { + // TODO: use CompatFlagsDrawFilter here, and combine logic with android/graphics/DrawFilter.cpp + // to avoid clobbering 0x02 paint flag + + // Equivalent to the Java Paint's FILTER_BITMAP_FLAG. + static const uint32_t sFilterBitmapFlag = 0x02; + if (CC_LIKELY(!mDrawModifiers.mHasDrawFilter || !paint)) { return paint; } - uint32_t flags = paint->getFlags(); + const uint32_t clearBits = mDrawModifiers.mPaintFilterClearBits; + const uint32_t setBits = mDrawModifiers.mPaintFilterSetBits; + const uint32_t flags = (paint->getFlags() & ~clearBits) | setBits; mFilteredPaint = *paint; - mFilteredPaint.setFlags((flags & ~mDrawModifiers.mPaintFilterClearBits) | - mDrawModifiers.mPaintFilterSetBits); + mFilteredPaint.setFlags(flags); + + // check if paint filter trying to override bitmap filter + if ((clearBits | setBits) & sFilterBitmapFlag) { + mFilteredPaint.setFilterLevel(flags & sFilterBitmapFlag + ? SkPaint::kLow_FilterLevel : SkPaint::kNone_FilterLevel); + } return &mFilteredPaint; } diff --git a/libs/hwui/TessellationCache.cpp b/libs/hwui/TessellationCache.cpp index 9e62f36..1e38f9e 100644 --- a/libs/hwui/TessellationCache.cpp +++ b/libs/hwui/TessellationCache.cpp @@ -216,7 +216,7 @@ static void tessellateShadows( // tessellate caster outline into a 2d polygon Vector<Vertex> casterVertices2d; - const float casterRefinementThresholdSquared = 20.0f; // TODO: experiment with this value + const float casterRefinementThresholdSquared = 4.0f; PathTessellator::approximatePathOutlineVertices(*casterPerimeter, casterRefinementThresholdSquared, casterVertices2d); if (!ShadowTessellator::isClockwisePath(*casterPerimeter)) { |
