OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #define LOG_TAG "PathRenderer" | 8 #define LOG_TAG "PathRenderer" |
9 #define LOG_NDEBUG 1 | 9 #define LOG_NDEBUG 1 |
10 #define ATRACE_TAG ATRACE_TAG_GRAPHICS | 10 #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
11 | 11 |
12 #define VERTEX_DEBUG 0 | 12 #define VERTEX_DEBUG 0 |
13 | 13 |
14 #include <SkPath.h> | 14 #include <SkPath.h> |
15 #include <SkStrokeRec.h> | 15 #include <SkStrokeRec.h> |
16 | 16 |
17 #include <stdlib.h> | 17 #include <stdlib.h> |
18 #include <stdint.h> | 18 #include <stdint.h> |
19 #include <sys/types.h> | 19 #include <sys/types.h> |
20 | 20 |
21 #include <SkTypes.h> | 21 #include <SkTypes.h> |
22 #include <SkTrace.h> | 22 #include <SkTraceEvent.h> |
23 #include <SkMatrix.h> | 23 #include <SkMatrix.h> |
24 #include <SkPoint.h> | 24 #include <SkPoint.h> |
25 | 25 |
26 #ifdef VERBOSE | 26 #ifdef VERBOSE |
27 #define ALOGV SkDebugf | 27 #define ALOGV SkDebugf |
28 #else | 28 #else |
29 #define ALOGV(x, ...) | 29 #define ALOGV(x, ...) |
30 #endif | 30 #endif |
31 | 31 |
32 #include "AndroidPathRenderer.h" | 32 #include "AndroidPathRenderer.h" |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 | 515 |
516 #if VERTEX_DEBUG | 516 #if VERTEX_DEBUG |
517 for (unsigned int i = 0; i < vertexBuffer.getSize(); i++) { | 517 for (unsigned int i = 0; i < vertexBuffer.getSize(); i++) { |
518 SkDebugf("point at %f %f, alpha %f", buffer[i].position[0], buffer[i].po
sition[1], buffer[i].alpha); | 518 SkDebugf("point at %f %f, alpha %f", buffer[i].position[0], buffer[i].po
sition[1], buffer[i].alpha); |
519 } | 519 } |
520 #endif | 520 #endif |
521 } | 521 } |
522 | 522 |
523 void PathRenderer::ConvexPathVertices(const SkPath &path, const SkStrokeRec& str
oke, bool isAA, | 523 void PathRenderer::ConvexPathVertices(const SkPath &path, const SkStrokeRec& str
oke, bool isAA, |
524 const SkMatrix* transform, VertexBuffer* vertexBuffer) { | 524 const SkMatrix* transform, VertexBuffer* vertexBuffer) { |
525 SK_TRACE_EVENT0("PathRenderer::convexPathVertices"); | |
526 | 525 |
527 SkStrokeRec::Style style = stroke.getStyle(); | 526 SkStrokeRec::Style style = stroke.getStyle(); |
528 | 527 |
529 float inverseScaleX, inverseScaleY; | 528 float inverseScaleX, inverseScaleY; |
530 computeInverseScales(transform, inverseScaleX, inverseScaleY); | 529 computeInverseScales(transform, inverseScaleX, inverseScaleY); |
531 | 530 |
532 SkTArray<Vertex, true> tempVertices; | 531 SkTArray<Vertex, true> tempVertices; |
533 float threshInvScaleX = inverseScaleX; | 532 float threshInvScaleX = inverseScaleX; |
534 float threshInvScaleY = inverseScaleY; | 533 float threshInvScaleY = inverseScaleY; |
535 if (style == SkStrokeRec::kStroke_Style) { | 534 if (style == SkStrokeRec::kStroke_Style) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 | 590 |
592 static void pushToVector(SkTArray<Vertex, true>* vertices, float x, float y) { | 591 static void pushToVector(SkTArray<Vertex, true>* vertices, float x, float y) { |
593 // TODO: make this not yuck | 592 // TODO: make this not yuck |
594 vertices->push_back(); | 593 vertices->push_back(); |
595 Vertex* newVertex = &((*vertices)[vertices->count() - 1]); | 594 Vertex* newVertex = &((*vertices)[vertices->count() - 1]); |
596 Vertex::set(newVertex, x, y); | 595 Vertex::set(newVertex, x, y); |
597 } | 596 } |
598 | 597 |
599 bool PathRenderer::ConvexPathPerimeterVertices(const SkPath& path, bool forceClo
se, | 598 bool PathRenderer::ConvexPathPerimeterVertices(const SkPath& path, bool forceClo
se, |
600 float sqrInvScaleX, float sqrInvScaleY, SkTArray<Vertex, true>* outputVe
rtices) { | 599 float sqrInvScaleX, float sqrInvScaleY, SkTArray<Vertex, true>* outputVe
rtices) { |
601 SK_TRACE_EVENT0("PathRenderer::convexPathPerimeterVertices"); | |
602 | 600 |
603 | 601 |
604 // TODO: to support joins other than sharp miter, join vertices should be la
belled in the | 602 // TODO: to support joins other than sharp miter, join vertices should be la
belled in the |
605 // perimeter, or resolved into more vertices. Reconsider forceClose-ing in t
hat case. | 603 // perimeter, or resolved into more vertices. Reconsider forceClose-ing in t
hat case. |
606 SkPath::Iter iter(path, forceClose); | 604 SkPath::Iter iter(path, forceClose); |
607 SkPoint pts[4]; | 605 SkPoint pts[4]; |
608 SkPath::Verb v; | 606 SkPath::Verb v; |
609 | 607 |
610 while (SkPath::kDone_Verb != (v = iter.next(pts))) { | 608 while (SkPath::kDone_Verb != (v = iter.next(pts))) { |
611 switch (v) { | 609 switch (v) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 | 720 |
723 RecursiveQuadraticBezierVertices(ax, ay, mx, my, acx, acy, | 721 RecursiveQuadraticBezierVertices(ax, ay, mx, my, acx, acy, |
724 sqrInvScaleX, sqrInvScaleY, outputVertices); | 722 sqrInvScaleX, sqrInvScaleY, outputVertices); |
725 RecursiveQuadraticBezierVertices(mx, my, bx, by, bcx, bcy, | 723 RecursiveQuadraticBezierVertices(mx, my, bx, by, bcx, bcy, |
726 sqrInvScaleX, sqrInvScaleY, outputVertices); | 724 sqrInvScaleX, sqrInvScaleY, outputVertices); |
727 } | 725 } |
728 } | 726 } |
729 | 727 |
730 }; // namespace uirenderer | 728 }; // namespace uirenderer |
731 }; // namespace android | 729 }; // namespace android |
OLD | NEW |