| 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 10 matching lines...) Expand all Loading... |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #ifndef GraphicsContext_h | 28 #ifndef GraphicsContext_h |
| 29 #define GraphicsContext_h | 29 #define GraphicsContext_h |
| 30 | 30 |
| 31 #include "core/platform/chromium/TraceEvent.h" | 31 #include "core/platform/graphics/AnnotationMode.h" |
| 32 #include "core/platform/graphics/CustomFontNotReadyAction.h" |
| 32 #include "core/platform/graphics/DashArray.h" | 33 #include "core/platform/graphics/DashArray.h" |
| 33 #include "core/platform/graphics/DrawLooper.h" | 34 #include "core/platform/graphics/DrawLooper.h" |
| 34 #include "core/platform/graphics/FloatRect.h" | 35 #include "core/platform/graphics/FloatRect.h" |
| 35 #include "core/platform/graphics/Font.h" | |
| 36 #include "core/platform/graphics/GraphicsContextAnnotation.h" | |
| 37 #include "core/platform/graphics/GraphicsContextState.h" | 36 #include "core/platform/graphics/GraphicsContextState.h" |
| 38 #include "core/platform/graphics/ImageBuffer.h" | 37 #include "core/platform/graphics/Image.h" |
| 39 #include "core/platform/graphics/ImageOrientation.h" | 38 #include "core/platform/graphics/ImageOrientation.h" |
| 39 #include "core/platform/graphics/RoundedRect.h" |
| 40 #include "core/platform/graphics/WindRule.h" |
| 40 #include "core/platform/graphics/skia/OpaqueRegionSkia.h" | 41 #include "core/platform/graphics/skia/OpaqueRegionSkia.h" |
| 41 | 42 |
| 42 #include <wtf/Noncopyable.h> | 43 #include <wtf/Noncopyable.h> |
| 43 #include <wtf/PassOwnPtr.h> | 44 #include <wtf/PassOwnPtr.h> |
| 44 | 45 |
| 45 class SkBitmap; | 46 class SkBitmap; |
| 46 class SkDevice; | 47 class SkDevice; |
| 48 class SkDrawLooper; |
| 47 class SkPaint; | 49 class SkPaint; |
| 48 class SkPath; | 50 class SkPath; |
| 49 class SkRRect; | 51 class SkRRect; |
| 50 struct SkRect; | 52 struct SkRect; |
| 51 | 53 |
| 52 namespace WebCore { | 54 namespace WebCore { |
| 53 | 55 |
| 56 class Font; |
| 57 class GraphicsContextAnnotation; |
| 54 class ImageBuffer; | 58 class ImageBuffer; |
| 55 class KURL; | 59 class KURL; |
| 60 class Path; |
| 61 class TextRun; |
| 62 class TextRunPaintInfo; |
| 56 | 63 |
| 57 class GraphicsContext { | 64 class GraphicsContext { |
| 58 WTF_MAKE_NONCOPYABLE(GraphicsContext); WTF_MAKE_FAST_ALLOCATED; | 65 WTF_MAKE_NONCOPYABLE(GraphicsContext); WTF_MAKE_FAST_ALLOCATED; |
| 59 public: | 66 public: |
| 60 enum AntiAliasingMode { | 67 enum AntiAliasingMode { |
| 61 NotAntiAliased, | 68 NotAntiAliased, |
| 62 AntiAliased | 69 AntiAliased |
| 63 }; | 70 }; |
| 64 enum AccessMode { | 71 enum AccessMode { |
| 65 ReadOnly, | 72 ReadOnly, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 94 void saveLayer(const SkRect* bounds, const SkPaint*, SkCanvas::SaveFlags = S
kCanvas::kARGB_ClipLayer_SaveFlag); | 101 void saveLayer(const SkRect* bounds, const SkPaint*, SkCanvas::SaveFlags = S
kCanvas::kARGB_ClipLayer_SaveFlag); |
| 95 void restoreLayer(); | 102 void restoreLayer(); |
| 96 | 103 |
| 97 float strokeThickness() const { return m_state->m_strokeData.thickness(); } | 104 float strokeThickness() const { return m_state->m_strokeData.thickness(); } |
| 98 void setStrokeThickness(float thickness) { m_state->m_strokeData.setThicknes
s(thickness); } | 105 void setStrokeThickness(float thickness) { m_state->m_strokeData.setThicknes
s(thickness); } |
| 99 | 106 |
| 100 StrokeStyle strokeStyle() const { return m_state->m_strokeData.style(); } | 107 StrokeStyle strokeStyle() const { return m_state->m_strokeData.style(); } |
| 101 void setStrokeStyle(StrokeStyle style) { m_state->m_strokeData.setStyle(styl
e); } | 108 void setStrokeStyle(StrokeStyle style) { m_state->m_strokeData.setStyle(styl
e); } |
| 102 | 109 |
| 103 Color strokeColor() const { return m_state->m_strokeData.color(); } | 110 Color strokeColor() const { return m_state->m_strokeData.color(); } |
| 104 void setStrokeColor(const Color&); | 111 void setStrokeColor(const Color& color) { m_state->m_strokeData.setColor(col
or); } |
| 112 SkColor effectiveStrokeColor() const; |
| 105 | 113 |
| 106 Pattern* strokePattern() const { return m_state->m_strokeData.pattern(); } | 114 Pattern* strokePattern() const { return m_state->m_strokeData.pattern(); } |
| 107 void setStrokePattern(PassRefPtr<Pattern>); | 115 void setStrokePattern(PassRefPtr<Pattern>); |
| 108 | 116 |
| 109 Gradient* strokeGradient() const { return m_state->m_strokeData.gradient();
} | 117 Gradient* strokeGradient() const { return m_state->m_strokeData.gradient();
} |
| 110 void setStrokeGradient(PassRefPtr<Gradient>); | 118 void setStrokeGradient(PassRefPtr<Gradient>); |
| 111 | 119 |
| 112 void setLineCap(LineCap cap) { m_state->m_strokeData.setLineCap(cap); } | 120 void setLineCap(LineCap cap) { m_state->m_strokeData.setLineCap(cap); } |
| 113 void setLineDash(const DashArray& dashes, float dashOffset) { m_state->m_str
okeData.setLineDash(dashes, dashOffset); } | 121 void setLineDash(const DashArray& dashes, float dashOffset) { m_state->m_str
okeData.setLineDash(dashes, dashOffset); } |
| 114 void setLineJoin(LineJoin join) { m_state->m_strokeData.setLineJoin(join); } | 122 void setLineJoin(LineJoin join) { m_state->m_strokeData.setLineJoin(join); } |
| 115 void setMiterLimit(float limit) { m_state->m_strokeData.setMiterLimit(limit)
; } | 123 void setMiterLimit(float limit) { m_state->m_strokeData.setMiterLimit(limit)
; } |
| 116 | 124 |
| 117 WindRule fillRule() const { return m_state->m_fillRule; } | 125 WindRule fillRule() const { return m_state->m_fillRule; } |
| 118 void setFillRule(WindRule fillRule) { m_state->m_fillRule = fillRule; } | 126 void setFillRule(WindRule fillRule) { m_state->m_fillRule = fillRule; } |
| 119 | 127 |
| 120 Color fillColor() const { return m_state->m_fillColor; } | 128 Color fillColor() const { return m_state->m_fillColor; } |
| 121 void setFillColor(const Color&); | 129 void setFillColor(const Color&); |
| 122 SkColor effectiveFillColor() const { return m_state->applyAlpha(m_state->m_f
illColor.rgb()); } | 130 SkColor effectiveFillColor() const; |
| 123 | 131 |
| 124 void setFillPattern(PassRefPtr<Pattern>); | 132 void setFillPattern(PassRefPtr<Pattern>); |
| 125 Pattern* fillPattern() const { return m_state->m_fillPattern.get(); } | 133 Pattern* fillPattern() const { return m_state->m_fillPattern.get(); } |
| 126 | 134 |
| 127 void setFillGradient(PassRefPtr<Gradient>); | 135 void setFillGradient(PassRefPtr<Gradient>); |
| 128 Gradient* fillGradient() const { return m_state->m_fillGradient.get(); } | 136 Gradient* fillGradient() const { return m_state->m_fillGradient.get(); } |
| 129 | 137 |
| 130 SkDrawLooper* drawLooper() const { return m_state->m_looper; } | 138 SkDrawLooper* drawLooper() const { return m_state->m_looper; } |
| 131 SkColor effectiveStrokeColor() const { return m_state->applyAlpha(m_state->m
_strokeData.color().rgb()); } | |
| 132 | 139 |
| 133 int getNormalizedAlpha() const; | 140 int getNormalizedAlpha() const; |
| 134 | 141 |
| 135 bool getClipBounds(SkRect* bounds) const; | 142 bool getClipBounds(SkRect* bounds) const; |
| 136 const SkMatrix& getTotalMatrix() const; | 143 const SkMatrix& getTotalMatrix() const; |
| 137 bool isPrintingDevice() const; | 144 bool isPrintingDevice() const; |
| 138 | 145 |
| 139 void setShouldAntialias(bool antialias) { m_state->m_shouldAntialias = antia
lias; } | 146 void setShouldAntialias(bool antialias) { m_state->m_shouldAntialias = antia
lias; } |
| 140 bool shouldAntialias() const { return m_state->m_shouldAntialias; } | 147 bool shouldAntialias() const { return m_state->m_shouldAntialias; } |
| 141 | 148 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 void clipRoundedRect(const RoundedRect&); | 281 void clipRoundedRect(const RoundedRect&); |
| 275 void clipOut(const IntRect& rect) { clipRect(rect, NotAntiAliased, SkRegion:
:kDifference_Op); } | 282 void clipOut(const IntRect& rect) { clipRect(rect, NotAntiAliased, SkRegion:
:kDifference_Op); } |
| 276 void clipOutRoundedRect(const RoundedRect&); | 283 void clipOutRoundedRect(const RoundedRect&); |
| 277 void clipPath(const Path&, WindRule = RULE_EVENODD); | 284 void clipPath(const Path&, WindRule = RULE_EVENODD); |
| 278 void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias =
true); | 285 void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias =
true); |
| 279 void clipToImageBuffer(const ImageBuffer*, const FloatRect&); | 286 void clipToImageBuffer(const ImageBuffer*, const FloatRect&); |
| 280 bool clipRect(const SkRect&, AntiAliasingMode = NotAntiAliased, SkRegion::Op
= SkRegion::kIntersect_Op); | 287 bool clipRect(const SkRect&, AntiAliasingMode = NotAntiAliased, SkRegion::Op
= SkRegion::kIntersect_Op); |
| 281 | 288 |
| 282 void drawText(const Font&, const TextRunPaintInfo&, const FloatPoint&); | 289 void drawText(const Font&, const TextRunPaintInfo&, const FloatPoint&); |
| 283 void drawEmphasisMarks(const Font&, const TextRunPaintInfo&, const AtomicStr
ing& mark, const FloatPoint&); | 290 void drawEmphasisMarks(const Font&, const TextRunPaintInfo&, const AtomicStr
ing& mark, const FloatPoint&); |
| 284 void drawBidiText(const Font&, const TextRunPaintInfo&, const FloatPoint&, F
ont::CustomFontNotReadyAction = Font::DoNotPaintIfFontNotReady); | 291 void drawBidiText(const Font&, const TextRunPaintInfo&, const FloatPoint&, C
ustomFontNotReadyAction = DoNotPaintIfFontNotReady); |
| 285 void drawHighlightForText(const Font&, const TextRun&, const FloatPoint&, in
t h, const Color& backgroundColor, int from = 0, int to = -1); | 292 void drawHighlightForText(const Font&, const TextRun&, const FloatPoint&, in
t h, const Color& backgroundColor, int from = 0, int to = -1); |
| 286 | 293 |
| 287 void drawLineForText(const FloatPoint&, float width, bool printing); | 294 void drawLineForText(const FloatPoint&, float width, bool printing); |
| 288 enum DocumentMarkerLineStyle { | 295 enum DocumentMarkerLineStyle { |
| 289 DocumentMarkerSpellingLineStyle, | 296 DocumentMarkerSpellingLineStyle, |
| 290 DocumentMarkerGrammarLineStyle | 297 DocumentMarkerGrammarLineStyle |
| 291 }; | 298 }; |
| 292 void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarke
rLineStyle); | 299 void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarke
rLineStyle); |
| 293 | 300 |
| 294 void beginTransparencyLayer(float opacity); | 301 void beginTransparencyLayer(float opacity); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 320 | 327 |
| 321 // This clip function is used only by <canvas> code. It allows | 328 // This clip function is used only by <canvas> code. It allows |
| 322 // implementations to handle clipping on the canvas differently since | 329 // implementations to handle clipping on the canvas differently since |
| 323 // the discipline is different. | 330 // the discipline is different. |
| 324 void canvasClip(const Path&, WindRule = RULE_EVENODD); | 331 void canvasClip(const Path&, WindRule = RULE_EVENODD); |
| 325 void clipOut(const Path&); | 332 void clipOut(const Path&); |
| 326 | 333 |
| 327 // ---------- Transformation methods ----------------- | 334 // ---------- Transformation methods ----------------- |
| 328 enum IncludeDeviceScale { DefinitelyIncludeDeviceScale, PossiblyIncludeDevic
eScale }; | 335 enum IncludeDeviceScale { DefinitelyIncludeDeviceScale, PossiblyIncludeDevic
eScale }; |
| 329 AffineTransform getCTM(IncludeDeviceScale includeScale = PossiblyIncludeDevi
ceScale) const; | 336 AffineTransform getCTM(IncludeDeviceScale includeScale = PossiblyIncludeDevi
ceScale) const; |
| 330 void concatCTM(const AffineTransform& affine) { concat(affine); } | 337 void concatCTM(const AffineTransform&); |
| 331 void setCTM(const AffineTransform& affine) { setMatrix(affine); } | 338 void setCTM(const AffineTransform&); |
| 332 void setMatrix(const SkMatrix&); | |
| 333 | 339 |
| 334 void scale(const FloatSize&); | 340 void scale(const FloatSize&); |
| 335 void rotate(float angleInRadians); | 341 void rotate(float angleInRadians); |
| 336 void translate(const FloatSize& size) { translate(size.width(), size.height(
)); } | 342 void translate(const FloatSize& size) { translate(size.width(), size.height(
)); } |
| 337 void translate(float x, float y); | 343 void translate(float x, float y); |
| 338 | 344 |
| 339 // This function applies the device scale factor to the context, making the
context capable of | 345 // This function applies the device scale factor to the context, making the
context capable of |
| 340 // acting as a base-level context for a HiDPI environment. | 346 // acting as a base-level context for a HiDPI environment. |
| 341 void applyDeviceScaleFactor(float deviceScaleFactor) { scale(FloatSize(devic
eScaleFactor, deviceScaleFactor)); } | 347 void applyDeviceScaleFactor(float deviceScaleFactor) { scale(FloatSize(devic
eScaleFactor, deviceScaleFactor)); } |
| 342 // ---------- End transformation methods ----------------- | 348 // ---------- End transformation methods ----------------- |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 // Helpers for drawing a focus ring (drawFocusRing) | 405 // Helpers for drawing a focus ring (drawFocusRing) |
| 400 void drawOuterPath(const SkPath&, SkPaint&, int); | 406 void drawOuterPath(const SkPath&, SkPaint&, int); |
| 401 void drawInnerPath(const SkPath&, SkPaint&, int); | 407 void drawInnerPath(const SkPath&, SkPaint&, int); |
| 402 | 408 |
| 403 // SkCanvas wrappers. | 409 // SkCanvas wrappers. |
| 404 bool isDrawingToLayer() const { return m_canvas->isDrawingToLayer(); } | 410 bool isDrawingToLayer() const { return m_canvas->isDrawingToLayer(); } |
| 405 | 411 |
| 406 bool clipPath(const SkPath&, AntiAliasingMode = NotAntiAliased, SkRegion::Op
= SkRegion::kIntersect_Op); | 412 bool clipPath(const SkPath&, AntiAliasingMode = NotAntiAliased, SkRegion::Op
= SkRegion::kIntersect_Op); |
| 407 bool clipRRect(const SkRRect&, AntiAliasingMode = NotAntiAliased, SkRegion::
Op = SkRegion::kIntersect_Op); | 413 bool clipRRect(const SkRRect&, AntiAliasingMode = NotAntiAliased, SkRegion::
Op = SkRegion::kIntersect_Op); |
| 408 | 414 |
| 409 bool concat(const SkMatrix&); | |
| 410 | |
| 411 // Used when restoring and the state has an image clip. Only shows the pixel
s in | 415 // Used when restoring and the state has an image clip. Only shows the pixel
s in |
| 412 // m_canvas that are also in imageBuffer. | 416 // m_canvas that are also in imageBuffer. |
| 413 // The clipping rectangle is given in absolute coordinates. | 417 // The clipping rectangle is given in absolute coordinates. |
| 414 void applyClipFromImage(const SkRect&, const SkBitmap&); | 418 void applyClipFromImage(const SkRect&, const SkBitmap&); |
| 415 | 419 |
| 416 // common code between setupPaintFor[Filling,Stroking] | 420 // common code between setupPaintFor[Filling,Stroking] |
| 417 void setupShader(SkPaint*, Gradient*, Pattern*, SkColor) const; | 421 void setupShader(SkPaint*, Gradient*, Pattern*, SkColor) const; |
| 418 | 422 |
| 419 // Apply deferred saves | 423 // Apply deferred saves |
| 420 void realizeSave(SkCanvas::SaveFlags flags) | 424 void realizeSave(SkCanvas::SaveFlags flags) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 // FIXME: Make this go away: crbug.com/236892 | 469 // FIXME: Make this go away: crbug.com/236892 |
| 466 bool m_updatingControlTints : 1; | 470 bool m_updatingControlTints : 1; |
| 467 bool m_accelerated : 1; | 471 bool m_accelerated : 1; |
| 468 bool m_isCertainlyOpaque : 1; | 472 bool m_isCertainlyOpaque : 1; |
| 469 bool m_printing : 1; | 473 bool m_printing : 1; |
| 470 }; | 474 }; |
| 471 | 475 |
| 472 } // namespace WebCore | 476 } // namespace WebCore |
| 473 | 477 |
| 474 #endif // GraphicsContext_h | 478 #endif // GraphicsContext_h |
| OLD | NEW |