Changeset 55371 in webkit
- Timestamp:
- Mar 1, 2010 9:41:44 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r55370 r55371 1 2010-03-01 Jakob Petsovits <jpetsovits@rim.com> 2 3 Reviewed by Dirk Schulze. 4 5 [OpenVG] Implement support for paths 6 https://bugs.webkit.org/show_bug.cgi?id=34366 7 8 Adds an implementation of the Path class - 9 *almost* complete, but not quite because OpenVG 10 does not provide access to the points in a VGPath 11 unless one keeps track of all the points by 12 themselves, which we decided not to do. 13 14 Also hooked up to PainterOpenVG and GraphicsContext. 15 16 Further introduced is SharedResourceOpenVG, which is 17 intended as base class for paths and other OpenVG 18 resources (images, fonts) that WebKit creates as 19 long-lived objects. We are at a slight disadvantage 20 here as WebKit doesn't have the concept of resources 21 belonging to a specific (hardware graphics) context, 22 which is the reason why EGLDisplayOpenVG had to 23 provide a current display singleton; this class is 24 what actually requires that functionality. 25 26 Path::addArcTo() uses code by Yong Li <yoli@rim.com>. 27 28 * platform/graphics/Path.cpp: 29 * platform/graphics/Path.h: 30 * platform/graphics/openvg/GraphicsContextOpenVG.cpp: 31 (WebCore::GraphicsContext::fillPath): 32 (WebCore::GraphicsContext::strokePath): 33 (WebCore::GraphicsContext::drawPath): 34 (WebCore::GraphicsContext::beginPath): 35 (WebCore::GraphicsContext::addPath): 36 * platform/graphics/openvg/PainterOpenVG.cpp: 37 (WebCore::PainterOpenVG::PainterOpenVG): 38 (WebCore::PainterOpenVG::~PainterOpenVG): 39 (WebCore::PainterOpenVG::transformPath): 40 (WebCore::PainterOpenVG::beginPath): 41 (WebCore::PainterOpenVG::addPath): 42 (WebCore::PainterOpenVG::currentPath): 43 (WebCore::PainterOpenVG::drawPath): 44 * platform/graphics/openvg/PainterOpenVG.h: 45 * platform/graphics/openvg/PathOpenVG.cpp: Added. 46 (WebCore::PlatformPathOpenVG::PlatformPathOpenVG): 47 (WebCore::PlatformPathOpenVG::operator=): 48 (WebCore::PlatformPathOpenVG::~PlatformPathOpenVG): 49 (WebCore::PlatformPathOpenVG::clear): 50 (WebCore::PlatformPathOpenVG::createPath): 51 (WebCore::Path::Path): 52 (WebCore::Path::~Path): 53 (WebCore::Path::operator=): 54 (WebCore::Path::contains): 55 (WebCore::Path::strokeContains): 56 (WebCore::Path::translate): 57 (WebCore::Path::boundingRect): 58 (WebCore::Path::strokeBoundingRect): 59 (WebCore::Path::moveTo): 60 (WebCore::Path::addLineTo): 61 (WebCore::Path::addQuadCurveTo): 62 (WebCore::Path::addBezierCurveTo): 63 (WebCore::Path::addArcTo): 64 (WebCore::Path::closeSubpath): 65 (WebCore::Path::addArc): 66 (WebCore::Path::addRect): 67 (WebCore::Path::addEllipse): 68 (WebCore::Path::clear): 69 (WebCore::Path::isEmpty): 70 (WebCore::Path::hasCurrentPoint): 71 (WebCore::Path::debugString): 72 (WebCore::Path::apply): 73 (WebCore::Path::transform): 74 (WebCore::Path::length): 75 (WebCore::Path::pointAtLength): 76 (WebCore::Path::normalAngleAtLength): 77 * platform/graphics/openvg/PlatformPathOpenVG.h: Added. 78 (WebCore::PlatformPathOpenVG::vgPath): 79 * platform/graphics/openvg/SharedResourceOpenVG.cpp: Added. 80 (WebCore::SharedResourceOpenVG::makeSharedContextCurrent): 81 (WebCore::SharedResourceOpenVG::makeCompatibleContextCurrent): 82 * platform/graphics/openvg/SharedResourceOpenVG.h: Added. 83 1 84 2010-03-01 Pavel Feldman <pfeldman@chromium.org> 2 85 -
trunk/WebCore/platform/graphics/Path.cpp
r44235 r55371 40 40 namespace WebCore { 41 41 42 #if !PLATFORM(OPENVG) 42 43 static void pathLengthApplierFunction(void* info, const PathElement* element) 43 44 { … … 108 109 return traversalState.m_normalAngle; 109 110 } 111 #endif 110 112 111 113 Path Path::createRoundedRectangle(const FloatRect& rectangle, const FloatSize& roundingRadii) -
trunk/WebCore/platform/graphics/Path.h
r54503 r55371 34 34 #if PLATFORM(CG) 35 35 typedef struct CGPath PlatformPath; 36 #elif PLATFORM(OPENVG) 37 namespace WebCore { 38 class PlatformPathOpenVG; 39 } 40 typedef WebCore::PlatformPathOpenVG PlatformPath; 36 41 #elif PLATFORM(QT) 37 42 #include <qpainterpath.h> -
trunk/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp
r55369 r55371 23 23 #include "AffineTransform.h" 24 24 #include "GraphicsContextPrivate.h" 25 #include "KURL.h" 25 26 #include "NotImplemented.h" 26 27 #include "PainterOpenVG.h" … … 144 145 return; 145 146 146 notImplemented();147 m_data->drawPath(VG_FILL_PATH, m_common->state.fillRule); 147 148 } 148 149 … … 152 153 return; 153 154 154 notImplemented(); 155 m_data->drawPath(VG_STROKE_PATH, m_common->state.fillRule); 156 } 157 158 void GraphicsContext::drawPath() 159 { 160 if (paintingDisabled()) 161 return; 162 163 m_data->drawPath(VG_FILL_PATH | VG_STROKE_PATH, m_common->state.fillRule); 155 164 } 156 165 … … 194 203 return; 195 204 196 notImplemented();205 m_data->beginPath(); 197 206 } 198 207 … … 202 211 return; 203 212 204 notImplemented();213 m_data->addPath(path); 205 214 } 206 215 -
trunk/WebCore/platform/graphics/openvg/PainterOpenVG.cpp
r55369 r55371 30 30 #include "IntSize.h" 31 31 #include "NotImplemented.h" 32 #include "PlatformPathOpenVG.h" 32 33 #include "SurfaceOpenVG.h" 33 34 #include "VGUtils.h" … … 341 342 : m_state(0) 342 343 , m_surface(0) 344 , m_currentPath(0) 343 345 { 344 346 } … … 347 349 : m_state(0) 348 350 , m_surface(0) 351 , m_currentPath(0) 349 352 { 350 353 ASSERT(surface); … … 355 358 { 356 359 end(); 360 delete m_currentPath; 357 361 } 358 362 … … 442 446 } 443 447 448 void PainterOpenVG::transformPath(VGPath dst, VGPath src, const AffineTransform& transformation) 449 { 450 vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); 451 452 // Save the transform state 453 VGfloat currentMatrix[9]; 454 vgGetMatrix(currentMatrix); 455 ASSERT_VG_NO_ERROR(); 456 457 // Load the new transform 458 vgLoadMatrix(VGMatrix(transformation).toVGfloat()); 459 ASSERT_VG_NO_ERROR(); 460 461 // Apply the new transform 462 vgTransformPath(dst, src); 463 ASSERT_VG_NO_ERROR(); 464 465 // Restore the transform state 466 vgLoadMatrix(currentMatrix); 467 ASSERT_VG_NO_ERROR(); 468 } 469 444 470 CompositeOperator PainterOpenVG::compositeOperation() const 445 471 { … … 620 646 transformation.translate(dx, dy); 621 647 setTransformation(transformation); 648 } 649 650 void PainterOpenVG::beginPath() 651 { 652 delete m_currentPath; 653 m_currentPath = new Path(); 654 } 655 656 void PainterOpenVG::addPath(const Path& path) 657 { 658 m_currentPath->platformPath()->makeCompatibleContextCurrent(); 659 660 vgAppendPath(m_currentPath->platformPath()->vgPath(), path.platformPath()->vgPath()); 661 ASSERT_VG_NO_ERROR(); 662 } 663 664 Path* PainterOpenVG::currentPath() const 665 { 666 return m_currentPath; 667 } 668 669 void PainterOpenVG::drawPath(VGbitfield specifiedPaintModes, WindRule fillRule) 670 { 671 ASSERT(m_state); 672 673 VGbitfield paintModes = 0; 674 if (!m_state->strokeDisabled()) 675 paintModes |= VG_STROKE_PATH; 676 if (!m_state->fillDisabled()) 677 paintModes |= VG_FILL_PATH; 678 679 paintModes &= specifiedPaintModes; 680 681 if (!paintModes) 682 return; 683 684 m_surface->makeCurrent(); 685 686 vgSeti(VG_FILL_RULE, toVGFillRule(fillRule)); 687 vgDrawPath(m_currentPath->platformPath()->vgPath(), paintModes); 688 ASSERT_VG_NO_ERROR(); 622 689 } 623 690 -
trunk/WebCore/platform/graphics/openvg/PainterOpenVG.h
r55369 r55371 37 37 class IntRect; 38 38 class IntSize; 39 class Path; 39 40 class SurfaceOpenVG; 40 41 … … 61 62 void setTransformation(const AffineTransform&); 62 63 void concatTransformation(const AffineTransform&); 64 65 static void transformPath(VGPath dst, VGPath src, const AffineTransform&); 63 66 64 67 CompositeOperator compositeOperation() const; … … 97 100 void translate(float dx, float dy); 98 101 102 void beginPath(); 103 void addPath(const Path&); 104 Path* currentPath() const; 105 void drawPath(VGbitfield paintModes = (VG_STROKE_PATH | VG_FILL_PATH), WindRule fillRule = RULE_NONZERO); 106 99 107 void intersectClipRect(const FloatRect&); 100 108 … … 115 123 PlatformPainterState* m_state; 116 124 SurfaceOpenVG* m_surface; 125 Path* m_currentPath; 117 126 }; 118 127
Note: See TracChangeset
for help on using the changeset viewer.