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

Side by Side Diff: third_party/WebKit/Source/platform/exported/WebScrollbarThemePainter.cpp

Issue 1430503007: Paint scrollbars at device scale resolution. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 23 matching lines...) Expand all
34 #include "public/platform/WebRect.h" 34 #include "public/platform/WebRect.h"
35 #include "third_party/skia/include/core/SkCanvas.h" 35 #include "third_party/skia/include/core/SkCanvas.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 void WebScrollbarThemePainter::assign(const WebScrollbarThemePainter& painter) 39 void WebScrollbarThemePainter::assign(const WebScrollbarThemePainter& painter)
40 { 40 {
41 // This is a pointer to a static object, so no ownership transferral. 41 // This is a pointer to a static object, so no ownership transferral.
42 m_theme = painter.m_theme; 42 m_theme = painter.m_theme;
43 m_scrollbar = painter.m_scrollbar; 43 m_scrollbar = painter.m_scrollbar;
44 m_deviceScaleFactor = painter.m_deviceScaleFactor;
44 } 45 }
45 46
46 void WebScrollbarThemePainter::reset() 47 void WebScrollbarThemePainter::reset()
47 { 48 {
48 m_scrollbar = nullptr; 49 m_scrollbar = nullptr;
49 } 50 }
50 51
51 void WebScrollbarThemePainter::paintScrollbarBackground(WebCanvas* canvas, const WebRect& rect) 52 void WebScrollbarThemePainter::paintScrollbarBackground(WebCanvas* canvas, const WebRect& rect)
52 { 53 {
53 SkRect clip = SkRect::MakeXYWH(rect.x, rect.y, rect.width, rect.height); 54 SkRect clip = SkRect::MakeXYWH(rect.x, rect.y, rect.width, rect.height);
54 canvas->clipRect(clip); 55 canvas->clipRect(clip);
55 56
56 IntRect intRect(rect); 57 IntRect intRect(rect);
57 SkPictureBuilder pictureBuilder(intRect); 58 SkPictureBuilder pictureBuilder(intRect);
59 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
ccameron 2015/11/06 23:15:20 I have a vague preference for rolling this into Sk
58 m_theme->paintScrollbarBackground(&pictureBuilder.context(), m_scrollbar.get ()); 60 m_theme->paintScrollbarBackground(&pictureBuilder.context(), m_scrollbar.get ());
59 pictureBuilder.endRecording()->playback(canvas); 61 pictureBuilder.endRecording()->playback(canvas);
60 } 62 }
61 63
62 void WebScrollbarThemePainter::paintTrackBackground(WebCanvas* canvas, const Web Rect& rect) 64 void WebScrollbarThemePainter::paintTrackBackground(WebCanvas* canvas, const Web Rect& rect)
63 { 65 {
64 IntRect intRect(rect); 66 IntRect intRect(rect);
65 SkPictureBuilder pictureBuilder(intRect); 67 SkPictureBuilder pictureBuilder(intRect);
68 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
66 m_theme->paintTrackBackground(&pictureBuilder.context(), m_scrollbar.get(), intRect); 69 m_theme->paintTrackBackground(&pictureBuilder.context(), m_scrollbar.get(), intRect);
67 pictureBuilder.endRecording()->playback(canvas); 70 pictureBuilder.endRecording()->playback(canvas);
68 } 71 }
69 72
70 void WebScrollbarThemePainter::paintBackTrackPart(WebCanvas* canvas, const WebRe ct& rect) 73 void WebScrollbarThemePainter::paintBackTrackPart(WebCanvas* canvas, const WebRe ct& rect)
71 { 74 {
72 IntRect intRect(rect); 75 IntRect intRect(rect);
73 SkPictureBuilder pictureBuilder(intRect); 76 SkPictureBuilder pictureBuilder(intRect);
77 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
74 m_theme->paintTrackPiece(&pictureBuilder.context(), m_scrollbar.get(), intRe ct, BackTrackPart); 78 m_theme->paintTrackPiece(&pictureBuilder.context(), m_scrollbar.get(), intRe ct, BackTrackPart);
75 pictureBuilder.endRecording()->playback(canvas); 79 pictureBuilder.endRecording()->playback(canvas);
76 } 80 }
77 81
78 void WebScrollbarThemePainter::paintForwardTrackPart(WebCanvas* canvas, const We bRect& rect) 82 void WebScrollbarThemePainter::paintForwardTrackPart(WebCanvas* canvas, const We bRect& rect)
79 { 83 {
80 IntRect intRect(rect); 84 IntRect intRect(rect);
81 SkPictureBuilder pictureBuilder(intRect); 85 SkPictureBuilder pictureBuilder(intRect);
86 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
82 m_theme->paintTrackPiece(&pictureBuilder.context(), m_scrollbar.get(), intRe ct, ForwardTrackPart); 87 m_theme->paintTrackPiece(&pictureBuilder.context(), m_scrollbar.get(), intRe ct, ForwardTrackPart);
83 pictureBuilder.endRecording()->playback(canvas); 88 pictureBuilder.endRecording()->playback(canvas);
84 } 89 }
85 90
86 void WebScrollbarThemePainter::paintBackButtonStart(WebCanvas* canvas, const Web Rect& rect) 91 void WebScrollbarThemePainter::paintBackButtonStart(WebCanvas* canvas, const Web Rect& rect)
87 { 92 {
88 IntRect intRect(rect); 93 IntRect intRect(rect);
89 SkPictureBuilder pictureBuilder(intRect); 94 SkPictureBuilder pictureBuilder(intRect);
95 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
90 m_theme->paintButton(&pictureBuilder.context(), m_scrollbar.get(), intRect, BackButtonStartPart); 96 m_theme->paintButton(&pictureBuilder.context(), m_scrollbar.get(), intRect, BackButtonStartPart);
91 pictureBuilder.endRecording()->playback(canvas); 97 pictureBuilder.endRecording()->playback(canvas);
92 } 98 }
93 99
94 void WebScrollbarThemePainter::paintBackButtonEnd(WebCanvas* canvas, const WebRe ct& rect) 100 void WebScrollbarThemePainter::paintBackButtonEnd(WebCanvas* canvas, const WebRe ct& rect)
95 { 101 {
96 IntRect intRect(rect); 102 IntRect intRect(rect);
97 SkPictureBuilder pictureBuilder(intRect); 103 SkPictureBuilder pictureBuilder(intRect);
104 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
98 m_theme->paintButton(&pictureBuilder.context(), m_scrollbar.get(), intRect, BackButtonEndPart); 105 m_theme->paintButton(&pictureBuilder.context(), m_scrollbar.get(), intRect, BackButtonEndPart);
99 pictureBuilder.endRecording()->playback(canvas); 106 pictureBuilder.endRecording()->playback(canvas);
100 } 107 }
101 108
102 void WebScrollbarThemePainter::paintForwardButtonStart(WebCanvas* canvas, const WebRect& rect) 109 void WebScrollbarThemePainter::paintForwardButtonStart(WebCanvas* canvas, const WebRect& rect)
103 { 110 {
104 IntRect intRect(rect); 111 IntRect intRect(rect);
105 SkPictureBuilder pictureBuilder(intRect); 112 SkPictureBuilder pictureBuilder(intRect);
113 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
106 m_theme->paintButton(&pictureBuilder.context(), m_scrollbar.get(), intRect, ForwardButtonStartPart); 114 m_theme->paintButton(&pictureBuilder.context(), m_scrollbar.get(), intRect, ForwardButtonStartPart);
107 pictureBuilder.endRecording()->playback(canvas); 115 pictureBuilder.endRecording()->playback(canvas);
108 } 116 }
109 117
110 void WebScrollbarThemePainter::paintForwardButtonEnd(WebCanvas* canvas, const We bRect& rect) 118 void WebScrollbarThemePainter::paintForwardButtonEnd(WebCanvas* canvas, const We bRect& rect)
111 { 119 {
112 IntRect intRect(rect); 120 IntRect intRect(rect);
113 SkPictureBuilder pictureBuilder(intRect); 121 SkPictureBuilder pictureBuilder(intRect);
122 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
114 m_theme->paintButton(&pictureBuilder.context(), m_scrollbar.get(), intRect, ForwardButtonEndPart); 123 m_theme->paintButton(&pictureBuilder.context(), m_scrollbar.get(), intRect, ForwardButtonEndPart);
115 pictureBuilder.endRecording()->playback(canvas); 124 pictureBuilder.endRecording()->playback(canvas);
116 } 125 }
117 126
118 void WebScrollbarThemePainter::paintTickmarks(WebCanvas* canvas, const WebRect& rect) 127 void WebScrollbarThemePainter::paintTickmarks(WebCanvas* canvas, const WebRect& rect)
119 { 128 {
120 IntRect intRect(rect); 129 IntRect intRect(rect);
121 SkPictureBuilder pictureBuilder(intRect); 130 SkPictureBuilder pictureBuilder(intRect);
131 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
122 m_theme->paintTickmarks(&pictureBuilder.context(), m_scrollbar.get(), intRec t); 132 m_theme->paintTickmarks(&pictureBuilder.context(), m_scrollbar.get(), intRec t);
123 pictureBuilder.endRecording()->playback(canvas); 133 pictureBuilder.endRecording()->playback(canvas);
124 } 134 }
125 135
126 void WebScrollbarThemePainter::paintThumb(WebCanvas* canvas, const WebRect& rect ) 136 void WebScrollbarThemePainter::paintThumb(WebCanvas* canvas, const WebRect& rect )
127 { 137 {
128 IntRect intRect(rect); 138 IntRect intRect(rect);
129 SkPictureBuilder pictureBuilder(intRect); 139 SkPictureBuilder pictureBuilder(intRect);
140 pictureBuilder.context().setDeviceScaleFactor(m_deviceScaleFactor);
130 m_theme->paintThumb(&pictureBuilder.context(), m_scrollbar.get(), intRect); 141 m_theme->paintThumb(&pictureBuilder.context(), m_scrollbar.get(), intRect);
131 pictureBuilder.endRecording()->playback(canvas); 142 pictureBuilder.endRecording()->playback(canvas);
132 } 143 }
133 144
134 WebScrollbarThemePainter::WebScrollbarThemePainter(ScrollbarTheme* theme, Scroll bar* scrollbar) 145 WebScrollbarThemePainter::WebScrollbarThemePainter(ScrollbarTheme* theme, Scroll bar* scrollbar, float deviceScaleFactor)
135 : m_theme(theme) 146 : m_theme(theme)
136 , m_scrollbar(scrollbar) 147 , m_scrollbar(scrollbar)
148 , m_deviceScaleFactor(deviceScaleFactor)
137 { 149 {
138 } 150 }
139 151
140 } // namespace blink 152 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698