| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 void scrollPathIntoView(); | 156 void scrollPathIntoView(); |
| 157 void scrollPathIntoView(Path2D*); | 157 void scrollPathIntoView(Path2D*); |
| 158 | 158 |
| 159 void clearRect(float x, float y, float width, float height); | 159 void clearRect(float x, float y, float width, float height); |
| 160 void fillRect(float x, float y, float width, float height); | 160 void fillRect(float x, float y, float width, float height); |
| 161 void strokeRect(float x, float y, float width, float height); | 161 void strokeRect(float x, float y, float width, float height); |
| 162 | 162 |
| 163 void drawImage(const CanvasImageSourceUnion&, float x, float y, ExceptionSta
te&); | 163 void drawImage(const CanvasImageSourceUnion&, float x, float y, ExceptionSta
te&); |
| 164 void drawImage(const CanvasImageSourceUnion&, float x, float y, float width,
float height, ExceptionState&); | 164 void drawImage(const CanvasImageSourceUnion&, float x, float y, float width,
float height, ExceptionState&); |
| 165 void drawImage(const CanvasImageSourceUnion&, float sx, float sy, float sw,
float sh, float dx, float dy, float dw, float dh, ExceptionState&); | 165 void drawImage(const CanvasImageSourceUnion&, float sx, float sy, float sw,
float sh, float dx, float dy, float dw, float dh, ExceptionState&); |
| 166 void drawImage(CanvasImageSource*, float sx, float sy, float sw, float sh, f
loat dx, float dy, float dw, float dh, ExceptionState&); |
| 166 | 167 |
| 167 PassRefPtrWillBeRawPtr<CanvasGradient> createLinearGradient(float x0, float
y0, float x1, float y1); | 168 PassRefPtrWillBeRawPtr<CanvasGradient> createLinearGradient(float x0, float
y0, float x1, float y1); |
| 168 PassRefPtrWillBeRawPtr<CanvasGradient> createRadialGradient(float x0, float
y0, float r0, float x1, float y1, float r1, ExceptionState&); | 169 PassRefPtrWillBeRawPtr<CanvasGradient> createRadialGradient(float x0, float
y0, float r0, float x1, float y1, float r1, ExceptionState&); |
| 169 PassRefPtrWillBeRawPtr<CanvasPattern> createPattern(const CanvasImageSourceU
nion&, const String& repetitionType, ExceptionState&); | 170 PassRefPtrWillBeRawPtr<CanvasPattern> createPattern(const CanvasImageSourceU
nion&, const String& repetitionType, ExceptionState&); |
| 170 | 171 |
| 171 PassRefPtrWillBeRawPtr<ImageData> createImageData(PassRefPtrWillBeRawPtr<Ima
geData>) const; | 172 PassRefPtrWillBeRawPtr<ImageData> createImageData(PassRefPtrWillBeRawPtr<Ima
geData>) const; |
| 172 PassRefPtrWillBeRawPtr<ImageData> createImageData(float width, float height,
ExceptionState&) const; | 173 PassRefPtrWillBeRawPtr<ImageData> createImageData(float width, float height,
ExceptionState&) const; |
| 173 PassRefPtrWillBeRawPtr<ImageData> getImageData(float sx, float sy, float sw,
float sh, ExceptionState&) const; | 174 PassRefPtrWillBeRawPtr<ImageData> getImageData(float sx, float sy, float sw,
float sh, ExceptionState&) const; |
| 174 void putImageData(ImageData*, float dx, float dy); | 175 void putImageData(ImageData*, float dx, float dy); |
| 175 void putImageData(ImageData*, float dx, float dy, float dirtyX, float dirtyY
, float dirtyWidth, float dirtyHeight); | 176 void putImageData(ImageData*, float dx, float dy, float dirtyX, float dirtyY
, float dirtyWidth, float dirtyHeight); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 unsigned hitRegionsCount() const; | 213 unsigned hitRegionsCount() const; |
| 213 | 214 |
| 214 void loseContext(); | 215 void loseContext(); |
| 215 void restoreContext(); | 216 void restoreContext(); |
| 216 | 217 |
| 217 void restoreCanvasMatrixClipStack(); | 218 void restoreCanvasMatrixClipStack(); |
| 218 | 219 |
| 219 virtual void trace(Visitor*) override; | 220 virtual void trace(Visitor*) override; |
| 220 | 221 |
| 221 private: | 222 private: |
| 223 friend class CanvasRenderingContext2DAutoRestoreSkCanvas; |
| 224 |
| 222 enum Direction { | 225 enum Direction { |
| 223 DirectionInherit, | 226 DirectionInherit, |
| 224 DirectionRTL, | 227 DirectionRTL, |
| 225 DirectionLTR | 228 DirectionLTR |
| 226 }; | 229 }; |
| 227 | 230 |
| 228 enum ClipListCopyMode { | 231 enum ClipListCopyMode { |
| 229 CopyClipList, | 232 CopyClipList, |
| 230 DontCopyClipList | 233 DontCopyClipList |
| 231 }; | 234 }; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // Text state. | 271 // Text state. |
| 269 TextAlign m_textAlign; | 272 TextAlign m_textAlign; |
| 270 TextBaseline m_textBaseline; | 273 TextBaseline m_textBaseline; |
| 271 Direction m_direction; | 274 Direction m_direction; |
| 272 | 275 |
| 273 String m_unparsedFont; | 276 String m_unparsedFont; |
| 274 Font m_font; | 277 Font m_font; |
| 275 bool m_realizedFont; | 278 bool m_realizedFont; |
| 276 | 279 |
| 277 bool m_hasClip; | 280 bool m_hasClip; |
| 281 bool m_hasComplexClip; |
| 278 | 282 |
| 279 ClipList m_clipList; | 283 ClipList m_clipList; |
| 280 }; | 284 }; |
| 281 | 285 |
| 282 CanvasRenderingContext2D(HTMLCanvasElement*, const CanvasContextCreationAttr
ibutes& attrs, Document&); | 286 CanvasRenderingContext2D(HTMLCanvasElement*, const CanvasContextCreationAttr
ibutes& attrs, Document&); |
| 283 | 287 |
| 284 State& modifiableState() { ASSERT(!state().m_unrealizedSaveCount); return *m
_stateStack.last(); } | 288 State& modifiableState() { ASSERT(!state().m_unrealizedSaveCount); return *m
_stateStack.last(); } |
| 285 const State& state() const { return *m_stateStack.last(); } | 289 const State& state() const { return *m_stateStack.last(); } |
| 286 | 290 |
| 287 void applyLineDash() const; | 291 void applyLineDash() const; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 299 | 303 |
| 300 GraphicsContext* drawingContext() const; // Deprecated: use drawingCanvas | 304 GraphicsContext* drawingContext() const; // Deprecated: use drawingCanvas |
| 301 SkCanvas* drawingCanvas() const; | 305 SkCanvas* drawingCanvas() const; |
| 302 | 306 |
| 303 void unwindStateStack(); | 307 void unwindStateStack(); |
| 304 void realizeSaves(SkCanvas*); | 308 void realizeSaves(SkCanvas*); |
| 305 | 309 |
| 306 void applyStrokePattern(); | 310 void applyStrokePattern(); |
| 307 void applyFillPattern(); | 311 void applyFillPattern(); |
| 308 | 312 |
| 309 void drawImageInternal(CanvasImageSource*, float sx, float sy, float sw, flo
at sh, float dx, float dy, float dw, float dh, ExceptionState&); | |
| 310 | |
| 311 void fillInternal(const Path&, const String& windingRuleString); | 313 void fillInternal(const Path&, const String& windingRuleString); |
| 312 void strokeInternal(const Path&); | 314 void strokeInternal(const Path&); |
| 313 void clipInternal(const Path&, const String& windingRuleString); | 315 void clipInternal(const Path&, const String& windingRuleString); |
| 314 | 316 |
| 315 bool isPointInPathInternal(const Path&, const float x, const float y, const
String& windingRuleString); | 317 bool isPointInPathInternal(const Path&, const float x, const float y, const
String& windingRuleString); |
| 316 bool isPointInStrokeInternal(const Path&, const float x, const float y); | 318 bool isPointInStrokeInternal(const Path&, const float x, const float y); |
| 317 | 319 |
| 318 void scrollPathIntoViewInternal(const Path&); | 320 void scrollPathIntoViewInternal(const Path&); |
| 319 | 321 |
| 320 void drawTextInternal(const String& text, float x, float y, bool fill, float
maxWidth = 0, bool useMaxWidth = false); | 322 void drawTextInternal(const String& text, float x, float y, bool fill, float
maxWidth = 0, bool useMaxWidth = false); |
| 321 | 323 |
| 322 const Font& accessFont(); | 324 const Font& accessFont(); |
| 323 int getFontBaseline(const FontMetrics&) const; | 325 int getFontBaseline(const FontMetrics&) const; |
| 324 | 326 |
| 325 void clearCanvas(); | 327 void clearCanvas(); |
| 326 bool rectContainsTransformedRect(const FloatRect&, const FloatRect&) const; | 328 bool rectContainsTransformedRect(const FloatRect&, const FloatRect&) const; |
| 327 | 329 |
| 328 void inflateStrokeRect(FloatRect&) const; | 330 void inflateStrokeRect(FloatRect&) const; |
| 329 | 331 |
| 330 void fullCanvasCompositedDraw(PassOwnPtr<Closure> draw); | 332 void fullCanvasCompositedDraw(PassOwnPtr<Closure> draw); |
| 331 | 333 |
| 332 void drawFocusIfNeededInternal(const Path&, Element*); | 334 void drawFocusIfNeededInternal(const Path&, Element*); |
| 333 bool focusRingCallIsValid(const Path&, Element*); | 335 bool focusRingCallIsValid(const Path&, Element*); |
| 334 void drawFocusRing(const Path&); | 336 void drawFocusRing(const Path&); |
| 335 | 337 |
| 336 bool hasClip() { return state().m_hasClip; } | 338 bool hasClip() { return state().m_hasClip; } |
| 337 | 339 |
| 338 void validateStateStack(); | 340 void validateStateStack(); |
| 339 | 341 |
| 342 enum DrawType { |
| 343 ClipFill, // Fill that is already known to cover the current clip |
| 344 UntransformedUnclippedFill |
| 345 }; |
| 346 |
| 347 enum ImageType { |
| 348 NoImage, |
| 349 OpaqueImage, |
| 350 NonOpaqueImage |
| 351 }; |
| 352 |
| 353 void checkOverdraw(const SkRect&, const SkPaint*, ImageType, DrawType); |
| 354 |
| 340 virtual bool is2d() const override { return true; } | 355 virtual bool is2d() const override { return true; } |
| 341 virtual bool isAccelerated() const override; | 356 virtual bool isAccelerated() const override; |
| 342 virtual bool hasAlpha() const override { return m_hasAlpha; } | 357 virtual bool hasAlpha() const override { return m_hasAlpha; } |
| 343 virtual void setIsHidden(bool) override; | 358 virtual void setIsHidden(bool) override; |
| 344 | 359 |
| 345 virtual bool isTransformInvertible() const override { return state().m_inver
tibleCTM; } | 360 virtual bool isTransformInvertible() const override { return state().m_inver
tibleCTM; } |
| 346 | 361 |
| 347 virtual WebLayer* platformLayer() const override; | 362 virtual WebLayer* platformLayer() const override; |
| 348 TextDirection toTextDirection(Direction, RenderStyle** computedStyle = nullp
tr) const; | 363 TextDirection toTextDirection(Direction, RenderStyle** computedStyle = nullp
tr) const; |
| 349 | 364 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 360 Timer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer; | 375 Timer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer; |
| 361 Timer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer; | 376 Timer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer; |
| 362 Timer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer; | 377 Timer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer; |
| 363 }; | 378 }; |
| 364 | 379 |
| 365 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, CanvasRenderingContext, context, con
text->is2d(), context.is2d()); | 380 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, CanvasRenderingContext, context, con
text->is2d(), context.is2d()); |
| 366 | 381 |
| 367 } // namespace blink | 382 } // namespace blink |
| 368 | 383 |
| 369 #endif // CanvasRenderingContext2D_h | 384 #endif // CanvasRenderingContext2D_h |
| OLD | NEW |