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