| 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 28 matching lines...) Expand all Loading... |
| 39 #include "third_party/skia/include/core/SkColorFilter.h" | 39 #include "third_party/skia/include/core/SkColorFilter.h" |
| 40 #include "third_party/skia/include/core/SkPaint.h" | 40 #include "third_party/skia/include/core/SkPaint.h" |
| 41 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
| 42 #include "wtf/RefPtr.h" | 42 #include "wtf/RefPtr.h" |
| 43 | 43 |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 // Encapsulates the state information we store for each pushed graphics state. | 46 // Encapsulates the state information we store for each pushed graphics state. |
| 47 // Only GraphicsContext can use this class. | 47 // Only GraphicsContext can use this class. |
| 48 class PLATFORM_EXPORT GraphicsContextState FINAL { | 48 class PLATFORM_EXPORT GraphicsContextState FINAL { |
| 49 WTF_MAKE_NONCOPYABLE(GraphicsContextState); |
| 49 public: | 50 public: |
| 50 static PassOwnPtr<GraphicsContextState> create() | 51 static PassOwnPtr<GraphicsContextState> create() |
| 51 { | 52 { |
| 52 return adoptPtr(new GraphicsContextState()); | 53 return adoptPtr(new GraphicsContextState()); |
| 53 } | 54 } |
| 54 | 55 |
| 55 static PassOwnPtr<GraphicsContextState> createAndCopy(const GraphicsContextS
tate& other) | 56 void copy(GraphicsContextState*); |
| 56 { | |
| 57 return adoptPtr(new GraphicsContextState(other)); | |
| 58 } | |
| 59 | |
| 60 void copy(const GraphicsContextState&); | |
| 61 | 57 |
| 62 // SkPaint objects that reflect the current state. If the length of the | 58 // SkPaint objects that reflect the current state. If the length of the |
| 63 // path to be stroked is known, pass it in for correct dash or dot placement
. | 59 // path to be stroked is known, pass it in for correct dash or dot placement
. |
| 64 const SkPaint& strokePaint(int strokedPathLength = 0) const; | 60 const SkPaint& strokePaint(int strokedPathLength = 0) const; |
| 65 const SkPaint& fillPaint() const; | 61 const SkPaint& fillPaint() const; |
| 66 | 62 |
| 67 uint16_t saveCount() const { return m_saveCount; } | 63 uint16_t saveCount() const { return m_saveCount; } |
| 68 void incrementSaveCount() { ++m_saveCount; } | 64 void incrementSaveCount() { ++m_saveCount; } |
| 69 void decrementSaveCount() { --m_saveCount; } | 65 void decrementSaveCount() { --m_saveCount; } |
| 70 | 66 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 void setShouldAntialias(bool); | 135 void setShouldAntialias(bool); |
| 140 | 136 |
| 141 bool shouldSmoothFonts() const { return m_shouldSmoothFonts; } | 137 bool shouldSmoothFonts() const { return m_shouldSmoothFonts; } |
| 142 void setShouldSmoothFonts(bool shouldSmoothFonts) { m_shouldSmoothFonts = sh
ouldSmoothFonts; } | 138 void setShouldSmoothFonts(bool shouldSmoothFonts) { m_shouldSmoothFonts = sh
ouldSmoothFonts; } |
| 143 | 139 |
| 144 bool shouldClampToSourceRect() const { return m_shouldClampToSourceRect; } | 140 bool shouldClampToSourceRect() const { return m_shouldClampToSourceRect; } |
| 145 void setShouldClampToSourceRect(bool shouldClampToSourceRect) { m_shouldClam
pToSourceRect = shouldClampToSourceRect; } | 141 void setShouldClampToSourceRect(bool shouldClampToSourceRect) { m_shouldClam
pToSourceRect = shouldClampToSourceRect; } |
| 146 | 142 |
| 147 private: | 143 private: |
| 148 GraphicsContextState(); | 144 GraphicsContextState(); |
| 149 explicit GraphicsContextState(const GraphicsContextState&); | |
| 150 GraphicsContextState& operator=(const GraphicsContextState&); | |
| 151 | 145 |
| 152 // Helper function for applying the state's alpha value to the given input | 146 // Helper function for applying the state's alpha value to the given input |
| 153 // color to produce a new output color. | 147 // color to produce a new output color. |
| 154 SkColor applyAlpha(SkColor c) const | 148 SkColor applyAlpha(SkColor c) const |
| 155 { | 149 { |
| 156 int a = SkAlphaMul(SkColorGetA(c), m_alpha); | 150 int a = SkAlphaMul(SkColorGetA(c), m_alpha); |
| 157 return (c & 0x00FFFFFF) | (a << 24); | 151 return (c & 0x00FFFFFF) | (a << 24); |
| 158 } | 152 } |
| 159 | 153 |
| 160 // These are mutbale to enable gradient updates when the paints are fetched
for use. | 154 // These are mutbale to enable gradient updates when the paints are fetched
for use. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 184 uint16_t m_saveCount; | 178 uint16_t m_saveCount; |
| 185 | 179 |
| 186 bool m_shouldAntialias : 1; | 180 bool m_shouldAntialias : 1; |
| 187 bool m_shouldSmoothFonts : 1; | 181 bool m_shouldSmoothFonts : 1; |
| 188 bool m_shouldClampToSourceRect : 1; | 182 bool m_shouldClampToSourceRect : 1; |
| 189 }; | 183 }; |
| 190 | 184 |
| 191 } // namespace WebCore | 185 } // namespace WebCore |
| 192 | 186 |
| 193 #endif // GraphicsContextState_h | 187 #endif // GraphicsContextState_h |
| OLD | NEW |