| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 142     void setShouldAntialias(bool antialias) { mutableState()->setShouldAntialias
     (antialias); } | 142     void setShouldAntialias(bool antialias) { mutableState()->setShouldAntialias
     (antialias); } | 
| 143     bool shouldAntialias() const { return immutableState()->shouldAntialias(); } | 143     bool shouldAntialias() const { return immutableState()->shouldAntialias(); } | 
| 144 | 144 | 
| 145     // Disable the anti-aliasing optimization for scales/multiple-of-90-degrees | 145     // Disable the anti-aliasing optimization for scales/multiple-of-90-degrees | 
| 146     // rotations of thin ("hairline") images. | 146     // rotations of thin ("hairline") images. | 
| 147     // Note: This will only be reliable when the device pixel scale/ratio is | 147     // Note: This will only be reliable when the device pixel scale/ratio is | 
| 148     // fixed (e.g. when drawing to context backed by an ImageBuffer). | 148     // fixed (e.g. when drawing to context backed by an ImageBuffer). | 
| 149     void disableAntialiasingOptimizationForHairlineImages() { ASSERT(!isRecordin
     g()); m_antialiasHairlineImages = true; } | 149     void disableAntialiasingOptimizationForHairlineImages() { ASSERT(!isRecordin
     g()); m_antialiasHairlineImages = true; } | 
| 150     bool shouldAntialiasHairlineImages() const { return m_antialiasHairlineImage
     s; } | 150     bool shouldAntialiasHairlineImages() const { return m_antialiasHairlineImage
     s; } | 
| 151 | 151 | 
| 152     void setShouldClampToSourceRect(bool clampToSourceRect) { mutableState()->se
     tShouldClampToSourceRect(clampToSourceRect); } |  | 
| 153     bool shouldClampToSourceRect() const { return immutableState()->shouldClampT
     oSourceRect(); } |  | 
| 154 |  | 
| 155     void setTextDrawingMode(TextDrawingModeFlags mode) { mutableState()->setText
     DrawingMode(mode); } | 152     void setTextDrawingMode(TextDrawingModeFlags mode) { mutableState()->setText
     DrawingMode(mode); } | 
| 156     TextDrawingModeFlags textDrawingMode() const { return immutableState()->text
     DrawingMode(); } | 153     TextDrawingModeFlags textDrawingMode() const { return immutableState()->text
     DrawingMode(); } | 
| 157 | 154 | 
| 158     void setAlphaAsFloat(float alpha) { mutableState()->setAlphaAsFloat(alpha);} |  | 
| 159     int getNormalizedAlpha() const |  | 
| 160     { |  | 
| 161         int alpha = immutableState()->alpha(); |  | 
| 162         return alpha > 255 ? 255 : alpha; |  | 
| 163     } |  | 
| 164 |  | 
| 165     void setImageInterpolationQuality(InterpolationQuality quality) { mutableSta
     te()->setInterpolationQuality(quality); } | 155     void setImageInterpolationQuality(InterpolationQuality quality) { mutableSta
     te()->setInterpolationQuality(quality); } | 
| 166     InterpolationQuality imageInterpolationQuality() const { return immutableSta
     te()->interpolationQuality(); } | 156     InterpolationQuality imageInterpolationQuality() const { return immutableSta
     te()->interpolationQuality(); } | 
| 167 | 157 | 
| 168     // Do not use these methods: they are deprecated/scheduled for removal. | 158     // Do not use these methods: they are deprecated/scheduled for removal. | 
| 169     void setCompositeOperation(SkXfermode::Mode); | 159     void setCompositeOperation(SkXfermode::Mode); | 
| 170     SkXfermode::Mode compositeOperation() const; | 160     SkXfermode::Mode compositeOperation() const; | 
| 171 | 161 | 
| 172     // Specify the device scale factor which may change the way document markers | 162     // Specify the device scale factor which may change the way document markers | 
| 173     // and fonts are rendered. | 163     // and fonts are rendered. | 
| 174     void setDeviceScaleFactor(float factor) { m_deviceScaleFactor = factor; } | 164     void setDeviceScaleFactor(float factor) { m_deviceScaleFactor = factor; } | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 226         SkXfermode::Mode = SkXfermode::kSrcOver_Mode, const IntSize& repeatSpaci
     ng = IntSize()); | 216         SkXfermode::Mode = SkXfermode::kSrcOver_Mode, const IntSize& repeatSpaci
     ng = IntSize()); | 
