| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Apple Inc. All rights reserv
ed. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 class HTMLCanvasElement; | 57 class HTMLCanvasElement; |
| 58 class HTMLImageElement; | 58 class HTMLImageElement; |
| 59 class HTMLVideoElement; | 59 class HTMLVideoElement; |
| 60 class ImageData; | 60 class ImageData; |
| 61 class TextMetrics; | 61 class TextMetrics; |
| 62 | 62 |
| 63 typedef int ExceptionCode; | 63 typedef int ExceptionCode; |
| 64 | 64 |
| 65 class CanvasRenderingContext2D : public CanvasRenderingContext, public CanvasPat
hMethods { | 65 class CanvasRenderingContext2D : public CanvasRenderingContext, public CanvasPat
hMethods { |
| 66 public: | 66 public: |
| 67 static PassOwnPtr<CanvasRenderingContext2D> create(HTMLCanvasElement* canvas
, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode) | 67 static PassOwnPtr<CanvasRenderingContext2D> create(HTMLCanvasElement* canvas
, bool usesCSSCompatibilityParseMode) |
| 68 { | 68 { |
| 69 return adoptPtr(new CanvasRenderingContext2D(canvas, usesCSSCompatibilit
yParseMode, usesDashboardCompatibilityMode)); | 69 return adoptPtr(new CanvasRenderingContext2D(canvas, usesCSSCompatibilit
yParseMode)); |
| 70 } | 70 } |
| 71 virtual ~CanvasRenderingContext2D(); | 71 virtual ~CanvasRenderingContext2D(); |
| 72 | 72 |
| 73 CanvasStyle* strokeStyle() const; | 73 CanvasStyle* strokeStyle() const; |
| 74 void setStrokeStyle(PassRefPtr<CanvasStyle>); | 74 void setStrokeStyle(PassRefPtr<CanvasStyle>); |
| 75 | 75 |
| 76 CanvasStyle* fillStyle() const; | 76 CanvasStyle* fillStyle() const; |
| 77 void setFillStyle(PassRefPtr<CanvasStyle>); | 77 void setFillStyle(PassRefPtr<CanvasStyle>); |
| 78 | 78 |
| 79 float lineWidth() const; | 79 float lineWidth() const; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 }; | 268 }; |
| 269 | 269 |
| 270 enum CanvasDidDrawOption { | 270 enum CanvasDidDrawOption { |
| 271 CanvasDidDrawApplyNone = 0, | 271 CanvasDidDrawApplyNone = 0, |
| 272 CanvasDidDrawApplyTransform = 1, | 272 CanvasDidDrawApplyTransform = 1, |
| 273 CanvasDidDrawApplyShadow = 1 << 1, | 273 CanvasDidDrawApplyShadow = 1 << 1, |
| 274 CanvasDidDrawApplyClip = 1 << 2, | 274 CanvasDidDrawApplyClip = 1 << 2, |
| 275 CanvasDidDrawApplyAll = 0xffffffff | 275 CanvasDidDrawApplyAll = 0xffffffff |
| 276 }; | 276 }; |
| 277 | 277 |
| 278 CanvasRenderingContext2D(HTMLCanvasElement*, bool usesCSSCompatibilityParseM
ode, bool usesDashboardCompatibilityMode); | 278 CanvasRenderingContext2D(HTMLCanvasElement*, bool usesCSSCompatibilityParseM
ode); |
| 279 | 279 |
| 280 State& modifiableState() { ASSERT(!m_unrealizedSaveCount); return m_stateSta
ck.last(); } | 280 State& modifiableState() { ASSERT(!m_unrealizedSaveCount); return m_stateSta
ck.last(); } |
| 281 const State& state() const { return m_stateStack.last(); } | 281 const State& state() const { return m_stateStack.last(); } |
| 282 | 282 |
| 283 void applyLineDash() const; | 283 void applyLineDash() const; |
| 284 void setShadow(const FloatSize& offset, float blur, RGBA32 color); | 284 void setShadow(const FloatSize& offset, float blur, RGBA32 color); |
| 285 void applyShadow(); | 285 void applyShadow(); |
| 286 bool shouldDrawShadows() const; | 286 bool shouldDrawShadows() const; |
| 287 | 287 |
| 288 void didDraw(const FloatRect&, unsigned options = CanvasDidDrawApplyAll); | 288 void didDraw(const FloatRect&, unsigned options = CanvasDidDrawApplyAll); |
| 289 void didDrawEntireCanvas(); | 289 void didDrawEntireCanvas(); |
| 290 | 290 |
| 291 GraphicsContext* drawingContext() const; | 291 GraphicsContext* drawingContext() const; |
| 292 | 292 |
| 293 void unwindStateStack(); | 293 void unwindStateStack(); |
| 294 void realizeSaves() | 294 void realizeSaves() |
| 295 { | 295 { |
| 296 if (m_unrealizedSaveCount) | 296 if (m_unrealizedSaveCount) |
| 297 realizeSavesLoop(); | 297 realizeSavesLoop(); |
| 298 } | 298 } |
| 299 void realizeSavesLoop(); | 299 void realizeSavesLoop(); |
| 300 | 300 |
| 301 void applyStrokePattern(); | 301 void applyStrokePattern(); |
| 302 void applyFillPattern(); | 302 void applyFillPattern(); |
| 303 | 303 |
| 304 void drawTextInternal(const String& text, float x, float y, bool fill, float
maxWidth = 0, bool useMaxWidth = false); | 304 void drawTextInternal(const String& text, float x, float y, bool fill, float
maxWidth = 0, bool useMaxWidth = false); |
| 305 | 305 |
| 306 const Font& accessFont(); | 306 const Font& accessFont(); |
| 307 | 307 |
| 308 #if ENABLE(DASHBOARD_SUPPORT) | |
| 309 void clearPathForDashboardBackwardCompatibilityMode(); | |
| 310 #endif | |
| 311 | |
| 312 void clearCanvas(); | 308 void clearCanvas(); |
| 313 Path transformAreaToDevice(const Path&) const; | 309 Path transformAreaToDevice(const Path&) const; |
| 314 Path transformAreaToDevice(const FloatRect&) const; | 310 Path transformAreaToDevice(const FloatRect&) const; |
| 315 bool rectContainsCanvas(const FloatRect&) const; | 311 bool rectContainsCanvas(const FloatRect&) const; |
| 316 | 312 |
| 317 template<class T> IntRect calculateCompositingBufferRect(const T&, IntSize*)
; | 313 template<class T> IntRect calculateCompositingBufferRect(const T&, IntSize*)
; |
| 318 PassOwnPtr<ImageBuffer> createCompositingBuffer(const IntRect&); | 314 PassOwnPtr<ImageBuffer> createCompositingBuffer(const IntRect&); |
| 319 void compositeBuffer(ImageBuffer*, const IntRect&, CompositeOperator); | 315 void compositeBuffer(ImageBuffer*, const IntRect&, CompositeOperator); |
| 320 | 316 |
| 321 void inflateStrokeRect(FloatRect&) const; | 317 void inflateStrokeRect(FloatRect&) const; |
| 322 | 318 |
| 323 template<class T> void fullCanvasCompositedFill(const T&); | 319 template<class T> void fullCanvasCompositedFill(const T&); |
| 324 template<class T> void fullCanvasCompositedDrawImage(T*, ColorSpace, const F
loatRect&, const FloatRect&, CompositeOperator); | 320 template<class T> void fullCanvasCompositedDrawImage(T*, ColorSpace, const F
loatRect&, const FloatRect&, CompositeOperator); |
| 325 | 321 |
| 326 void prepareGradientForDashboard(CanvasGradient* gradient) const; | |
| 327 | |
| 328 PassRefPtr<ImageData> getImageData(ImageBuffer::CoordinateSystem, float sx,
float sy, float sw, float sh, ExceptionCode&) const; | 322 PassRefPtr<ImageData> getImageData(ImageBuffer::CoordinateSystem, float sx,
float sy, float sw, float sh, ExceptionCode&) const; |
| 329 void putImageData(ImageData*, ImageBuffer::CoordinateSystem, float dx, float
dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionC
ode&); | 323 void putImageData(ImageData*, ImageBuffer::CoordinateSystem, float dx, float
dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionC
ode&); |
| 330 | 324 |
| 331 virtual bool is2d() const OVERRIDE { return true; } | 325 virtual bool is2d() const OVERRIDE { return true; } |
| 332 virtual bool isAccelerated() const OVERRIDE; | 326 virtual bool isAccelerated() const OVERRIDE; |
| 333 | 327 |
| 334 virtual bool isTransformInvertible() const { return state().m_invertibleCTM;
} | 328 virtual bool isTransformInvertible() const { return state().m_invertibleCTM;
} |
| 335 | 329 |
| 336 #if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING) | 330 #if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING) |
| 337 virtual PlatformLayer* platformLayer() const OVERRIDE; | 331 virtual PlatformLayer* platformLayer() const OVERRIDE; |
| 338 #endif | 332 #endif |
| 339 | 333 |
| 340 Vector<State, 1> m_stateStack; | 334 Vector<State, 1> m_stateStack; |
| 341 unsigned m_unrealizedSaveCount; | 335 unsigned m_unrealizedSaveCount; |
| 342 bool m_usesCSSCompatibilityParseMode; | 336 bool m_usesCSSCompatibilityParseMode; |
| 343 #if ENABLE(DASHBOARD_SUPPORT) | |
| 344 bool m_usesDashboardCompatibilityMode; | |
| 345 #endif | |
| 346 }; | 337 }; |
| 347 | 338 |
| 348 } // namespace WebCore | 339 } // namespace WebCore |
| 349 | 340 |
| 350 #endif | 341 #endif |
| OLD | NEW |