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

Side by Side Diff: cc/scrollbar_layer.cc

Issue 11264056: cc: Use gfx:: Geometry types for positions, bounds, and related things. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ScaleAsVector Created 8 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 | Annotate | Revision Log
« no previous file with comments | « cc/scrollbar_layer.h ('k') | cc/scrollbar_layer_impl.cc » ('j') | 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 #include "cc/scrollbar_layer.h" 7 #include "cc/scrollbar_layer.h"
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "cc/layer_painter.h" 11 #include "cc/layer_painter.h"
12 #include "cc/layer_tree_host.h" 12 #include "cc/layer_tree_host.h"
13 #include "cc/resource_update_queue.h" 13 #include "cc/resource_update_queue.h"
14 #include "cc/scrollbar_layer_impl.h" 14 #include "cc/scrollbar_layer_impl.h"
15 #include "ui/gfx/rect_conversions.h"
15 #include <public/WebRect.h> 16 #include <public/WebRect.h>
16 17
17 using WebKit::WebRect; 18 using WebKit::WebRect;
18 19
19 namespace cc { 20 namespace cc {
20 21
21 scoped_ptr<LayerImpl> ScrollbarLayer::createLayerImpl() 22 scoped_ptr<LayerImpl> ScrollbarLayer::createLayerImpl()
22 { 23 {
23 return ScrollbarLayerImpl::create(id()).PassAs<LayerImpl>(); 24 return ScrollbarLayerImpl::create(id()).PassAs<LayerImpl>();
24 } 25 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 if (!m_foreTrack) 192 if (!m_foreTrack)
192 m_foreTrack = m_foreTrackUpdater->createResource(layerTreeHost()->co ntentsTextureManager()); 193 m_foreTrack = m_foreTrackUpdater->createResource(layerTreeHost()->co ntentsTextureManager());
193 } 194 }
194 195
195 if (!m_thumbUpdater) 196 if (!m_thumbUpdater)
196 m_thumbUpdater = CachingBitmapContentLayerUpdater::Create(ScrollbarThumb Painter::create(m_scrollbar.get(), m_painter, m_geometry.get()).PassAs<LayerPain ter>()); 197 m_thumbUpdater = CachingBitmapContentLayerUpdater::Create(ScrollbarThumb Painter::create(m_scrollbar.get(), m_painter, m_geometry.get()).PassAs<LayerPain ter>());
197 if (!m_thumb) 198 if (!m_thumb)
198 m_thumb = m_thumbUpdater->createResource(layerTreeHost()->contentsTextur eManager()); 199 m_thumb = m_thumbUpdater->createResource(layerTreeHost()->contentsTextur eManager());
199 } 200 }
200 201
201 void ScrollbarLayer::updatePart(CachingBitmapContentLayerUpdater* painter, Layer Updater::Resource* texture, const IntRect& rect, ResourceUpdateQueue& queue, Ren deringStats& stats) 202 void ScrollbarLayer::updatePart(CachingBitmapContentLayerUpdater* painter, Layer Updater::Resource* texture, const gfx::Rect& rect, ResourceUpdateQueue& queue, R enderingStats& stats)
202 { 203 {
203 // Skip painting and uploading if there are no invalidations and 204 // Skip painting and uploading if there are no invalidations and
204 // we already have valid texture data. 205 // we already have valid texture data.
205 if (texture->texture()->haveBackingTexture() 206 if (texture->texture()->haveBackingTexture()
206 && texture->texture()->size() == rect.size() 207 && texture->texture()->size() == rect.size()
207 && m_updateRect.isEmpty()) 208 && m_updateRect.IsEmpty())
208 return; 209 return;
209 210
210 // We should always have enough memory for UI. 211 // We should always have enough memory for UI.
211 DCHECK(texture->texture()->canAcquireBackingTexture()); 212 DCHECK(texture->texture()->canAcquireBackingTexture());
212 if (!texture->texture()->canAcquireBackingTexture()) 213 if (!texture->texture()->canAcquireBackingTexture())
213 return; 214 return;
214 215
215 // Paint and upload the entire part. 216 // Paint and upload the entire part.
216 gfx::Rect paintedOpaqueRect; 217 gfx::Rect paintedOpaqueRect;
217 painter->prepareToUpdate(rect, rect.size(), contentsScaleX(), contentsScaleY (), paintedOpaqueRect, stats); 218 painter->prepareToUpdate(rect, rect.size(), contentsScaleX(), contentsScaleY (), paintedOpaqueRect, stats);
218 if (!painter->pixelsDidChange() && texture->texture()->haveBackingTexture()) { 219 if (!painter->pixelsDidChange() && texture->texture()->haveBackingTexture()) {
219 TRACE_EVENT_INSTANT0("cc","ScrollbarLayer::updatePart no texture upload needed"); 220 TRACE_EVENT_INSTANT0("cc","ScrollbarLayer::updatePart no texture upload needed");
220 return; 221 return;
221 } 222 }
222 223
223 gfx::Vector2d destOffset(0, 0); 224 gfx::Vector2d destOffset(0, 0);
224 texture->update(queue, rect, destOffset, false, stats); 225 texture->update(queue, rect, destOffset, false, stats);
225 } 226 }
226 227
227 IntRect ScrollbarLayer::scrollbarLayerRectToContentRect(const WebRect& layerRect ) const 228 gfx::Rect ScrollbarLayer::scrollbarLayerRectToContentRect(const gfx::Rect& layer Rect) const
228 { 229 {
229 // Don't intersect with the bounds as in layerRectToContentRect() because 230 // Don't intersect with the bounds as in layerRectToContentRect() because
230 // layerRect here might be in coordinates of the containing layer. 231 // layerRect here might be in coordinates of the containing layer.
231 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h eight); 232 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content sScaleY());
232 contentRect.scale(contentsScaleX(), contentsScaleY()); 233 return gfx::ToEnclosingRect(contentRect);
233 return enclosingIntRect(contentRect);
234 } 234 }
235 235
236 void ScrollbarLayer::setTexturePriorities(const PriorityCalculator&) 236 void ScrollbarLayer::setTexturePriorities(const PriorityCalculator&)
237 { 237 {
238 if (contentBounds().isEmpty()) 238 if (contentBounds().IsEmpty())
239 return; 239 return;
240 240
241 createUpdaterIfNeeded(); 241 createUpdaterIfNeeded();
242 242
243 bool drawsToRoot = !renderTarget()->parent(); 243 bool drawsToRoot = !renderTarget()->parent();
244 if (m_backTrack) { 244 if (m_backTrack) {
245 m_backTrack->texture()->setDimensions(contentBounds(), m_textureFormat); 245 m_backTrack->texture()->setDimensions(contentBounds(), m_textureFormat);
246 m_backTrack->texture()->setRequestPriority(PriorityCalculator::uiPriorit y(drawsToRoot)); 246 m_backTrack->texture()->setRequestPriority(PriorityCalculator::uiPriorit y(drawsToRoot));
247 } 247 }
248 if (m_foreTrack) { 248 if (m_foreTrack) {
249 m_foreTrack->texture()->setDimensions(contentBounds(), m_textureFormat); 249 m_foreTrack->texture()->setDimensions(contentBounds(), m_textureFormat);
250 m_foreTrack->texture()->setRequestPriority(PriorityCalculator::uiPriorit y(drawsToRoot)); 250 m_foreTrack->texture()->setRequestPriority(PriorityCalculator::uiPriorit y(drawsToRoot));
251 } 251 }
252 if (m_thumb) { 252 if (m_thumb) {
253 IntSize thumbSize = scrollbarLayerRectToContentRect(m_geometry->thumbRec t(m_scrollbar.get())).size(); 253 gfx::Size thumbSize = scrollbarLayerRectToContentRect(m_geometry->thumbR ect(m_scrollbar.get())).size();
254 m_thumb->texture()->setDimensions(thumbSize, m_textureFormat); 254 m_thumb->texture()->setDimensions(thumbSize, m_textureFormat);
255 m_thumb->texture()->setRequestPriority(PriorityCalculator::uiPriority(dr awsToRoot)); 255 m_thumb->texture()->setRequestPriority(PriorityCalculator::uiPriority(dr awsToRoot));
256 } 256 }
257 } 257 }
258 258
259 void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, RenderingStats& stats) 259 void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, RenderingStats& stats)
260 { 260 {
261 if (contentBounds().isEmpty()) 261 if (contentBounds().IsEmpty())
262 return; 262 return;
263 263
264 createUpdaterIfNeeded(); 264 createUpdaterIfNeeded();
265 265
266 IntRect contentRect = scrollbarLayerRectToContentRect(WebRect(m_scrollbar->l ocation().x, m_scrollbar->location().y, bounds().width(), bounds().height())); 266 gfx::Rect contentRect = scrollbarLayerRectToContentRect(gfx::Rect(m_scrollba r->location(), bounds()));
267 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue, stats); 267 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue, stats);
268 if (m_foreTrack && m_foreTrackUpdater) 268 if (m_foreTrack && m_foreTrackUpdater)
269 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que ue, stats); 269 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que ue, stats);
270 270
271 // Consider the thumb to be at the origin when painting. 271 // Consider the thumb to be at the origin when painting.
272 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); 272 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get());
273 IntRect originThumbRect = scrollbarLayerRectToContentRect(WebRect(0, 0, thum bRect.width, thumbRect.height)); 273 gfx::Rect originThumbRect = scrollbarLayerRectToContentRect(gfx::Rect(0, 0, thumbRect.width, thumbRect.height));
274 if (!originThumbRect.isEmpty()) 274 if (!originThumbRect.IsEmpty())
275 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue, stats); 275 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue, stats);
276 } 276 }
277 277
278 } 278 }
OLDNEW
« no previous file with comments | « cc/scrollbar_layer.h ('k') | cc/scrollbar_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698