| 227     void drawTiledImage(Image*, const IntRect& destRect, const IntRect& srcRect, | 217     void drawTiledImage(Image*, const IntRect& destRect, const IntRect& srcRect, | 
| 228         const FloatSize& tileScaleFactor, Image::TileRule hRule = Image::Stretch
     Tile, Image::TileRule vRule = Image::StretchTile, | 218         const FloatSize& tileScaleFactor, Image::TileRule hRule = Image::Stretch
     Tile, Image::TileRule vRule = Image::StretchTile, | 
| 229         SkXfermode::Mode = SkXfermode::kSrcOver_Mode); | 219         SkXfermode::Mode = SkXfermode::kSrcOver_Mode); | 
| 230 | 220 | 
| 231     void drawImageBuffer(ImageBuffer*, const FloatRect& destRect, const FloatRec
     t* srcRect = 0, SkXfermode::Mode = SkXfermode::kSrcOver_Mode); | 221     void drawImageBuffer(ImageBuffer*, const FloatRect& destRect, const FloatRec
     t* srcRect = 0, SkXfermode::Mode = SkXfermode::kSrcOver_Mode); | 
| 232 | 222 | 
| 233     // These methods write to the canvas. | 223     // These methods write to the canvas. | 
| 234     // Also drawLine(const IntPoint& point1, const IntPoint& point2) and fillRou
     ndedRect | 224     // Also drawLine(const IntPoint& point1, const IntPoint& point2) and fillRou
     ndedRect | 
| 235     void writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, in
     t x, int y); | 225     void writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, in
     t x, int y); | 
| 236     void drawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkP
     aint* = 0); |  | 
| 237     void drawOval(const SkRect&, const SkPaint&); | 226     void drawOval(const SkRect&, const SkPaint&); | 
| 238     void drawPath(const SkPath&, const SkPaint&); | 227     void drawPath(const SkPath&, const SkPaint&); | 
| 239     void drawRect(const SkRect&, const SkPaint&); | 228     void drawRect(const SkRect&, const SkPaint&); | 
| 240 | 229 | 
| 241     void clip(const IntRect& rect) { clipRect(rect); } | 230     void clip(const IntRect& rect) { clipRect(rect); } | 
| 242     void clip(const FloatRect& rect) { clipRect(rect); } | 231     void clip(const FloatRect& rect) { clipRect(rect); } | 
| 243     void clipRoundedRect(const FloatRoundedRect&, SkRegion::Op = SkRegion::kInte
     rsect_Op); | 232     void clipRoundedRect(const FloatRoundedRect&, SkRegion::Op = SkRegion::kInte
     rsect_Op); | 
| 244     void clipOut(const IntRect& rect) { clipRect(rect, NotAntiAliased, SkRegion:
     :kDifference_Op); } | 233     void clipOut(const IntRect& rect) { clipRect(rect, NotAntiAliased, SkRegion:
     :kDifference_Op); } | 
| 245     void clipOut(const FloatRect& rect) { clipRect(rect, NotAntiAliased, SkRegio
     n::kDifference_Op); } | 234     void clipOut(const FloatRect& rect) { clipRect(rect, NotAntiAliased, SkRegio
     n::kDifference_Op); } | 
| 246     void clipOut(const Path&); | 235     void clipOut(const Path&); | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
| 271 | 260 | 
| 272     // Instead of being dispatched to the active canvas, draw commands following
      beginRecording() | 261     // Instead of being dispatched to the active canvas, draw commands following
      beginRecording() | 
| 273     // are stored in a display list that can be replayed at a later time. Pass i
     n the bounding | 262     // are stored in a display list that can be replayed at a later time. Pass i
     n the bounding | 
| 274     // rectangle for the content in the list. | 263     // rectangle for the content in the list. | 
| 275     void beginRecording(const FloatRect&, uint32_t = 0); | 264     void beginRecording(const FloatRect&, uint32_t = 0); | 
| 276     PassRefPtr<const SkPicture> endRecording(); | 265     PassRefPtr<const SkPicture> endRecording(); | 
| 277 | 266 | 
| 278     void setShadow(const FloatSize& offset, float blur, const Color&, | 267     void setShadow(const FloatSize& offset, float blur, const Color&, | 
| 279         DrawLooperBuilder::ShadowTransformMode = DrawLooperBuilder::ShadowRespec
     tsTransforms, | 268         DrawLooperBuilder::ShadowTransformMode = DrawLooperBuilder::ShadowRespec
     tsTransforms, | 
| 280         DrawLooperBuilder::ShadowAlphaMode = DrawLooperBuilder::ShadowRespectsAl
     pha, ShadowMode = DrawShadowAndForeground); | 269         DrawLooperBuilder::ShadowAlphaMode = DrawLooperBuilder::ShadowRespectsAl
     pha, ShadowMode = DrawShadowAndForeground); | 
