| OLD | NEW |
| 1 // Copyright (C) 2013 Google Inc. All rights reserved. | 1 // Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 // | 2 // |
| 3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
| 4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
| 5 // met: | 5 // met: |
| 6 // | 6 // |
| 7 // * Redistributions of source code must retain the above copyright | 7 // * 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 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
| 10 // copyright notice, this list of conditions and the following disclaimer | 10 // copyright notice, this list of conditions and the following disclaimer |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 #ifndef GraphicsContextState_h | 29 #ifndef GraphicsContextState_h |
| 30 #define GraphicsContextState_h | 30 #define GraphicsContextState_h |
| 31 | 31 |
| 32 #include "core/platform/graphics/Gradient.h" | 32 #include "core/platform/graphics/Gradient.h" |
| 33 #include "core/platform/graphics/GraphicsTypes.h" | 33 #include "core/platform/graphics/GraphicsTypes.h" |
| 34 #include "core/platform/graphics/Path.h" | 34 #include "core/platform/graphics/Path.h" |
| 35 #include "core/platform/graphics/Pattern.h" | 35 #include "core/platform/graphics/Pattern.h" |
| 36 #include "core/platform/graphics/StrokeData.h" | 36 #include "core/platform/graphics/StrokeData.h" |
| 37 #include "third_party/skia/include/core/SkColorFilter.h" |
| 37 #include "third_party/skia/include/core/SkColorPriv.h" | 38 #include "third_party/skia/include/core/SkColorPriv.h" |
| 38 #include "third_party/skia/include/core/SkDrawLooper.h" | 39 #include "third_party/skia/include/core/SkDrawLooper.h" |
| 39 #include "third_party/skia/include/effects/SkDashPathEffect.h" | 40 #include "third_party/skia/include/effects/SkDashPathEffect.h" |
| 40 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
| 41 #include "wtf/RefPtr.h" | 42 #include "wtf/RefPtr.h" |
| 42 | 43 |
| 43 namespace WebCore { | 44 namespace WebCore { |
| 44 | 45 |
| 45 // Encapsulates the state information we store for each pushed graphics state. | 46 // Encapsulates the state information we store for each pushed graphics state. |
| 46 // Only GraphicsContext can use this class. | 47 // Only GraphicsContext can use this class. |
| 47 class GraphicsContextState { | 48 class GraphicsContextState { |
| 48 private: | 49 private: |
| 49 friend class GraphicsContext; | 50 friend class GraphicsContext; |
| 50 | 51 |
| 51 GraphicsContextState() | 52 GraphicsContextState() |
| 52 : m_fillColor(Color::black) | 53 : m_fillColor(Color::black) |
| 53 , m_fillRule(RULE_NONZERO) | 54 , m_fillRule(RULE_NONZERO) |
| 54 , m_textDrawingMode(TextModeFill) | 55 , m_textDrawingMode(TextModeFill) |
| 55 , m_alpha(1) | 56 , m_alpha(1) |
| 56 , m_xferMode(SkXfermode::kSrcOver_Mode) | 57 , m_xferMode(SkXfermode::kSrcOver_Mode) |
| 57 , m_compositeOperator(CompositeSourceOver) | 58 , m_compositeOperator(CompositeSourceOver) |
| 58 , m_blendMode(BlendModeNormal) | 59 , m_blendMode(BlendModeNormal) |
| 59 , m_clip(SkRect::MakeEmpty()) | |
| 60 #if USE(LOW_QUALITY_IMAGE_INTERPOLATION) | 60 #if USE(LOW_QUALITY_IMAGE_INTERPOLATION) |
| 61 , m_interpolationQuality(InterpolationLow) | 61 , m_interpolationQuality(InterpolationLow) |
| 62 #else | 62 #else |
| 63 , m_interpolationQuality(InterpolationHigh) | 63 , m_interpolationQuality(InterpolationHigh) |
| 64 #endif | 64 #endif |
| 65 , m_shouldAntialias(true) | 65 , m_shouldAntialias(true) |
| 66 , m_shouldSmoothFonts(true) | 66 , m_shouldSmoothFonts(true) |
| 67 { | 67 { |
| 68 } | 68 } |
| 69 | 69 |
| 70 GraphicsContextState(const GraphicsContextState& other) | 70 GraphicsContextState(const GraphicsContextState& other) |
| 71 : m_strokeData(other.m_strokeData) | 71 : m_strokeData(other.m_strokeData) |
| 72 , m_fillColor(other.m_fillColor) | 72 , m_fillColor(other.m_fillColor) |
| 73 , m_fillRule(other.m_fillRule) | 73 , m_fillRule(other.m_fillRule) |
| 74 , m_fillGradient(other.m_fillGradient) | 74 , m_fillGradient(other.m_fillGradient) |
| 75 , m_fillPattern(other.m_fillPattern) | 75 , m_fillPattern(other.m_fillPattern) |
| 76 , m_looper(other.m_looper) | 76 , m_looper(other.m_looper) |
| 77 , m_textDrawingMode(other.m_textDrawingMode) | 77 , m_textDrawingMode(other.m_textDrawingMode) |
| 78 , m_alpha(other.m_alpha) | 78 , m_alpha(other.m_alpha) |
| 79 , m_xferMode(other.m_xferMode) | 79 , m_xferMode(other.m_xferMode) |
| 80 , m_colorFilter(other.m_colorFilter) |
| 80 , m_compositeOperator(other.m_compositeOperator) | 81 , m_compositeOperator(other.m_compositeOperator) |
| 81 , m_blendMode(other.m_blendMode) | 82 , m_blendMode(other.m_blendMode) |
| 82 , m_clip(other.m_clip) | |
| 83 , m_interpolationQuality(other.m_interpolationQuality) | 83 , m_interpolationQuality(other.m_interpolationQuality) |
| 84 , m_shouldAntialias(other.m_shouldAntialias) | 84 , m_shouldAntialias(other.m_shouldAntialias) |
| 85 , m_shouldSmoothFonts(other.m_shouldSmoothFonts) | 85 , m_shouldSmoothFonts(other.m_shouldSmoothFonts) |
| 86 { | 86 { |
| 87 } | 87 } |
| 88 | 88 |
| 89 // Helper function for applying the state's alpha value to the given input | 89 // Helper function for applying the state's alpha value to the given input |
| 90 // color to produce a new output color. | 90 // color to produce a new output color. |
| 91 SkColor applyAlpha(SkColor c) const | 91 SkColor applyAlpha(SkColor c) const |
| 92 { | 92 { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 117 | 117 |
| 118 // Shadow. (This will need tweaking if we use draw loopers for other things.
) | 118 // Shadow. (This will need tweaking if we use draw loopers for other things.
) |
| 119 RefPtr<SkDrawLooper> m_looper; | 119 RefPtr<SkDrawLooper> m_looper; |
| 120 | 120 |
| 121 // Text. (See TextModeFill & friends.) | 121 // Text. (See TextModeFill & friends.) |
| 122 TextDrawingModeFlags m_textDrawingMode; | 122 TextDrawingModeFlags m_textDrawingMode; |
| 123 | 123 |
| 124 // Common shader state. | 124 // Common shader state. |
| 125 float m_alpha; | 125 float m_alpha; |
| 126 SkXfermode::Mode m_xferMode; | 126 SkXfermode::Mode m_xferMode; |
| 127 RefPtr<SkColorFilter> m_colorFilter; |
| 127 | 128 |
| 128 // Compositing control, for the CSS and Canvas compositing spec. | 129 // Compositing control, for the CSS and Canvas compositing spec. |
| 129 CompositeOperator m_compositeOperator; | 130 CompositeOperator m_compositeOperator; |
| 130 BlendMode m_blendMode; | 131 BlendMode m_blendMode; |
| 131 | 132 |
| 132 // If non-empty, the current State is clipped to this image. | |
| 133 SkBitmap m_imageBufferClip; | |
| 134 | |
| 135 // If m_imageBufferClip is non-empty, this is the region the image is clippe
d to. | |
| 136 SkRect m_clip; | |
| 137 | |
| 138 // Image interpolation control. | 133 // Image interpolation control. |
| 139 InterpolationQuality m_interpolationQuality; | 134 InterpolationQuality m_interpolationQuality; |
| 140 | 135 |
| 141 bool m_shouldAntialias : 1; | 136 bool m_shouldAntialias : 1; |
| 142 bool m_shouldSmoothFonts : 1; | 137 bool m_shouldSmoothFonts : 1; |
| 143 }; | 138 }; |
| 144 | 139 |
| 145 } // namespace WebCore | 140 } // namespace WebCore |
| 146 | 141 |
| 147 #endif // GraphicsContextState_h | 142 #endif // GraphicsContextState_h |
| 148 | 143 |
| OLD | NEW |