| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008-2009 Torch Mobile, Inc. | 3 * Copyright (C) 2008-2009 Torch Mobile, Inc. |
| 4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 bool getTransformedClipBounds(FloatRect* bounds) const; | 148 bool getTransformedClipBounds(FloatRect* bounds) const; |
| 149 SkMatrix getTotalMatrix() const; | 149 SkMatrix getTotalMatrix() const; |
| 150 | 150 |
| 151 void setShouldAntialias(bool antialias) { mutableState()->setShouldAntialias
(antialias); } | 151 void setShouldAntialias(bool antialias) { mutableState()->setShouldAntialias
(antialias); } |
| 152 bool shouldAntialias() const { return immutableState()->shouldAntialias(); } | 152 bool shouldAntialias() const { return immutableState()->shouldAntialias(); } |
| 153 | 153 |
| 154 // Disable the anti-aliasing optimization for scales/multiple-of-90-degrees | 154 // Disable the anti-aliasing optimization for scales/multiple-of-90-degrees |
| 155 // rotations of thin ("hairline") images. | 155 // rotations of thin ("hairline") images. |
| 156 // Note: This will only be reliable when the device pixel scale/ratio is | 156 // Note: This will only be reliable when the device pixel scale/ratio is |
| 157 // fixed (e.g. when drawing to context backed by an ImageBuffer). | 157 // fixed (e.g. when drawing to context backed by an ImageBuffer). |
| 158 void disableAntialiasingOptimizationForHairlineImages() { ASSERT(!isRecordin
g()); m_antialiasHairlineImages = true; } | 158 void disableAntialiasingOptimizationForHairlineImages() { m_antialiasHairlin
eImages = true; } |
| 159 bool shouldAntialiasHairlineImages() const { return m_antialiasHairlineImage
s; } | 159 bool shouldAntialiasHairlineImages() const { return m_antialiasHairlineImage
s; } |
| 160 | 160 |
| 161 void setShouldClampToSourceRect(bool clampToSourceRect) { mutableState()->se
tShouldClampToSourceRect(clampToSourceRect); } | 161 void setShouldClampToSourceRect(bool clampToSourceRect) { mutableState()->se
tShouldClampToSourceRect(clampToSourceRect); } |
| 162 bool shouldClampToSourceRect() const { return immutableState()->shouldClampT
oSourceRect(); } | 162 bool shouldClampToSourceRect() const { return immutableState()->shouldClampT
oSourceRect(); } |
| 163 | 163 |
| 164 // FIXME: the setter is only used once, at construction time; convert to a c
onstructor param, | 164 // FIXME: the setter is only used once, at construction time; convert to a c
onstructor param, |
| 165 // and possibly consolidate with other flags (paintDisabled, isPrinting, ...
) | 165 // and possibly consolidate with other flags (paintDisabled, isPrinting, ...
) |
| 166 void setShouldSmoothFonts(bool smoothFonts) { m_shouldSmoothFonts = smoothFo
nts; } | 166 void setShouldSmoothFonts(bool smoothFonts) { m_shouldSmoothFonts = smoothFo
nts; } |
| 167 | 167 |
| 168 // Turn off LCD text for the paint if not supported on this context. | 168 // Turn off LCD text for the paint if not supported on this context. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 void clearRect(const FloatRect&); | 252 void clearRect(const FloatRect&); |
| 253 | 253 |
| 254 void strokeRect(const FloatRect&); | 254 void strokeRect(const FloatRect&); |
| 255 void strokeRect(const FloatRect&, float lineWidth); | 255 void strokeRect(const FloatRect&, float lineWidth); |
| 256 | 256 |
| 257 void fillBetweenRoundedRects(const IntRect&, const IntSize& outerTopLeft, co
nst IntSize& outerTopRight, const IntSize& outerBottomLeft, const IntSize& outer
BottomRight, | 257 void fillBetweenRoundedRects(const IntRect&, const IntSize& outerTopLeft, co
nst IntSize& outerTopRight, const IntSize& outerBottomLeft, const IntSize& outer
BottomRight, |
| 258 const IntRect&, const IntSize& innerTopLeft, const IntSize& innerTopRigh
t, const IntSize& innerBottomLeft, const IntSize& innerBottomRight, const Color&
); | 258 const IntRect&, const IntSize& innerTopLeft, const IntSize& innerTopRigh
t, const IntSize& innerBottomLeft, const IntSize& innerBottomRight, const Color&
); |
| 259 void fillBetweenRoundedRects(const RoundedRect&, const RoundedRect&, const C
olor&); | 259 void fillBetweenRoundedRects(const RoundedRect&, const RoundedRect&, const C
olor&); |
| 260 | 260 |
| 261 void drawDisplayList(DisplayList*); | 261 void drawDisplayList(DisplayList*, const FloatPoint&); |
| 262 | 262 |
| 263 void drawImage(Image*, const IntPoint&, CompositeOperator = CompositeSourceO
ver, RespectImageOrientationEnum = DoNotRespectImageOrientation); | 263 void drawImage(Image*, const IntPoint&, CompositeOperator = CompositeSourceO
ver, RespectImageOrientationEnum = DoNotRespectImageOrientation); |
| 264 void drawImage(Image*, const IntRect&, CompositeOperator = CompositeSourceOv
er, RespectImageOrientationEnum = DoNotRespectImageOrientation); | 264 void drawImage(Image*, const IntRect&, CompositeOperator = CompositeSourceOv
er, RespectImageOrientationEnum = DoNotRespectImageOrientation); |
| 265 void drawImage(Image*, const FloatRect& destRect); | 265 void drawImage(Image*, const FloatRect& destRect); |
| 266 void drawImage(Image*, const FloatRect& destRect, const FloatRect& srcRect,
CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotResp
ectImageOrientation); | 266 void drawImage(Image*, const FloatRect& destRect, const FloatRect& srcRect,
CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotResp
ectImageOrientation); |
| 267 void drawImage(Image*, const FloatRect& destRect, const FloatRect& srcRect,
CompositeOperator, WebBlendMode, RespectImageOrientationEnum = DoNotRespectImage
Orientation); | 267 void drawImage(Image*, const FloatRect& destRect, const FloatRect& srcRect,
CompositeOperator, WebBlendMode, RespectImageOrientationEnum = DoNotRespectImage
Orientation); |
| 268 | 268 |
| 269 void drawTiledImage(Image*, const IntRect& destRect, const IntPoint& srcPoin
t, const IntSize& tileSize, | 269 void drawTiledImage(Image*, const IntRect& destRect, const IntPoint& srcPoin
t, const IntSize& tileSize, |
| 270 CompositeOperator = CompositeSourceOver, WebBlendMode = WebBlendModeNorm
al, const IntSize& repeatSpacing = IntSize()); | 270 CompositeOperator = CompositeSourceOver, WebBlendMode = WebBlendModeNorm
al, const IntSize& repeatSpacing = IntSize()); |
| 271 void drawTiledImage(Image*, const IntRect& destRect, const IntRect& srcRect, | 271 void drawTiledImage(Image*, const IntRect& destRect, const IntRect& srcRect, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 enum DocumentMarkerLineStyle { | 312 enum DocumentMarkerLineStyle { |
| 313 DocumentMarkerSpellingLineStyle, | 313 DocumentMarkerSpellingLineStyle, |
| 314 DocumentMarkerGrammarLineStyle | 314 DocumentMarkerGrammarLineStyle |
| 315 }; | 315 }; |
| 316 void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarke
rLineStyle); | 316 void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarke
rLineStyle); |
| 317 | 317 |
| 318 void beginTransparencyLayer(float opacity, const FloatRect* = 0); | 318 void beginTransparencyLayer(float opacity, const FloatRect* = 0); |
| 319 void beginLayer(float opacity, CompositeOperator, const FloatRect* = 0, Colo
rFilter = ColorFilterNone, ImageFilter* = 0); | 319 void beginLayer(float opacity, CompositeOperator, const FloatRect* = 0, Colo
rFilter = ColorFilterNone, ImageFilter* = 0); |
| 320 void endLayer(); | 320 void endLayer(); |
| 321 | 321 |
| 322 // Instead of being dispatched to the active canvas, draw commands following
beginRecording() | |
| 323 // are stored in a display list that can be replayed at a later time. | |
| 324 void beginRecording(const FloatRect& bounds); | |
| 325 PassRefPtr<DisplayList> endRecording(); | |
| 326 | |
| 327 bool hasShadow() const; | 322 bool hasShadow() const; |
| 328 void setShadow(const FloatSize& offset, float blur, const Color&, | 323 void setShadow(const FloatSize& offset, float blur, const Color&, |
| 329 DrawLooperBuilder::ShadowTransformMode = DrawLooperBuilder::ShadowRespec
tsTransforms, | 324 DrawLooperBuilder::ShadowTransformMode = DrawLooperBuilder::ShadowRespec
tsTransforms, |
| 330 DrawLooperBuilder::ShadowAlphaMode = DrawLooperBuilder::ShadowRespectsAl
pha); | 325 DrawLooperBuilder::ShadowAlphaMode = DrawLooperBuilder::ShadowRespectsAl
pha); |
| 331 void clearShadow() { clearDrawLooper(); } | 326 void clearShadow() { clearDrawLooper(); } |
| 332 | 327 |
| 333 // It is assumed that this draw looper is used only for shadows | 328 // It is assumed that this draw looper is used only for shadows |
| 334 // (i.e. a draw looper is set if and only if there is a shadow). | 329 // (i.e. a draw looper is set if and only if there is a shadow). |
| 335 // The builder passed into this method will be destroyed. | 330 // The builder passed into this method will be destroyed. |
| 336 void setDrawLooper(PassOwnPtr<DrawLooperBuilder>); | 331 void setDrawLooper(PassOwnPtr<DrawLooperBuilder>); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 return; | 454 return; |
| 460 | 455 |
| 461 m_canvas->save(); | 456 m_canvas->save(); |
| 462 m_pendingCanvasSave = false; | 457 m_pendingCanvasSave = false; |
| 463 } | 458 } |
| 464 | 459 |
| 465 void didDrawTextInRect(const SkRect& textRect); | 460 void didDrawTextInRect(const SkRect& textRect); |
| 466 | 461 |
| 467 void fillRectWithRoundedHole(const IntRect&, const RoundedRect& roundedHoleR
ect, const Color&); | 462 void fillRectWithRoundedHole(const IntRect&, const RoundedRect& roundedHoleR
ect, const Color&); |
| 468 | 463 |
| 469 bool isRecording() const; | |
| 470 | |
| 471 // null indicates painting is contextDisabled. Never delete this object. | 464 // null indicates painting is contextDisabled. Never delete this object. |
| 472 SkCanvas* m_canvas; | 465 SkCanvas* m_canvas; |
| 473 | 466 |
| 474 // Paint states stack. Enables local drawing state change with save()/restor
e() calls. | 467 // Paint states stack. Enables local drawing state change with save()/restor
e() calls. |
| 475 // This state controls the appearance of drawn content. | 468 // This state controls the appearance of drawn content. |
| 476 // We do not delete from this stack to avoid memory churn. | 469 // We do not delete from this stack to avoid memory churn. |
| 477 Vector<OwnPtr<GraphicsContextState> > m_paintStateStack; | 470 Vector<OwnPtr<GraphicsContextState> > m_paintStateStack; |
| 478 // Current index on the stack. May not be the last thing on the stack. | 471 // Current index on the stack. May not be the last thing on the stack. |
| 479 unsigned m_paintStateIndex; | 472 unsigned m_paintStateIndex; |
| 480 // Raw pointer to the current state. | 473 // Raw pointer to the current state. |
| 481 GraphicsContextState* m_paintState; | 474 GraphicsContextState* m_paintState; |
| 482 | 475 |
| 483 // Currently pending save flags for Skia Canvas state. | 476 // Currently pending save flags for Skia Canvas state. |
| 484 // Canvas state includes the canavs, it's matrix and clips. Think of it as _
where_ | 477 // Canvas state includes the canavs, it's matrix and clips. Think of it as _
where_ |
| 485 // the draw operations will happen. | 478 // the draw operations will happen. |
| 486 struct CanvasSaveState; | 479 struct CanvasSaveState; |
| 487 Vector<CanvasSaveState> m_canvasStateStack; | 480 Vector<CanvasSaveState> m_canvasStateStack; |
| 488 bool m_pendingCanvasSave; | 481 bool m_pendingCanvasSave; |
| 489 | 482 |
| 490 struct RecordingState; | |
| 491 Vector<RecordingState> m_recordingStateStack; | |
| 492 | |
| 493 #if ENABLE(ASSERT) | 483 #if ENABLE(ASSERT) |
| 494 unsigned m_layerCount; | 484 unsigned m_layerCount; |
| 495 bool m_disableDestructionChecks; | 485 bool m_disableDestructionChecks; |
| 496 #endif | 486 #endif |
| 497 // Tracks the region painted opaque via the GraphicsContext. | 487 // Tracks the region painted opaque via the GraphicsContext. |
| 498 RegionTracker m_trackedRegion; | 488 RegionTracker m_trackedRegion; |
| 499 | 489 |
| 500 // Tracks the region where text is painted via the GraphicsContext. | 490 // Tracks the region where text is painted via the GraphicsContext. |
| 501 SkRect m_textRegion; | 491 SkRect m_textRegion; |
| 502 | 492 |
| 503 unsigned m_disabledState; | 493 unsigned m_disabledState; |
| 504 | 494 |
| 505 float m_deviceScaleFactor; | 495 float m_deviceScaleFactor; |
| 506 | 496 |
| 507 // Activation for the above region tracking features | 497 // Activation for the above region tracking features |
| 508 unsigned m_regionTrackingMode : 2; | 498 unsigned m_regionTrackingMode : 2; |
| 509 bool m_trackTextRegion : 1; | 499 bool m_trackTextRegion : 1; |
| 510 | 500 |
| 511 bool m_accelerated : 1; | 501 bool m_accelerated : 1; |
| 512 bool m_isCertainlyOpaque : 1; | 502 bool m_isCertainlyOpaque : 1; |
| 513 bool m_antialiasHairlineImages : 1; | 503 bool m_antialiasHairlineImages : 1; |
| 514 bool m_shouldSmoothFonts : 1; | 504 bool m_shouldSmoothFonts : 1; |
| 515 }; | 505 }; |
| 516 | 506 |
| 517 } // namespace blink | 507 } // namespace blink |
| 518 | 508 |
| 519 #endif // SKY_ENGINE_PLATFORM_GRAPHICS_GRAPHICSCONTEXT_H_ | 509 #endif // SKY_ENGINE_PLATFORM_GRAPHICS_GRAPHICSCONTEXT_H_ |
| OLD | NEW |