| 281     void clearShadow() { clearDrawLooper(); clearDropShadowImageFilter(); } |  | 
| 282     void setDropShadowImageFilter(PassRefPtr<SkImageFilter>); |  | 
| 283 | 270 | 
| 284     // It is assumed that this draw looper is used only for shadows | 271     // It is assumed that this draw looper is used only for shadows | 
| 285     // (i.e. a draw looper is set if and only if there is a shadow). | 272     // (i.e. a draw looper is set if and only if there is a shadow). | 
| 286     // The builder passed into this method will be destroyed. | 273     // The builder passed into this method will be destroyed. | 
| 287     void setDrawLooper(PassOwnPtr<DrawLooperBuilder>); | 274     void setDrawLooper(PassOwnPtr<DrawLooperBuilder>); | 
| 288     void setDrawLooper(PassRefPtr<SkDrawLooper> looper) { mutableState()->setDra
     wLooper(looper); } |  | 
| 289     void clearDrawLooper(); | 275     void clearDrawLooper(); | 
| 290 | 276 | 
| 291     void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Colo
     r&); | 277     void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Colo
     r&); | 
| 292     void drawFocusRing(const Path&, int width, int offset, const Color&); | 278     void drawFocusRing(const Path&, int width, int offset, const Color&); | 
| 293 | 279 | 
| 294     enum Edge { | 280     enum Edge { | 
| 295         NoEdge = 0, | 281         NoEdge = 0, | 
| 296         TopEdge = 1 << 1, | 282         TopEdge = 1 << 1, | 
| 297         RightEdge = 1 << 2, | 283         RightEdge = 1 << 2, | 
| 298         BottomEdge = 1 << 3, | 284         BottomEdge = 1 << 3, | 
| 299         LeftEdge = 1 << 4 | 285         LeftEdge = 1 << 4 | 
| 300     }; | 286     }; | 
| 301     typedef unsigned Edges; | 287     typedef unsigned Edges; | 
| 302     void drawInnerShadow(const FloatRoundedRect&, const Color& shadowColor, cons
     t IntSize shadowOffset, int shadowBlur, int shadowSpread, Edges clippedEdges = N
     oEdge); | 288     void drawInnerShadow(const FloatRoundedRect&, const Color& shadowColor, cons
     t IntSize shadowOffset, int shadowBlur, int shadowSpread, Edges clippedEdges = N
     oEdge); | 
| 303 | 289 | 
|  | 290     const SkPaint& fillPaint() const { return immutableState()->fillPaint(); } | 
|  | 291 | 
| 304     // ---------- Transformation methods ----------------- | 292     // ---------- Transformation methods ----------------- | 
| 305     // Note that the getCTM method returns only the current transform from Blink
     's perspective, | 293     // Note that the getCTM method returns only the current transform from Blink
     's perspective, | 
| 306     // which is not the final transform used to place content on screen. It cann
     ot be relied upon | 294     // which is not the final transform used to place content on screen. It cann
     ot be relied upon | 
| 307     // for testing where a point will appear on screen or how large it will be. | 295     // for testing where a point will appear on screen or how large it will be. | 
| 308     AffineTransform getCTM() const; | 296     AffineTransform getCTM() const; | 
| 309     void concatCTM(const AffineTransform&); | 297     void concatCTM(const AffineTransform&); | 
| 310     void setCTM(const AffineTransform&); | 298     void setCTM(const AffineTransform&); | 
| 311     void setMatrix(const SkMatrix&); | 299     void setMatrix(const SkMatrix&); | 
| 312 | 300 | 
| 313     void scale(float x, float y); | 301     void scale(float x, float y); | 
| 314     void rotate(float angleInRadians); | 302     void rotate(float angleInRadians); | 
| 315     void translate(float x, float y); | 303     void translate(float x, float y); | 
| 316     // ---------- End transformation methods ----------------- | 304     // ---------- End transformation methods ----------------- | 
| 317 | 305 | 
|  | 306     void preparePaintForImage(SkPaint*) const; | 
|  | 307     SkFilterQuality getFilterQuality(Image*, const FloatRect& dest, const FloatR
     ect& src) const; | 
|  | 308 | 
| 318     // URL drawing | 309     // URL drawing | 
| 319     void setURLForRect(const KURL&, const IntRect&); | 310     void setURLForRect(const KURL&, const IntRect&); | 
| 320     void setURLFragmentForRect(const String& name, const IntRect&); | 311     void setURLFragmentForRect(const String& name, const IntRect&); | 
| 321     void addURLTargetAtPoint(const String& name, const IntPoint&); | 312     void addURLTargetAtPoint(const String& name, const IntPoint&); | 
| 322 | 313 | 
| 323     static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, floa
     t strokeWidth, StrokeStyle); | 314     static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, floa
     t strokeWidth, StrokeStyle); | 
