Chromium Code Reviews| 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() |
|
f(malita)
2014/05/27 18:16:44
Let's update this instead: create(const GraphicsCo
| |
| 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) |
|
f(malita)
2014/05/27 18:16:44
realizePaintSave() is the only user of create(), n
Dominik Grewe
2014/05/27 19:59:22
The GraphicsContext constructor also calls create,
| |
| 56 { | |
| 57 return adoptPtr(new GraphicsContextState(*other)); | |
| 58 } | |
| 59 | |
| 60 void copy(const GraphicsContextState*); | |
|
f(malita)
2014/05/27 18:16:44
Let's also update this to a const reference argume
Dominik Grewe
2014/05/27 19:59:22
Will do.
| |
| 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&); | |
| 145 | 150 |
| 146 // Helper function for applying the state's alpha value to the given input | 151 // Helper function for applying the state's alpha value to the given input |
| 147 // color to produce a new output color. | 152 // color to produce a new output color. |
| 148 SkColor applyAlpha(SkColor c) const | 153 SkColor applyAlpha(SkColor c) const |
| 149 { | 154 { |
| 150 int a = SkAlphaMul(SkColorGetA(c), m_alpha); | 155 int a = SkAlphaMul(SkColorGetA(c), m_alpha); |
| 151 return (c & 0x00FFFFFF) | (a << 24); | 156 return (c & 0x00FFFFFF) | (a << 24); |
| 152 } | 157 } |
| 153 | 158 |
| 154 // These are mutbale to enable gradient updates when the paints are fetched for use. | 159 // 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; | 183 uint16_t m_saveCount; |
| 179 | 184 |
| 180 bool m_shouldAntialias : 1; | 185 bool m_shouldAntialias : 1; |
| 181 bool m_shouldSmoothFonts : 1; | 186 bool m_shouldSmoothFonts : 1; |
| 182 bool m_shouldClampToSourceRect : 1; | 187 bool m_shouldClampToSourceRect : 1; |
| 183 }; | 188 }; |
| 184 | 189 |
| 185 } // namespace WebCore | 190 } // namespace WebCore |
| 186 | 191 |
| 187 #endif // GraphicsContextState_h | 192 #endif // GraphicsContextState_h |
| OLD | NEW |