Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GraphicsContextState.cpp

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: Rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/GraphicsContextState.h" 5 #include "platform/graphics/GraphicsContextState.h"
6 6
7 #include "platform/graphics/skia/SkiaUtils.h" 7 #include "platform/graphics/skia/SkiaUtils.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 static inline SkFilterQuality filterQualityForPaint( 11 static inline SkFilterQuality filterQualityForPaint(
12 InterpolationQuality quality) { 12 InterpolationQuality quality) {
13 // The filter quality "selected" here will primarily be used when painting a 13 // The filter quality "selected" here will primarily be used when painting a
14 // primitive using one of the SkPaints below. For the most part this will 14 // primitive using one of the SkPaints below. For the most part this will
15 // not affect things that are part of the Image class hierarchy (which use 15 // not affect things that are part of the Image class hierarchy (which use
16 // the unmodified m_interpolationQuality.) 16 // the unmodified m_interpolationQuality.)
17 return quality != InterpolationNone ? kLow_SkFilterQuality 17 return quality != InterpolationNone ? kLow_SkFilterQuality
18 : kNone_SkFilterQuality; 18 : kNone_SkFilterQuality;
19 } 19 }
20 20
21 GraphicsContextState::GraphicsContextState() 21 GraphicsContextState::GraphicsContextState()
22 : m_textDrawingMode(TextModeFill), 22 : m_textDrawingMode(TextModeFill),
23 m_interpolationQuality(InterpolationDefault), 23 m_interpolationQuality(InterpolationDefault),
24 m_saveCount(0), 24 m_saveCount(0),
25 m_shouldAntialias(true) { 25 m_shouldAntialias(true) {
26 m_strokePaint.setStyle(SkPaint::kStroke_Style); 26 m_strokePaint.setStyle(PaintFlags::kStroke_Style);
27 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); 27 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness()));
28 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); 28 m_strokePaint.setStrokeCap(PaintFlags::kDefault_Cap);
29 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); 29 m_strokePaint.setStrokeJoin(PaintFlags::kDefault_Join);
30 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit())); 30 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit()));
31 m_strokePaint.setFilterQuality(filterQualityForPaint(m_interpolationQuality)); 31 m_strokePaint.setFilterQuality(filterQualityForPaint(m_interpolationQuality));
32 m_strokePaint.setAntiAlias(m_shouldAntialias); 32 m_strokePaint.setAntiAlias(m_shouldAntialias);
33 m_fillPaint.setFilterQuality(filterQualityForPaint(m_interpolationQuality)); 33 m_fillPaint.setFilterQuality(filterQualityForPaint(m_interpolationQuality));
34 m_fillPaint.setAntiAlias(m_shouldAntialias); 34 m_fillPaint.setAntiAlias(m_shouldAntialias);
35 } 35 }
36 36
37 GraphicsContextState::GraphicsContextState(const GraphicsContextState& other) 37 GraphicsContextState::GraphicsContextState(const GraphicsContextState& other)
38 : m_strokePaint(other.m_strokePaint), 38 : m_strokePaint(other.m_strokePaint),
39 m_fillPaint(other.m_fillPaint), 39 m_fillPaint(other.m_fillPaint),
40 m_strokeData(other.m_strokeData), 40 m_strokeData(other.m_strokeData),
41 m_textDrawingMode(other.m_textDrawingMode), 41 m_textDrawingMode(other.m_textDrawingMode),
42 m_interpolationQuality(other.m_interpolationQuality), 42 m_interpolationQuality(other.m_interpolationQuality),
43 m_saveCount(0), 43 m_saveCount(0),
44 m_shouldAntialias(other.m_shouldAntialias) {} 44 m_shouldAntialias(other.m_shouldAntialias) {}
45 45
46 void GraphicsContextState::copy(const GraphicsContextState& source) { 46 void GraphicsContextState::copy(const GraphicsContextState& source) {
47 this->~GraphicsContextState(); 47 this->~GraphicsContextState();
48 new (this) GraphicsContextState(source); 48 new (this) GraphicsContextState(source);
49 } 49 }
50 50
51 const SkPaint& GraphicsContextState::strokePaint(int strokedPathLength) const { 51 const PaintFlags& GraphicsContextState::strokePaint(
52 int strokedPathLength) const {
52 m_strokeData.setupPaintDashPathEffect(&m_strokePaint, strokedPathLength); 53 m_strokeData.setupPaintDashPathEffect(&m_strokePaint, strokedPathLength);
53 return m_strokePaint; 54 return m_strokePaint;
54 } 55 }
55 56
56 void GraphicsContextState::setStrokeStyle(StrokeStyle style) { 57 void GraphicsContextState::setStrokeStyle(StrokeStyle style) {
57 m_strokeData.setStyle(style); 58 m_strokeData.setStyle(style);
58 } 59 }
59 60
60 void GraphicsContextState::setStrokeThickness(float thickness) { 61 void GraphicsContextState::setStrokeThickness(float thickness) {
61 m_strokeData.setThickness(thickness); 62 m_strokeData.setThickness(thickness);
62 m_strokePaint.setStrokeWidth(SkFloatToScalar(thickness)); 63 m_strokePaint.setStrokeWidth(SkFloatToScalar(thickness));
63 } 64 }
64 65
65 void GraphicsContextState::setStrokeColor(const Color& color) { 66 void GraphicsContextState::setStrokeColor(const Color& color) {
66 m_strokePaint.setColor(color.rgb()); 67 m_strokePaint.setColor(color.rgb());
67 m_strokePaint.setShader(0); 68 m_strokePaint.setShader(0);
68 } 69 }
69 70
70 void GraphicsContextState::setLineCap(LineCap cap) { 71 void GraphicsContextState::setLineCap(LineCap cap) {
71 m_strokeData.setLineCap(cap); 72 m_strokeData.setLineCap(cap);
72 m_strokePaint.setStrokeCap((SkPaint::Cap)cap); 73 m_strokePaint.setStrokeCap((PaintFlags::Cap)cap);
73 } 74 }
74 75
75 void GraphicsContextState::setLineJoin(LineJoin join) { 76 void GraphicsContextState::setLineJoin(LineJoin join) {
76 m_strokeData.setLineJoin(join); 77 m_strokeData.setLineJoin(join);
77 m_strokePaint.setStrokeJoin((SkPaint::Join)join); 78 m_strokePaint.setStrokeJoin((PaintFlags::Join)join);
78 } 79 }
79 80
80 void GraphicsContextState::setMiterLimit(float miterLimit) { 81 void GraphicsContextState::setMiterLimit(float miterLimit) {
81 m_strokeData.setMiterLimit(miterLimit); 82 m_strokeData.setMiterLimit(miterLimit);
82 m_strokePaint.setStrokeMiter(SkFloatToScalar(miterLimit)); 83 m_strokePaint.setStrokeMiter(SkFloatToScalar(miterLimit));
83 } 84 }
84 85
85 void GraphicsContextState::setFillColor(const Color& color) { 86 void GraphicsContextState::setFillColor(const Color& color) {
86 m_fillPaint.setColor(color.rgb()); 87 m_fillPaint.setColor(color.rgb());
87 m_fillPaint.setShader(0); 88 m_fillPaint.setShader(0);
(...skipping 26 matching lines...) Expand all
114 m_fillPaint.setFilterQuality(filterQualityForPaint(quality)); 115 m_fillPaint.setFilterQuality(filterQualityForPaint(quality));
115 } 116 }
116 117
117 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) { 118 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) {
118 m_shouldAntialias = shouldAntialias; 119 m_shouldAntialias = shouldAntialias;
119 m_strokePaint.setAntiAlias(shouldAntialias); 120 m_strokePaint.setAntiAlias(shouldAntialias);
120 m_fillPaint.setAntiAlias(shouldAntialias); 121 m_fillPaint.setAntiAlias(shouldAntialias);
121 } 122 }
122 123
123 } // namespace blink 124 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698