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

Side by Side Diff: cc/ScrollbarLayerChromium.cpp

Issue 10989003: Revert 158386 - Revert 158362 - Support high DPI scrollbar on top level web frame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « cc/ScrollbarLayerChromium.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "config.h" 5 #include "config.h"
6 6
7 #if USE(ACCELERATED_COMPOSITING) 7 #if USE(ACCELERATED_COMPOSITING)
8 8
9 #include "ScrollbarLayerChromium.h" 9 #include "ScrollbarLayerChromium.h"
10 10
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 , m_trackPart(trackPart) 124 , m_trackPart(trackPart)
125 { 125 {
126 } 126 }
127 127
128 WebKit::WebScrollbar* m_scrollbar; 128 WebKit::WebScrollbar* m_scrollbar;
129 WebKit::WebScrollbarThemePainter m_painter; 129 WebKit::WebScrollbarThemePainter m_painter;
130 WebKit::WebScrollbarThemeGeometry* m_geometry; 130 WebKit::WebScrollbarThemeGeometry* m_geometry;
131 WebKit::WebScrollbar::ScrollbarPart m_trackPart; 131 WebKit::WebScrollbar::ScrollbarPart m_trackPart;
132 }; 132 };
133 133
134 bool ScrollbarLayerChromium::needsContentsScale() const
135 {
136 return true;
137 }
138
139 IntSize ScrollbarLayerChromium::contentBounds() const
140 {
141 return IntSize(lroundf(bounds().width() * contentsScale()), lroundf(bounds() .height() * contentsScale()));
142 }
143
134 class ScrollbarThumbPainter : public LayerPainterChromium { 144 class ScrollbarThumbPainter : public LayerPainterChromium {
135 WTF_MAKE_NONCOPYABLE(ScrollbarThumbPainter); 145 WTF_MAKE_NONCOPYABLE(ScrollbarThumbPainter);
136 public: 146 public:
137 static PassOwnPtr<ScrollbarThumbPainter> create(WebKit::WebScrollbar* scroll bar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeometry * geometry) 147 static PassOwnPtr<ScrollbarThumbPainter> create(WebKit::WebScrollbar* scroll bar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeometry * geometry)
138 { 148 {
139 return adoptPtr(new ScrollbarThumbPainter(scrollbar, painter, geometry)) ; 149 return adoptPtr(new ScrollbarThumbPainter(scrollbar, painter, geometry)) ;
140 } 150 }
141 151
142 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect & opaque) OVERRIDE 152 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect & opaque) OVERRIDE
143 { 153 {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 && texture->texture()->size() == rect.size() 216 && texture->texture()->size() == rect.size()
207 && m_updateRect.isEmpty()) 217 && m_updateRect.isEmpty())
208 return; 218 return;
209 219
210 // We should always have enough memory for UI. 220 // We should always have enough memory for UI.
211 ASSERT(texture->texture()->canAcquireBackingTexture()); 221 ASSERT(texture->texture()->canAcquireBackingTexture());
212 if (!texture->texture()->canAcquireBackingTexture()) 222 if (!texture->texture()->canAcquireBackingTexture())
213 return; 223 return;
214 224
215 // Paint and upload the entire part. 225 // Paint and upload the entire part.
226 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi dth();
227 float heightScale = static_cast<float>(contentBounds().height()) / bounds(). height();
216 IntRect paintedOpaqueRect; 228 IntRect paintedOpaqueRect;
217 painter->prepareToUpdate(rect, rect.size(), 1, 1, paintedOpaqueRect, stats); 229 painter->prepareToUpdate(rect, rect.size(), widthScale, heightScale, painted OpaqueRect, stats);
218 texture->prepareRect(rect, stats); 230 texture->prepareRect(rect, stats);
219 231
220 IntSize destOffset(0, 0); 232 IntSize destOffset(0, 0);
221 TextureUploader::Parameters upload = { texture, rect, destOffset }; 233 TextureUploader::Parameters upload = { texture, rect, destOffset };
222 queue.appendFullUpload(upload); 234 queue.appendFullUpload(upload);
223 } 235 }
224 236
225 237
226 void ScrollbarLayerChromium::setTexturePriorities(const CCPriorityCalculator&) 238 void ScrollbarLayerChromium::setTexturePriorities(const CCPriorityCalculator&)
227 { 239 {
228 if (contentBounds().isEmpty()) 240 if (contentBounds().isEmpty())
229 return; 241 return;
230 242
231 createTextureUpdaterIfNeeded(); 243 createTextureUpdaterIfNeeded();
232 244
233 bool drawsToRoot = !renderTarget()->parent(); 245 bool drawsToRoot = !renderTarget()->parent();
234 if (m_backTrack) { 246 if (m_backTrack) {
235 m_backTrack->texture()->setDimensions(contentBounds(), m_textureFormat); 247 m_backTrack->texture()->setDimensions(contentBounds(), m_textureFormat);
236 m_backTrack->texture()->setRequestPriority(CCPriorityCalculator::uiPrior ity(drawsToRoot)); 248 m_backTrack->texture()->setRequestPriority(CCPriorityCalculator::uiPrior ity(drawsToRoot));
237 } 249 }
238 if (m_foreTrack) { 250 if (m_foreTrack) {
239 m_foreTrack->texture()->setDimensions(contentBounds(), m_textureFormat); 251 m_foreTrack->texture()->setDimensions(contentBounds(), m_textureFormat);
240 m_foreTrack->texture()->setRequestPriority(CCPriorityCalculator::uiPrior ity(drawsToRoot)); 252 m_foreTrack->texture()->setRequestPriority(CCPriorityCalculator::uiPrior ity(drawsToRoot));
241 } 253 }
242 if (m_thumb) { 254 if (m_thumb) {
243 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); 255 IntSize thumbSize = layerRectToContentRect(m_geometry->thumbRect(m_scrol lbar.get())).size();
244 m_thumb->texture()->setDimensions(IntSize(thumbRect.width, thumbRect.hei ght), m_textureFormat); 256 m_thumb->texture()->setDimensions(thumbSize, m_textureFormat);
245 m_thumb->texture()->setRequestPriority(CCPriorityCalculator::uiPriority( drawsToRoot)); 257 m_thumb->texture()->setRequestPriority(CCPriorityCalculator::uiPriority( drawsToRoot));
246 } 258 }
247 } 259 }
248 260
249 void ScrollbarLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusi onTracker*, CCRenderingStats& stats) 261 void ScrollbarLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusi onTracker*, CCRenderingStats& stats)
250 { 262 {
251 if (contentBounds().isEmpty()) 263 if (contentBounds().isEmpty())
252 return; 264 return;
253 265
254 createTextureUpdaterIfNeeded(); 266 createTextureUpdaterIfNeeded();
255 267
256 IntPoint scrollbarOrigin(m_scrollbar->location().x, m_scrollbar->location(). y); 268 IntPoint scrollbarOrigin(m_scrollbar->location().x, m_scrollbar->location(). y);
257 IntRect contentRect(scrollbarOrigin, contentBounds()); 269 IntRect contentRect = layerRectToContentRect(WebKit::WebRect(scrollbarOrigin .x(), scrollbarOrigin.y(), bounds().width(), bounds().height()));
258 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue, stats); 270 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue, stats);
259 if (m_foreTrack && m_foreTrackUpdater) 271 if (m_foreTrack && m_foreTrackUpdater)
260 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que ue, stats); 272 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que ue, stats);
261 273
262 // Consider the thumb to be at the origin when painting. 274 // Consider the thumb to be at the origin when painting.
263 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); 275 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get());
264 IntRect originThumbRect = IntRect(0, 0, thumbRect.width, thumbRect.height); 276 IntRect originThumbRect = layerRectToContentRect(WebKit::WebRect(0, 0, thumb Rect.width, thumbRect.height));
265 if (!originThumbRect.isEmpty()) 277 if (!originThumbRect.isEmpty())
266 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue, stats); 278 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue, stats);
267 } 279 }
268 280
269 } 281 }
270 #endif // USE(ACCELERATED_COMPOSITING) 282 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW
« no previous file with comments | « cc/ScrollbarLayerChromium.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698