| 324 | 315 | 
| 325     void beginAnnotation(const AnnotationList&); | 316     void beginAnnotation(const AnnotationList&); | 
| 326     void endAnnotation(); | 317     void endAnnotation(); | 
| 327 | 318 | 
| 328     // This method can potentially push saves onto the canvas. It returns the in
     itial save count, |  | 
| 329     // and should be balanced with a call to context->canvas()->restoreToCount(i
     nitialSaveCount). |  | 
| 330     WARN_UNUSED_RETURN int preparePaintForDrawRectToRect( |  | 
| 331         SkPaint*, |  | 
| 332         const SkRect& srcRect, |  | 
| 333         const SkRect& destRect, |  | 
| 334         SkXfermode::Mode, |  | 
| 335         bool isBitmapWithAlpha, |  | 
| 336         bool isLazyDecoded = false, |  | 
| 337         bool isDataComplete = true) const; |  | 
| 338 |  | 
| 339     static int focusRingOutsetExtent(int offset, int width) | 319     static int focusRingOutsetExtent(int offset, int width) | 
| 340     { | 320     { | 
| 341         return focusRingOutset(offset) + (focusRingWidth(width) + 1) / 2; | 321         return focusRingOutset(offset) + (focusRingWidth(width) + 1) / 2; | 
| 342     } | 322     } | 
| 343 | 323 | 
| 344     // public decl needed for OwnPtr wrapper. | 324     // public decl needed for OwnPtr wrapper. | 
| 345     class RecordingState; | 325     class RecordingState; | 
| 346 | 326 | 
| 347 #if ENABLE(ASSERT) | 327 #if ENABLE(ASSERT) | 
| 348     void setInDrawingRecorder(bool); | 328     void setInDrawingRecorder(bool); | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 385     // Helpers for drawing a focus ring (drawFocusRing) | 365     // Helpers for drawing a focus ring (drawFocusRing) | 
| 386     float prepareFocusRingPaint(SkPaint&, const Color&, int width) const; | 366     float prepareFocusRingPaint(SkPaint&, const Color&, int width) const; | 
| 387     void drawFocusRingPath(const SkPath&, const Color&, int width); | 367     void drawFocusRingPath(const SkPath&, const Color&, int width); | 
| 388     void drawFocusRingRect(const SkRect&, const Color&, int width); | 368     void drawFocusRingRect(const SkRect&, const Color&, int width); | 
| 389 | 369 | 
| 390     // SkCanvas wrappers. | 370     // SkCanvas wrappers. | 
| 391     void clipRRect(const SkRRect&, AntiAliasingMode = NotAntiAliased, SkRegion::
     Op = SkRegion::kIntersect_Op); | 371     void clipRRect(const SkRRect&, AntiAliasingMode = NotAntiAliased, SkRegion::
     Op = SkRegion::kIntersect_Op); | 
| 392     void concat(const SkMatrix&); | 372     void concat(const SkMatrix&); | 
| 393     void drawRRect(const SkRRect&, const SkPaint&); | 373     void drawRRect(const SkRRect&, const SkPaint&); | 
| 394 | 374 | 
| 395     void clearDropShadowImageFilter(); |  | 
| 396     SkImageFilter* dropShadowImageFilter() const { return immutableState()->drop
     ShadowImageFilter(); } |  | 
| 397 |  | 
| 398     // Apply deferred paint state saves | 375     // Apply deferred paint state saves | 
| 399     void realizePaintSave() | 376     void realizePaintSave() | 
| 400     { | 377     { | 
| 401         if (contextDisabled()) | 378         if (contextDisabled()) | 
| 402             return; | 379             return; | 
| 403 | 380 | 
| 404         if (m_paintState->saveCount()) { | 381         if (m_paintState->saveCount()) { | 
| 405             m_paintState->decrementSaveCount(); | 382             m_paintState->decrementSaveCount(); | 
| 406             ++m_paintStateIndex; | 383             ++m_paintStateIndex; | 
| 407             if (m_paintStateStack.size() == m_paintStateIndex) { | 384             if (m_paintStateStack.size() == m_paintStateIndex) { | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 452     float m_deviceScaleFactor; | 429     float m_deviceScaleFactor; | 
| 453 | 430 | 
| 454     unsigned m_accelerated : 1; | 431     unsigned m_accelerated : 1; | 
| 455     unsigned m_printing : 1; | 432     unsigned m_printing : 1; | 
| 456     unsigned m_antialiasHairlineImages : 1; | 433     unsigned m_antialiasHairlineImages : 1; | 
| 457 }; | 434 }; | 
| 458 | 435 | 
| 459 } // namespace blink | 436 } // namespace blink | 
| 460 | 437 | 
| 461 #endif // GraphicsContext_h | 438 #endif // GraphicsContext_h | 
| OLD | NEW | 
|---|