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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); } | 152 void setShouldClampToSourceRect(bool clampToSourceRect) { mutableState()->se
tShouldClampToSourceRect(clampToSourceRect); } |
153 bool shouldClampToSourceRect() const { return immutableState()->shouldClampT
oSourceRect(); } | 153 bool shouldClampToSourceRect() const { return immutableState()->shouldClampT
oSourceRect(); } |
154 | 154 |
155 // FIXME: the setter is only used once, at construction time; convert to a c
onstructor param, | 155 // FIXME: the setter is only used once, at construction time; convert to a c
onstructor param, |
156 // and possibly consolidate with other flags (paintDisabled, isPrinting, ...
) | 156 // and possibly consolidate with other flags (paintDisabled, isPrinting, ...
) |
157 void setShouldSmoothFonts(bool smoothFonts) { m_shouldSmoothFonts = smoothFo
nts; } | 157 void setShouldSmoothFonts(bool smoothFonts) { m_shouldSmoothFonts = smoothFo
nts; } |
158 bool shouldSmoothFonts() const { return m_shouldSmoothFonts; } | |
159 | 158 |
160 // Turn off LCD text for the paint if not supported on this context. | 159 // Turn off LCD text for the paint if not supported on this context. |
161 void adjustTextRenderMode(SkPaint*) const; | 160 void adjustTextRenderMode(SkPaint*) const; |
162 bool couldUseLCDRenderedText() const; | 161 bool couldUseLCDRenderedText() const { return m_isCertainlyOpaque && m_shoul
dSmoothFonts; } |
163 | 162 |
164 void setTextDrawingMode(TextDrawingModeFlags mode) { mutableState()->setText
DrawingMode(mode); } | 163 void setTextDrawingMode(TextDrawingModeFlags mode) { mutableState()->setText
DrawingMode(mode); } |
165 TextDrawingModeFlags textDrawingMode() const { return immutableState()->text
DrawingMode(); } | 164 TextDrawingModeFlags textDrawingMode() const { return immutableState()->text
DrawingMode(); } |
166 | 165 |
167 void setAlphaAsFloat(float alpha) { mutableState()->setAlphaAsFloat(alpha);} | 166 void setAlphaAsFloat(float alpha) { mutableState()->setAlphaAsFloat(alpha);} |
168 int getNormalizedAlpha() const | 167 int getNormalizedAlpha() const |
169 { | 168 { |
170 int alpha = immutableState()->alpha(); | 169 int alpha = immutableState()->alpha(); |
171 return alpha > 255 ? 255 : alpha; | 170 return alpha > 255 ? 255 : alpha; |
172 } | 171 } |
173 | 172 |
174 void setImageInterpolationQuality(InterpolationQuality quality) { mutableSta
te()->setInterpolationQuality(quality); } | 173 void setImageInterpolationQuality(InterpolationQuality quality) { mutableSta
te()->setInterpolationQuality(quality); } |
175 InterpolationQuality imageInterpolationQuality() const { return immutableSta
te()->interpolationQuality(); } | 174 InterpolationQuality imageInterpolationQuality() const { return immutableSta
te()->interpolationQuality(); } |
176 | 175 |
177 void setCompositeOperation(CompositeOperator, WebBlendMode = WebBlendModeNor
mal); | 176 void setCompositeOperation(CompositeOperator, WebBlendMode = WebBlendModeNor
mal); |
178 CompositeOperator compositeOperation() const { return immutableState()->comp
ositeOperator(); } | 177 CompositeOperator compositeOperation() const { return immutableState()->comp
ositeOperator(); } |
179 WebBlendMode blendModeOperation() const { return immutableState()->blendMode
(); } | 178 WebBlendMode blendModeOperation() const { return immutableState()->blendMode
(); } |
180 | 179 |
181 // Speicy the device scale factor which may change the way document markers | 180 // Speicy the device scale factor which may change the way document markers |
182 // and fonts are rendered. | 181 // and fonts are rendered. |
183 void setDeviceScaleFactor(float factor) { m_deviceScaleFactor = factor; } | 182 void setDeviceScaleFactor(float factor) { m_deviceScaleFactor = factor; } |
184 float deviceScaleFactor() const { return m_deviceScaleFactor; } | 183 float deviceScaleFactor() const { return m_deviceScaleFactor; } |
185 | 184 |
186 // If true we are (most likely) rendering to a web page and the | 185 // If true we are (most likely) rendering to a web page and the |
187 // canvas has been prepared with an opaque background. If false, | 186 // canvas has been prepared with an opaque background. If false, |
188 // the canvas may have transparency (as is the case when rendering | 187 // the canvas may have transparency (as is the case when rendering |
189 // to a canvas object). | 188 // to a canvas object). |
190 void setCertainlyOpaque(bool isOpaque) { m_isCertainlyOpaque = isOpaque; } | 189 void setCertainlyOpaque(bool isOpaque) { m_isCertainlyOpaque = isOpaque; } |
191 bool isCertainlyOpaque() const { return m_isCertainlyOpaque; } | |
192 | 190 |
193 // Returns if the context is a printing context instead of a display | 191 // Returns if the context is a printing context instead of a display |
194 // context. Bitmap shouldn't be resampled when printing to keep the best | 192 // context. Bitmap shouldn't be resampled when printing to keep the best |
195 // possible quality. | 193 // possible quality. |
196 bool printing() const { return m_printing; } | 194 bool printing() const { return m_printing; } |
197 void setPrinting(bool printing) { m_printing = printing; } | 195 void setPrinting(bool printing) { m_printing = printing; } |
198 | 196 |
199 bool isAccelerated() const { return m_accelerated; } | 197 bool isAccelerated() const { return m_accelerated; } |
200 void setAccelerated(bool accelerated) { m_accelerated = accelerated; } | 198 void setAccelerated(bool accelerated) { m_accelerated = accelerated; } |
201 | 199 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 unsigned m_accelerated : 1; | 518 unsigned m_accelerated : 1; |
521 unsigned m_isCertainlyOpaque : 1; | 519 unsigned m_isCertainlyOpaque : 1; |
522 unsigned m_printing : 1; | 520 unsigned m_printing : 1; |
523 unsigned m_antialiasHairlineImages : 1; | 521 unsigned m_antialiasHairlineImages : 1; |
524 unsigned m_shouldSmoothFonts : 1; | 522 unsigned m_shouldSmoothFonts : 1; |
525 }; | 523 }; |
526 | 524 |
527 } // namespace blink | 525 } // namespace blink |
528 | 526 |
529 #endif // GraphicsContext_h | 527 #endif // GraphicsContext_h |
OLD | NEW |