Loading libs/hwui/AmbientShadow.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -97,9 +97,9 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, // calculate the normal N, which should be perpendicular to the edge of the // polygon (represented by the neighbor intersection points) . // Shadow's vertices will be generated as : P + N * scale. const Vector2 centroid2d = Vector2(centroid3d.x, centroid3d.y); const Vector2 centroid2d = {centroid3d.x, centroid3d.y}; for (int rayIndex = 0; rayIndex < rays; rayIndex++) { Vector2 normal(1.0f, 0.0f); Vector2 normal = {1.0f, 0.0f}; calculateNormal(rays, rayIndex, dir.array(), rayDist, normal); // The vertex should be start from rayDist[i] then scale the Loading libs/hwui/LayerRenderer.h +1 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ public: LayerRenderer(RenderState& renderState, Layer* layer); virtual ~LayerRenderer(); virtual void onViewportInitialized(int width, int height) { /* do nothing */ } virtual void onViewportInitialized() { /* do nothing */ } virtual status_t prepareDirty(float left, float top, float right, float bottom, bool opaque); virtual status_t clear(float left, float top, float right, float bottom, bool opaque); virtual void finish(); Loading libs/hwui/OpenGLRenderer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -138,7 +138,7 @@ OpenGLRenderer::OpenGLRenderer(RenderState& renderState) , mRenderState(renderState) , mScissorOptimizationDisabled(false) , mCountOverdraw(false) , mLightCenter(FLT_MIN, FLT_MIN, FLT_MIN) , mLightCenter((Vector3){FLT_MIN, FLT_MIN, FLT_MIN}) , mLightRadius(FLT_MIN) , mAmbientShadowAlpha(0) , mSpotShadowAlpha(0) { Loading libs/hwui/PathTessellator.cpp +44 −53 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ void PathTessellator::extractTessellationScales(const Matrix4& transform, * * NOTE: assumes angles between normals 90 degrees or less */ inline static vec2 totalOffsetFromNormals(const vec2& normalA, const vec2& normalB) { inline static Vector2 totalOffsetFromNormals(const Vector2& normalA, const Vector2& normalB) { return (normalA + normalB) / (1 + fabs(normalA.dot(normalB))); } Loading Loading @@ -129,7 +129,7 @@ public: float halfStrokeWidth; float maxAlpha; inline void scaleOffsetForStrokeWidth(vec2& offset) const { inline void scaleOffsetForStrokeWidth(Vector2& offset) const { if (halfStrokeWidth == 0.0f) { // hairline - compensate for scale offset.x *= 0.5f * inverseScaleX; Loading @@ -143,9 +143,8 @@ public: * NOTE: the input will not always be a normal, especially for sharp edges - it should be the * result of totalOffsetFromNormals (see documentation there) */ inline vec2 deriveAAOffset(const vec2& offset) const { return vec2(offset.x * 0.5f * inverseScaleX, offset.y * 0.5f * inverseScaleY); inline Vector2 deriveAAOffset(const Vector2& offset) const { return (Vector2){offset.x * 0.5f * inverseScaleX, offset.y * 0.5f * inverseScaleY}; } /** Loading Loading @@ -208,16 +207,14 @@ void getStrokeVerticesFromPerimeter(const PaintInfo& paintInfo, const Vector<Ver int currentIndex = 0; const Vertex* last = &(perimeter[perimeter.size() - 1]); const Vertex* current = &(perimeter[0]); vec2 lastNormal(current->y - last->y, last->x - current->x); Vector2 lastNormal = {current->y - last->y, last->x - current->x}; lastNormal.normalize(); for (unsigned int i = 0; i < perimeter.size(); i++) { const Vertex* next = &(perimeter[i + 1 >= perimeter.size() ? 0 : i + 1]); vec2 nextNormal(next->y - current->y, current->x - next->x); Vector2 nextNormal = {next->y - current->y, current->x - next->x}; nextNormal.normalize(); vec2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal); Vector2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal); paintInfo.scaleOffsetForStrokeWidth(totalOffset); Vertex::set(&buffer[currentIndex++], Loading @@ -241,13 +238,14 @@ void getStrokeVerticesFromPerimeter(const PaintInfo& paintInfo, const Vector<Ver } static inline void storeBeginEnd(const PaintInfo& paintInfo, const Vertex& center, const vec2& normal, Vertex* buffer, int& currentIndex, bool begin) { vec2 strokeOffset = normal; const Vector2& normal, Vertex* buffer, int& currentIndex, bool begin) { Vector2 strokeOffset = normal; paintInfo.scaleOffsetForStrokeWidth(strokeOffset); vec2 referencePoint(center.x, center.y); Vector2 referencePoint = {center.x, center.y}; if (paintInfo.cap == SkPaint::kSquare_Cap) { referencePoint += vec2(-strokeOffset.y, strokeOffset.x) * (begin ? -1 : 1); Vector2 rotated = {-strokeOffset.y, strokeOffset.x}; referencePoint += rotated * (begin ? -1 : 1); } Vertex::set(&buffer[currentIndex++], referencePoint + strokeOffset); Loading Loading @@ -288,14 +286,14 @@ void getStrokeVerticesFromUnclosedVertices(const PaintInfo& paintInfo, } beginTheta += dTheta; vec2 beginRadialOffset(cos(beginTheta), sin(beginTheta)); Vector2 beginRadialOffset = {cos(beginTheta), sin(beginTheta)}; paintInfo.scaleOffsetForStrokeWidth(beginRadialOffset); Vertex::set(&buffer[capOffset], vertices[0].x + beginRadialOffset.x, vertices[0].y + beginRadialOffset.y); endTheta += dTheta; vec2 endRadialOffset(cos(endTheta), sin(endTheta)); Vector2 endRadialOffset = {cos(endTheta), sin(endTheta)}; paintInfo.scaleOffsetForStrokeWidth(endRadialOffset); Vertex::set(&buffer[allocSize - 1 - capOffset], vertices[lastIndex].x + endRadialOffset.x, Loading @@ -306,22 +304,20 @@ void getStrokeVerticesFromUnclosedVertices(const PaintInfo& paintInfo, int currentIndex = extra; const Vertex* last = &(vertices[0]); const Vertex* current = &(vertices[1]); vec2 lastNormal(current->y - last->y, last->x - current->x); Vector2 lastNormal = {current->y - last->y, last->x - current->x}; lastNormal.normalize(); storeBeginEnd(paintInfo, vertices[0], lastNormal, buffer, currentIndex, true); for (unsigned int i = 1; i < vertices.size() - 1; i++) { const Vertex* next = &(vertices[i + 1]); vec2 nextNormal(next->y - current->y, current->x - next->x); Vector2 nextNormal = {next->y - current->y, current->x - next->x}; nextNormal.normalize(); vec2 strokeOffset = totalOffsetFromNormals(lastNormal, nextNormal); Vector2 strokeOffset = totalOffsetFromNormals(lastNormal, nextNormal); paintInfo.scaleOffsetForStrokeWidth(strokeOffset); vec2 center(current->x, current->y); Vector2 center = {current->x, current->y}; Vertex::set(&buffer[currentIndex++], center + strokeOffset); Vertex::set(&buffer[currentIndex++], center - strokeOffset); Loading Loading @@ -353,18 +349,16 @@ void getFillVerticesFromPerimeterAA(const PaintInfo& paintInfo, const Vector<Ver int currentIndex = 0; const Vertex* last = &(perimeter[perimeter.size() - 1]); const Vertex* current = &(perimeter[0]); vec2 lastNormal(current->y - last->y, last->x - current->x); Vector2 lastNormal = {current->y - last->y, last->x - current->x}; lastNormal.normalize(); for (unsigned int i = 0; i < perimeter.size(); i++) { const Vertex* next = &(perimeter[i + 1 >= perimeter.size() ? 0 : i + 1]); vec2 nextNormal(next->y - current->y, current->x - next->x); Vector2 nextNormal = {next->y - current->y, current->x - next->x}; nextNormal.normalize(); // AA point offset from original point is that point's normal, such that each side is offset // by .5 pixels vec2 totalOffset = paintInfo.deriveAAOffset(totalOffsetFromNormals(lastNormal, nextNormal)); Vector2 totalOffset = paintInfo.deriveAAOffset(totalOffsetFromNormals(lastNormal, nextNormal)); AlphaVertex::set(&buffer[currentIndex++], current->x + totalOffset.x, Loading Loading @@ -407,7 +401,7 @@ void getFillVerticesFromPerimeterAA(const PaintInfo& paintInfo, const Vector<Ver * getStrokeVerticesFromUnclosedVerticesAA() below. */ inline static void storeCapAA(const PaintInfo& paintInfo, const Vector<Vertex>& vertices, AlphaVertex* buffer, bool isFirst, vec2 normal, int offset) { AlphaVertex* buffer, bool isFirst, Vector2 normal, int offset) { const int extra = paintInfo.capExtraDivisions(); const int extraOffset = (extra + 1) / 2; const int capIndex = isFirst Loading @@ -416,27 +410,28 @@ inline static void storeCapAA(const PaintInfo& paintInfo, const Vector<Vertex>& if (isFirst) normal *= -1; // TODO: this normal should be scaled by radialScale if extra != 0, see totalOffsetFromNormals() vec2 AAOffset = paintInfo.deriveAAOffset(normal); Vector2 AAOffset = paintInfo.deriveAAOffset(normal); vec2 strokeOffset = normal; Vector2 strokeOffset = normal; paintInfo.scaleOffsetForStrokeWidth(strokeOffset); vec2 outerOffset = strokeOffset + AAOffset; vec2 innerOffset = strokeOffset - AAOffset; Vector2 outerOffset = strokeOffset + AAOffset; Vector2 innerOffset = strokeOffset - AAOffset; vec2 capAAOffset; Vector2 capAAOffset = {0, 0}; if (paintInfo.cap != SkPaint::kRound_Cap) { // if the cap is square or butt, the inside primary cap vertices will be inset in two // directions - both normal to the stroke, and parallel to it. capAAOffset = vec2(-AAOffset.y, AAOffset.x); capAAOffset = (Vector2){-AAOffset.y, AAOffset.x}; } // determine referencePoint, the center point for the 4 primary cap vertices const Vertex* point = isFirst ? vertices.begin() : (vertices.end() - 1); vec2 referencePoint(point->x, point->y); Vector2 referencePoint = {point->x, point->y}; if (paintInfo.cap == SkPaint::kSquare_Cap) { // To account for square cap, move the primary cap vertices (that create the AA edge) by the // stroke offset vector (rotated to be parallel to the stroke) referencePoint += vec2(-strokeOffset.y, strokeOffset.x); Vector2 rotated = {-strokeOffset.y, strokeOffset.x}; referencePoint += rotated; } AlphaVertex::set(&buffer[capIndex + 0], Loading Loading @@ -469,7 +464,7 @@ inline static void storeCapAA(const PaintInfo& paintInfo, const Vector<Vertex>& for (int i = 0; i < extra; i++) { theta += dTheta; vec2 radialOffset(cos(theta), sin(theta)); Vector2 radialOffset = {cos(theta), sin(theta)}; // scale to compensate for pinching at sharp angles, see totalOffsetFromNormals() radialOffset *= radialScale; Loading Loading @@ -592,8 +587,7 @@ void getStrokeVerticesFromUnclosedVerticesAA(const PaintInfo& paintInfo, const Vertex* last = &(vertices[0]); const Vertex* current = &(vertices[1]); vec2 lastNormal(current->y - last->y, last->x - current->x); Vector2 lastNormal = {current->y - last->y, last->x - current->x}; lastNormal.normalize(); // TODO: use normal from bezier traversal for cap, instead of from vertices Loading @@ -601,16 +595,15 @@ void getStrokeVerticesFromUnclosedVerticesAA(const PaintInfo& paintInfo, for (unsigned int i = 1; i < vertices.size() - 1; i++) { const Vertex* next = &(vertices[i + 1]); vec2 nextNormal(next->y - current->y, current->x - next->x); Vector2 nextNormal = {next->y - current->y, current->x - next->x}; nextNormal.normalize(); vec2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal); vec2 AAOffset = paintInfo.deriveAAOffset(totalOffset); Vector2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal); Vector2 AAOffset = paintInfo.deriveAAOffset(totalOffset); vec2 innerOffset = totalOffset; Vector2 innerOffset = totalOffset; paintInfo.scaleOffsetForStrokeWidth(innerOffset); vec2 outerOffset = innerOffset + AAOffset; Vector2 outerOffset = innerOffset + AAOffset; innerOffset -= AAOffset; AlphaVertex::set(&buffer[currentAAOuterIndex++], Loading Loading @@ -662,21 +655,19 @@ void getStrokeVerticesFromPerimeterAA(const PaintInfo& paintInfo, const Vector<V const Vertex* last = &(perimeter[perimeter.size() - 1]); const Vertex* current = &(perimeter[0]); vec2 lastNormal(current->y - last->y, last->x - current->x); Vector2 lastNormal = {current->y - last->y, last->x - current->x}; lastNormal.normalize(); for (unsigned int i = 0; i < perimeter.size(); i++) { const Vertex* next = &(perimeter[i + 1 >= perimeter.size() ? 0 : i + 1]); vec2 nextNormal(next->y - current->y, current->x - next->x); Vector2 nextNormal = {next->y - current->y, current->x - next->x}; nextNormal.normalize(); vec2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal); vec2 AAOffset = paintInfo.deriveAAOffset(totalOffset); Vector2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal); Vector2 AAOffset = paintInfo.deriveAAOffset(totalOffset); vec2 innerOffset = totalOffset; Vector2 innerOffset = totalOffset; paintInfo.scaleOffsetForStrokeWidth(innerOffset); vec2 outerOffset = innerOffset + AAOffset; Vector2 outerOffset = innerOffset + AAOffset; innerOffset -= AAOffset; AlphaVertex::set(&buffer[currentAAOuterIndex++], Loading libs/hwui/RenderNode.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -836,7 +836,8 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) { DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance(); const int saveCountOffset = renderer.getSaveCount() - 1; const int projectionReceiveIndex = mDisplayListData->projectionReceiveIndex; for (unsigned int i = 0; i < mDisplayListData->displayListOps.size(); i++) { const int size = static_cast<int>(mDisplayListData->displayListOps.size()); for (int i = 0; i < size; i++) { DisplayListOp *op = mDisplayListData->displayListOps[i]; #if DEBUG_DISPLAY_LIST Loading Loading
libs/hwui/AmbientShadow.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -97,9 +97,9 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, // calculate the normal N, which should be perpendicular to the edge of the // polygon (represented by the neighbor intersection points) . // Shadow's vertices will be generated as : P + N * scale. const Vector2 centroid2d = Vector2(centroid3d.x, centroid3d.y); const Vector2 centroid2d = {centroid3d.x, centroid3d.y}; for (int rayIndex = 0; rayIndex < rays; rayIndex++) { Vector2 normal(1.0f, 0.0f); Vector2 normal = {1.0f, 0.0f}; calculateNormal(rays, rayIndex, dir.array(), rayDist, normal); // The vertex should be start from rayDist[i] then scale the Loading
libs/hwui/LayerRenderer.h +1 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ public: LayerRenderer(RenderState& renderState, Layer* layer); virtual ~LayerRenderer(); virtual void onViewportInitialized(int width, int height) { /* do nothing */ } virtual void onViewportInitialized() { /* do nothing */ } virtual status_t prepareDirty(float left, float top, float right, float bottom, bool opaque); virtual status_t clear(float left, float top, float right, float bottom, bool opaque); virtual void finish(); Loading
libs/hwui/OpenGLRenderer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -138,7 +138,7 @@ OpenGLRenderer::OpenGLRenderer(RenderState& renderState) , mRenderState(renderState) , mScissorOptimizationDisabled(false) , mCountOverdraw(false) , mLightCenter(FLT_MIN, FLT_MIN, FLT_MIN) , mLightCenter((Vector3){FLT_MIN, FLT_MIN, FLT_MIN}) , mLightRadius(FLT_MIN) , mAmbientShadowAlpha(0) , mSpotShadowAlpha(0) { Loading
libs/hwui/PathTessellator.cpp +44 −53 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ void PathTessellator::extractTessellationScales(const Matrix4& transform, * * NOTE: assumes angles between normals 90 degrees or less */ inline static vec2 totalOffsetFromNormals(const vec2& normalA, const vec2& normalB) { inline static Vector2 totalOffsetFromNormals(const Vector2& normalA, const Vector2& normalB) { return (normalA + normalB) / (1 + fabs(normalA.dot(normalB))); } Loading Loading @@ -129,7 +129,7 @@ public: float halfStrokeWidth; float maxAlpha; inline void scaleOffsetForStrokeWidth(vec2& offset) const { inline void scaleOffsetForStrokeWidth(Vector2& offset) const { if (halfStrokeWidth == 0.0f) { // hairline - compensate for scale offset.x *= 0.5f * inverseScaleX; Loading @@ -143,9 +143,8 @@ public: * NOTE: the input will not always be a normal, especially for sharp edges - it should be the * result of totalOffsetFromNormals (see documentation there) */ inline vec2 deriveAAOffset(const vec2& offset) const { return vec2(offset.x * 0.5f * inverseScaleX, offset.y * 0.5f * inverseScaleY); inline Vector2 deriveAAOffset(const Vector2& offset) const { return (Vector2){offset.x * 0.5f * inverseScaleX, offset.y * 0.5f * inverseScaleY}; } /** Loading Loading @@ -208,16 +207,14 @@ void getStrokeVerticesFromPerimeter(const PaintInfo& paintInfo, const Vector<Ver int currentIndex = 0; const Vertex* last = &(perimeter[perimeter.size() - 1]); const Vertex* current = &(perimeter[0]); vec2 lastNormal(current->y - last->y, last->x - current->x); Vector2 lastNormal = {current->y - last->y, last->x - current->x}; lastNormal.normalize(); for (unsigned int i = 0; i < perimeter.size(); i++) { const Vertex* next = &(perimeter[i + 1 >= perimeter.size() ? 0 : i + 1]); vec2 nextNormal(next->y - current->y, current->x - next->x); Vector2 nextNormal = {next->y - current->y, current->x - next->x}; nextNormal.normalize(); vec2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal); Vector2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal); paintInfo.scaleOffsetForStrokeWidth(totalOffset); Vertex::set(&buffer[currentIndex++], Loading @@ -241,13 +238,14 @@ void getStrokeVerticesFromPerimeter(const PaintInfo& paintInfo, const Vector<Ver } static inline void storeBeginEnd(const PaintInfo& paintInfo, const Vertex& center, const vec2& normal, Vertex* buffer, int& currentIndex, bool begin) { vec2 strokeOffset = normal; const Vector2& normal, Vertex* buffer, int& currentIndex, bool begin) { Vector2 strokeOffset = normal; paintInfo.scaleOffsetForStrokeWidth(strokeOffset); vec2 referencePoint(center.x, center.y); Vector2 referencePoint = {center.x, center.y}; if (paintInfo.cap == SkPaint::kSquare_Cap) { referencePoint += vec2(-strokeOffset.y, strokeOffset.x) * (begin ? -1 : 1); Vector2 rotated = {-strokeOffset.y, strokeOffset.x}; referencePoint += rotated * (begin ? -1 : 1); } Vertex::set(&buffer[currentIndex++], referencePoint + strokeOffset); Loading Loading @@ -288,14 +286,14 @@ void getStrokeVerticesFromUnclosedVertices(const PaintInfo& paintInfo, } beginTheta += dTheta; vec2 beginRadialOffset(cos(beginTheta), sin(beginTheta)); Vector2 beginRadialOffset = {cos(beginTheta), sin(beginTheta)}; paintInfo.scaleOffsetForStrokeWidth(beginRadialOffset); Vertex::set(&buffer[capOffset], vertices[0].x + beginRadialOffset.x, vertices[0].y + beginRadialOffset.y); endTheta += dTheta; vec2 endRadialOffset(cos(endTheta), sin(endTheta)); Vector2 endRadialOffset = {cos(endTheta), sin(endTheta)}; paintInfo.scaleOffsetForStrokeWidth(endRadialOffset); Vertex::set(&buffer[allocSize - 1 - capOffset], vertices[lastIndex].x + endRadialOffset.x, Loading @@ -306,22 +304,20 @@ void getStrokeVerticesFromUnclosedVertices(const PaintInfo& paintInfo, int currentIndex = extra; const Vertex* last = &(vertices[0]); const Vertex* current = &(vertices[1]); vec2 lastNormal(current->y - last->y, last->x - current->x); Vector2 lastNormal = {current->y - last->y, last->x - current->x}; lastNormal.normalize(); storeBeginEnd(paintInfo, vertices[0], lastNormal, buffer, currentIndex, true); for (unsigned int i = 1; i < vertices.size() - 1; i++) { const Vertex* next = &(vertices[i + 1]); vec2 nextNormal(next->y - current->y, current->x - next->x); Vector2 nextNormal = {next->y - current->y, current->x - next->x}; nextNormal.normalize(); vec2 strokeOffset = totalOffsetFromNormals(lastNormal, nextNormal); Vector2 strokeOffset = totalOffsetFromNormals(lastNormal, nextNormal); paintInfo.scaleOffsetForStrokeWidth(strokeOffset); vec2 center(current->x, current->y); Vector2 center = {current->x, current->y}; Vertex::set(&buffer[currentIndex++], center + strokeOffset); Vertex::set(&buffer[currentIndex++], center - strokeOffset); Loading Loading @@ -353,18 +349,16 @@ void getFillVerticesFromPerimeterAA(const PaintInfo& paintInfo, const Vector<Ver int currentIndex = 0; const Vertex* last = &(perimeter[perimeter.size() - 1]); const Vertex* current = &(perimeter[0]); vec2 lastNormal(current->y - last->y, last->x - current->x); Vector2 lastNormal = {current->y - last->y, last->x - current->x}; lastNormal.normalize(); for (unsigned int i = 0; i < perimeter.size(); i++) { const Vertex* next = &(perimeter[i + 1 >= perimeter.size() ? 0 : i + 1]); vec2 nextNormal(next->y - current->y, current->x - next->x); Vector2 nextNormal = {next->y - current->y, current->x - next->x}; nextNormal.normalize(); // AA point offset from original point is that point's normal, such that each side is offset // by .5 pixels vec2 totalOffset = paintInfo.deriveAAOffset(totalOffsetFromNormals(lastNormal, nextNormal)); Vector2 totalOffset = paintInfo.deriveAAOffset(totalOffsetFromNormals(lastNormal, nextNormal)); AlphaVertex::set(&buffer[currentIndex++], current->x + totalOffset.x, Loading Loading @@ -407,7 +401,7 @@ void getFillVerticesFromPerimeterAA(const PaintInfo& paintInfo, const Vector<Ver * getStrokeVerticesFromUnclosedVerticesAA() below. */ inline static void storeCapAA(const PaintInfo& paintInfo, const Vector<Vertex>& vertices, AlphaVertex* buffer, bool isFirst, vec2 normal, int offset) { AlphaVertex* buffer, bool isFirst, Vector2 normal, int offset) { const int extra = paintInfo.capExtraDivisions(); const int extraOffset = (extra + 1) / 2; const int capIndex = isFirst Loading @@ -416,27 +410,28 @@ inline static void storeCapAA(const PaintInfo& paintInfo, const Vector<Vertex>& if (isFirst) normal *= -1; // TODO: this normal should be scaled by radialScale if extra != 0, see totalOffsetFromNormals() vec2 AAOffset = paintInfo.deriveAAOffset(normal); Vector2 AAOffset = paintInfo.deriveAAOffset(normal); vec2 strokeOffset = normal; Vector2 strokeOffset = normal; paintInfo.scaleOffsetForStrokeWidth(strokeOffset); vec2 outerOffset = strokeOffset + AAOffset; vec2 innerOffset = strokeOffset - AAOffset; Vector2 outerOffset = strokeOffset + AAOffset; Vector2 innerOffset = strokeOffset - AAOffset; vec2 capAAOffset; Vector2 capAAOffset = {0, 0}; if (paintInfo.cap != SkPaint::kRound_Cap) { // if the cap is square or butt, the inside primary cap vertices will be inset in two // directions - both normal to the stroke, and parallel to it. capAAOffset = vec2(-AAOffset.y, AAOffset.x); capAAOffset = (Vector2){-AAOffset.y, AAOffset.x}; } // determine referencePoint, the center point for the 4 primary cap vertices const Vertex* point = isFirst ? vertices.begin() : (vertices.end() - 1); vec2 referencePoint(point->x, point->y); Vector2 referencePoint = {point->x, point->y}; if (paintInfo.cap == SkPaint::kSquare_Cap) { // To account for square cap, move the primary cap vertices (that create the AA edge) by the // stroke offset vector (rotated to be parallel to the stroke) referencePoint += vec2(-strokeOffset.y, strokeOffset.x); Vector2 rotated = {-strokeOffset.y, strokeOffset.x}; referencePoint += rotated; } AlphaVertex::set(&buffer[capIndex + 0], Loading Loading @@ -469,7 +464,7 @@ inline static void storeCapAA(const PaintInfo& paintInfo, const Vector<Vertex>& for (int i = 0; i < extra; i++) { theta += dTheta; vec2 radialOffset(cos(theta), sin(theta)); Vector2 radialOffset = {cos(theta), sin(theta)}; // scale to compensate for pinching at sharp angles, see totalOffsetFromNormals() radialOffset *= radialScale; Loading Loading @@ -592,8 +587,7 @@ void getStrokeVerticesFromUnclosedVerticesAA(const PaintInfo& paintInfo, const Vertex* last = &(vertices[0]); const Vertex* current = &(vertices[1]); vec2 lastNormal(current->y - last->y, last->x - current->x); Vector2 lastNormal = {current->y - last->y, last->x - current->x}; lastNormal.normalize(); // TODO: use normal from bezier traversal for cap, instead of from vertices Loading @@ -601,16 +595,15 @@ void getStrokeVerticesFromUnclosedVerticesAA(const PaintInfo& paintInfo, for (unsigned int i = 1; i < vertices.size() - 1; i++) { const Vertex* next = &(vertices[i + 1]); vec2 nextNormal(next->y - current->y, current->x - next->x); Vector2 nextNormal = {next->y - current->y, current->x - next->x}; nextNormal.normalize(); vec2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal); vec2 AAOffset = paintInfo.deriveAAOffset(totalOffset); Vector2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal); Vector2 AAOffset = paintInfo.deriveAAOffset(totalOffset); vec2 innerOffset = totalOffset; Vector2 innerOffset = totalOffset; paintInfo.scaleOffsetForStrokeWidth(innerOffset); vec2 outerOffset = innerOffset + AAOffset; Vector2 outerOffset = innerOffset + AAOffset; innerOffset -= AAOffset; AlphaVertex::set(&buffer[currentAAOuterIndex++], Loading Loading @@ -662,21 +655,19 @@ void getStrokeVerticesFromPerimeterAA(const PaintInfo& paintInfo, const Vector<V const Vertex* last = &(perimeter[perimeter.size() - 1]); const Vertex* current = &(perimeter[0]); vec2 lastNormal(current->y - last->y, last->x - current->x); Vector2 lastNormal = {current->y - last->y, last->x - current->x}; lastNormal.normalize(); for (unsigned int i = 0; i < perimeter.size(); i++) { const Vertex* next = &(perimeter[i + 1 >= perimeter.size() ? 0 : i + 1]); vec2 nextNormal(next->y - current->y, current->x - next->x); Vector2 nextNormal = {next->y - current->y, current->x - next->x}; nextNormal.normalize(); vec2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal); vec2 AAOffset = paintInfo.deriveAAOffset(totalOffset); Vector2 totalOffset = totalOffsetFromNormals(lastNormal, nextNormal); Vector2 AAOffset = paintInfo.deriveAAOffset(totalOffset); vec2 innerOffset = totalOffset; Vector2 innerOffset = totalOffset; paintInfo.scaleOffsetForStrokeWidth(innerOffset); vec2 outerOffset = innerOffset + AAOffset; Vector2 outerOffset = innerOffset + AAOffset; innerOffset -= AAOffset; AlphaVertex::set(&buffer[currentAAOuterIndex++], Loading
libs/hwui/RenderNode.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -836,7 +836,8 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) { DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance(); const int saveCountOffset = renderer.getSaveCount() - 1; const int projectionReceiveIndex = mDisplayListData->projectionReceiveIndex; for (unsigned int i = 0; i < mDisplayListData->displayListOps.size(); i++) { const int size = static_cast<int>(mDisplayListData->displayListOps.size()); for (int i = 0; i < size; i++) { DisplayListOp *op = mDisplayListData->displayListOps[i]; #if DEBUG_DISPLAY_LIST Loading