Changeset 54063 in webkit
- Timestamp:
- Jan 29, 2010 7:43:08 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r54061 r54063 1 2010-01-29 Jakob Petsovits <jpetsovits@rim.com> 2 3 Reviewed by Nikolas Zimmermann. 4 5 [OpenVG] Implement a basic GraphicsContext on top of a new PainterOpenVG class 6 https://bugs.webkit.org/show_bug.cgi?id=33405 7 8 PainterOpenVG provides painter state management that works 9 on a single (EGL) context, and apart from painter state 10 implements a single drawing operation (for now), drawRect(). 11 12 It is a generic painter class that cooperates with 13 SurfaceOpenVG to enable robust surface/context switching 14 (given that EGL doesn't notify us if somebody switches 15 the surface/context behind our backs), and provides 16 painting operations close to OpenVG's way of working 17 that GraphicsContext, Path, Image, Font and other WebKit 18 platform classes can use to draw on. 19 20 Initial code for state management and OpenVG scissoring by 21 Eli Fidler <efidler@rim.com>. VGRect/VGMatrix and the bulk 22 of the transformations code by Adam Treat <atreat@rim.com>. 23 Preliminary drawFocusRing() implementation by Yong Li <yoli@rim.com>. 24 25 * platform/graphics/FloatRect.h: 26 * platform/graphics/GraphicsContext.cpp: 27 * platform/graphics/GraphicsContext.h: 28 * platform/graphics/openvg/GraphicsContextOpenVG.cpp: Added. 29 (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate): 30 (WebCore::GraphicsContext::GraphicsContext): 31 (WebCore::GraphicsContext::~GraphicsContext): 32 (WebCore::GraphicsContext::platformContext): 33 (WebCore::GraphicsContext::getCTM): 34 (WebCore::GraphicsContext::savePlatformState): 35 (WebCore::GraphicsContext::restorePlatformState): 36 (WebCore::GraphicsContext::drawRect): 37 (WebCore::GraphicsContext::drawLine): 38 (WebCore::GraphicsContext::drawEllipse): 39 (WebCore::GraphicsContext::strokeArc): 40 (WebCore::GraphicsContext::drawConvexPolygon): 41 (WebCore::GraphicsContext::fillPath): 42 (WebCore::GraphicsContext::strokePath): 43 (WebCore::GraphicsContext::fillRect): 44 (WebCore::GraphicsContext::fillRoundedRect): 45 (WebCore::GraphicsContext::beginPath): 46 (WebCore::GraphicsContext::addPath): 47 (WebCore::GraphicsContext::clip): 48 (WebCore::GraphicsContext::clipPath): 49 (WebCore::GraphicsContext::drawFocusRing): 50 (WebCore::GraphicsContext::drawLineForText): 51 (WebCore::GraphicsContext::drawLineForMisspellingOrBadGrammar): 52 (WebCore::GraphicsContext::roundToDevicePixels): 53 (WebCore::GraphicsContext::setPlatformShadow): 54 (WebCore::GraphicsContext::clearPlatformShadow): 55 (WebCore::GraphicsContext::beginTransparencyLayer): 56 (WebCore::GraphicsContext::endTransparencyLayer): 57 (WebCore::GraphicsContext::clearRect): 58 (WebCore::GraphicsContext::strokeRect): 59 (WebCore::GraphicsContext::setLineCap): 60 (WebCore::GraphicsContext::setLineDash): 61 (WebCore::GraphicsContext::setLineJoin): 62 (WebCore::GraphicsContext::setMiterLimit): 63 (WebCore::GraphicsContext::setAlpha): 64 (WebCore::GraphicsContext::setCompositeOperation): 65 (WebCore::GraphicsContext::canvasClip): 66 (WebCore::GraphicsContext::clipOut): 67 (WebCore::GraphicsContext::scale): 68 (WebCore::GraphicsContext::rotate): 69 (WebCore::GraphicsContext::translate): 70 (WebCore::GraphicsContext::origin): 71 (WebCore::GraphicsContext::clipOutEllipseInRect): 72 (WebCore::GraphicsContext::clipToImageBuffer): 73 (WebCore::GraphicsContext::addInnerRoundedRectClip): 74 (WebCore::GraphicsContext::concatCTM): 75 (WebCore::GraphicsContext::setURLForRect): 76 (WebCore::GraphicsContext::setPlatformStrokeColor): 77 (WebCore::GraphicsContext::setPlatformStrokeStyle): 78 (WebCore::GraphicsContext::setPlatformStrokeThickness): 79 (WebCore::GraphicsContext::setPlatformFillColor): 80 (WebCore::GraphicsContext::setPlatformShouldAntialias): 81 (WebCore::GraphicsContext::setImageInterpolationQuality): 82 (WebCore::GraphicsContext::imageInterpolationQuality): 83 * platform/graphics/openvg/PainterOpenVG.cpp: Added. 84 (WebCore::isNonRotatedAffineTransformation): 85 (WebCore::toVGCapStyle): 86 (WebCore::toVGJoinStyle): 87 (WebCore::toVGFillRule): 88 (WebCore::colorToVGColor): 89 (WebCore::setVGSolidColor): 90 (WebCore::PlatformPainterState::PlatformPainterState): 91 (WebCore::PlatformPainterState::copyPaintState): 92 (WebCore::PlatformPainterState::applyState): 93 (WebCore::PlatformPainterState::applyBlending): 94 (WebCore::PlatformPainterState::applyTransformationMatrix): 95 (WebCore::PlatformPainterState::applyScissorRect): 96 (WebCore::PlatformPainterState::applyStrokeStyle): 97 (WebCore::PlatformPainterState::strokeDisabled): 98 (WebCore::PlatformPainterState::fillDisabled): 99 (WebCore::PainterOpenVG::PainterOpenVG): 100 (WebCore::PainterOpenVG::~PainterOpenVG): 101 (WebCore::PainterOpenVG::begin): 102 (WebCore::PainterOpenVG::end): 103 (WebCore::PainterOpenVG::destroyPainterStates): 104 (WebCore::PainterOpenVG::applyState): 105 (WebCore::PainterOpenVG::blitToSurface): 106 (WebCore::PainterOpenVG::transformationMatrix): 107 (WebCore::PainterOpenVG::concatTransformationMatrix): 108 (WebCore::PainterOpenVG::setTransformationMatrix): 109 (WebCore::PainterOpenVG::compositeOperation): 110 (WebCore::PainterOpenVG::setCompositeOperation): 111 (WebCore::PainterOpenVG::opacity): 112 (WebCore::PainterOpenVG::setOpacity): 113 (WebCore::PainterOpenVG::strokeThickness): 114 (WebCore::PainterOpenVG::setStrokeThickness): 115 (WebCore::PainterOpenVG::strokeStyle): 116 (WebCore::PainterOpenVG::setStrokeStyle): 117 (WebCore::PainterOpenVG::setLineDash): 118 (WebCore::PainterOpenVG::setLineCap): 119 (WebCore::PainterOpenVG::setLineJoin): 120 (WebCore::PainterOpenVG::setMiterLimit): 121 (WebCore::PainterOpenVG::strokeColor): 122 (WebCore::PainterOpenVG::setStrokeColor): 123 (WebCore::PainterOpenVG::fillColor): 124 (WebCore::PainterOpenVG::setFillColor): 125 (WebCore::PainterOpenVG::antialiasingEnabled): 126 (WebCore::PainterOpenVG::setAntialiasingEnabled): 127 (WebCore::PainterOpenVG::scale): 128 (WebCore::PainterOpenVG::rotate): 129 (WebCore::PainterOpenVG::translate): 130 (WebCore::PainterOpenVG::intersectScissorRect): 131 (WebCore::PainterOpenVG::intersectClipRect): 132 (WebCore::PainterOpenVG::drawRect): 133 (WebCore::PainterOpenVG::save): 134 (WebCore::PainterOpenVG::restore): 135 * platform/graphics/openvg/PainterOpenVG.h: Added. 136 (WebCore::PainterOpenVG::): 137 (WebCore::PainterOpenVG::surface): 138 * platform/graphics/openvg/SurfaceOpenVG.cpp: 139 (WebCore::SurfaceOpenVG::SurfaceOpenVG): 140 (WebCore::SurfaceOpenVG::~SurfaceOpenVG): 141 (WebCore::SurfaceOpenVG::makeCurrent): 142 (WebCore::SurfaceOpenVG::makeCompatibleCurrent): 143 (WebCore::SurfaceOpenVG::setActivePainter): 144 (WebCore::SurfaceOpenVG::activePainter): 145 * platform/graphics/openvg/SurfaceOpenVG.h: 146 (WebCore::SurfaceOpenVG::): 147 * platform/graphics/openvg/VGUtils.cpp: Added. 148 (WebCore::VGMatrix::VGMatrix): 149 (WebCore::VGMatrix::operator TransformationMatrix): 150 (WebCore::TransformationMatrix::operator VGMatrix): 151 (WebCore::VGRect::VGRect): 152 (WebCore::VGRect::operator FloatRect): 153 (WebCore::FloatRect::operator VGRect): 154 * platform/graphics/openvg/VGUtils.h: 155 (WebCore::VGMatrix::toVGfloat): 156 (WebCore::VGRect::toVGfloat): 157 * platform/graphics/transforms/TransformationMatrix.h: 158 1 159 2010-01-29 Philippe Normand <pnormand@igalia.com> 2 160 -
trunk/WebCore/platform/graphics/FloatRect.h
r52791 r54063 62 62 namespace WebCore { 63 63 64 #if PLATFORM(OPENVG) 65 class VGRect; 66 #endif 67 64 68 class IntRect; 65 69 … … 155 159 #endif 156 160 161 #if PLATFORM(OPENVG) 162 operator VGRect() const; 163 #endif 164 157 165 private: 158 166 FloatPoint m_location; -
trunk/WebCore/platform/graphics/GraphicsContext.cpp
r53949 r54063 507 507 #endif 508 508 509 #if !PLATFORM(QT) && !PLATFORM(CAIRO) && !PLATFORM(SKIA) && !PLATFORM(HAIKU) 509 #if !PLATFORM(QT) && !PLATFORM(CAIRO) && !PLATFORM(SKIA) && !PLATFORM(HAIKU) && !PLATFORM(OPENVG) 510 510 void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle&) 511 511 { -
trunk/WebCore/platform/graphics/GraphicsContext.h
r53949 r54063 42 42 #elif PLATFORM(CAIRO) 43 43 typedef struct _cairo PlatformGraphicsContext; 44 #elif PLATFORM(OPENVG) 45 namespace WebCore { 46 class SurfaceOpenVG; 47 } 48 typedef class WebCore::SurfaceOpenVG PlatformGraphicsContext; 44 49 #elif PLATFORM(QT) 45 50 QT_BEGIN_NAMESPACE -
trunk/WebCore/platform/graphics/openvg/SurfaceOpenVG.cpp
r53639 r54063 30 30 31 31 #include <wtf/Assertions.h> 32 #include <wtf/UnusedParam.h>33 32 34 33 namespace WebCore { 35 34 35 PainterOpenVG* SurfaceOpenVG::s_currentPainter = 0; 36 36 37 SurfaceOpenVG* SurfaceOpenVG::currentSurface() 37 38 { … … 46 47 #if PLATFORM(EGL) 47 48 SurfaceOpenVG::SurfaceOpenVG(const IntSize& size, const EGLDisplay& display, EGLConfig* confPtr, EGLint* errorCode) 48 : m_eglDisplay(display) 49 : m_activePainter(0) 50 , m_eglDisplay(display) 49 51 , m_eglSurface(EGL_NO_SURFACE) 50 52 , m_eglContext(EGL_NO_CONTEXT) … … 64 66 65 67 SurfaceOpenVG::SurfaceOpenVG(EGLNativeWindowType window, const EGLDisplay& display, EGLConfig* confPtr) 66 : m_eglDisplay(display) 68 : m_activePainter(0) 69 , m_eglDisplay(display) 67 70 , m_eglSurface(EGL_NO_SURFACE) 68 71 , m_eglContext(EGL_NO_CONTEXT) … … 85 88 // by itself. 86 89 SurfaceOpenVG::SurfaceOpenVG() 87 : m_eglDisplay(EGL_NO_DISPLAY) 90 : m_activePainter(0) 91 , m_eglDisplay(EGL_NO_DISPLAY) 88 92 , m_eglSurface(EGL_NO_SURFACE) 89 93 , m_eglContext(EGL_NO_CONTEXT) … … 96 100 if (!isValid()) 97 101 return; 102 103 if (m_activePainter && this == m_activePainter->baseSurface()) 104 m_activePainter->end(); 98 105 99 106 #if PLATFORM(EGL) … … 169 176 eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext); 170 177 ASSERT_EGL_NO_ERROR(); 178 s_currentPainter = 0; 171 179 } 172 #else 173 UNUSED_PARAM(mode); 174 #endif 180 #endif 181 182 if (m_activePainter && mode == ApplyPainterStateOnSurfaceSwitch 183 && s_currentPainter != m_activePainter) { 184 m_activePainter->applyState(); 185 s_currentPainter = m_activePainter; 186 } 175 187 } 176 188 … … 185 197 ASSERT_EGL_NO_ERROR(); 186 198 187 if (currentSurface != m_eglSurface 188 && !EGLDisplayOpenVG::forDisplay(m_eglDisplay)->surfacesCompatible(currentSurface, m_eglSurface)) { 199 if (currentSurface == m_eglSurface) { 200 if (m_activePainter && s_currentPainter != m_activePainter) { 201 m_activePainter->applyState(); 202 s_currentPainter = m_activePainter; 203 } 204 } else if (!EGLDisplayOpenVG::forDisplay(m_eglDisplay)->surfacesCompatible(currentSurface, m_eglSurface)) { 189 205 eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext); 190 206 ASSERT_EGL_NO_ERROR(); 207 s_currentPainter = 0; 191 208 } 192 209 // else: surfaces compatible, no need to switch contexts … … 204 221 } 205 222 206 } 223 void SurfaceOpenVG::setActivePainter(PainterOpenVG* painter) 224 { 225 ASSERT(isValid()); 226 227 // If painter is non-zero, we want to make sure there was no previous painter set. 228 ASSERT(!painter || !m_activePainter); 229 230 // Make sure a disabled painter isn't marked as global current painter anymore. 231 if (!painter && s_currentPainter == m_activePainter) 232 s_currentPainter = 0; 233 234 m_activePainter = painter; 235 } 236 237 PainterOpenVG* SurfaceOpenVG::activePainter() 238 { 239 ASSERT(isValid()); 240 return m_activePainter; 241 } 242 243 } -
trunk/WebCore/platform/graphics/openvg/SurfaceOpenVG.h
r53639 r54063 33 33 class EGLDisplayOpenVG; 34 34 #endif 35 class PainterOpenVG; 35 36 class IntSize; 36 37 … … 45 46 class SurfaceOpenVG : public Noncopyable { 46 47 public: 48 enum MakeCurrentMode { 49 ApplyPainterStateOnSurfaceSwitch, 50 DontApplyPainterState, 51 }; 52 47 53 static SurfaceOpenVG* currentSurface(); 48 54 … … 91 97 * OpenVG commands apply to it. 92 98 */ 93 void makeCurrent( );99 void makeCurrent(MakeCurrentMode mode = ApplyPainterStateOnSurfaceSwitch); 94 100 95 101 /** … … 111 117 void flush(); 112 118 119 void setActivePainter(PainterOpenVG*); 120 PainterOpenVG* activePainter(); 121 113 122 private: 123 PainterOpenVG* m_activePainter; 124 static PainterOpenVG* s_currentPainter; // global currently active painter 125 114 126 #if PLATFORM(EGL) 115 127 SurfaceOpenVG(); // for EGLDisplayOpenVG -
trunk/WebCore/platform/graphics/openvg/VGUtils.h
r53639 r54063 57 57 #endif 58 58 59 60 namespace WebCore { 61 62 class FloatRect; 63 class TransformationMatrix; 64 65 class VGMatrix { 66 public: 67 VGMatrix(const VGfloat data[9]); 68 VGMatrix(const TransformationMatrix&); 69 const VGfloat* toVGfloat() const { return m_data; } 70 operator TransformationMatrix() const; 71 private: 72 VGfloat m_data[9]; 73 }; 74 75 class VGRect { 76 public: 77 VGRect(const VGfloat data[4]); 78 VGRect(const FloatRect&); 79 const VGfloat* toVGfloat() const { return m_data; } 80 operator FloatRect() const; 81 private: 82 VGfloat m_data[4]; 83 }; 84 85 } 86 59 87 #endif -
trunk/WebCore/platform/graphics/transforms/TransformationMatrix.h
r53949 r54063 36 36 #elif PLATFORM(CAIRO) 37 37 #include <cairo.h> 38 #elif PLATFORM(OPENVG) 39 #include "VGUtils.h" 38 40 #elif PLATFORM(QT) 39 41 #include <QTransform> … … 308 310 #elif PLATFORM(CAIRO) 309 311 operator cairo_matrix_t() const; 312 #elif PLATFORM(OPENVG) 313 operator VGMatrix() const; 310 314 #elif PLATFORM(QT) 311 315 operator QTransform() const;
Note: See TracChangeset
for help on using the changeset viewer.