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

Side by Side Diff: cc/scrollbar_layer_impl.cc

Issue 11276060: Pass accurate contentsScale to LayerImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased 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_impl.h ('k') | cc/test/tiled_layer_test_common.h » ('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_impl.h" 7 #include "cc/scrollbar_layer_impl.h"
8 8
9 #include "cc/quad_sink.h" 9 #include "cc/quad_sink.h"
10 #include "cc/scrollbar_animation_controller.h" 10 #include "cc/scrollbar_animation_controller.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 m_geometry->update(scrollbar); 66 m_geometry->update(scrollbar);
67 } 67 }
68 68
69 static FloatRect toUVRect(const WebRect& r, const IntRect& bounds) 69 static FloatRect toUVRect(const WebRect& r, const IntRect& bounds)
70 { 70 {
71 return FloatRect(static_cast<float>(r.x) / bounds.width(), static_cast<float >(r.y) / bounds.height(), 71 return FloatRect(static_cast<float>(r.x) / bounds.width(), static_cast<float >(r.y) / bounds.height(),
72 static_cast<float>(r.width) / bounds.width(), static_cast<f loat>(r.height) / bounds.height()); 72 static_cast<float>(r.width) / bounds.width(), static_cast<f loat>(r.height) / bounds.height());
73 } 73 }
74 74
75 IntRect ScrollbarLayerImpl::scrollbarLayerRectToContentRect(const WebRect& layer Rect) const
76 {
77 // Don't intersect with the bounds as in layerRectToContentRect() because
78 // layerRect here might be in coordinates of the containing layer.
79 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h eight);
80 contentRect.scale(contentsScaleX(), contentsScaleY());
81 return enclosingIntRect(contentRect);
82 }
83
75 void ScrollbarLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& append QuadsData) 84 void ScrollbarLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& append QuadsData)
76 { 85 {
77 bool premultipledAlpha = false; 86 bool premultipledAlpha = false;
78 bool flipped = false; 87 bool flipped = false;
79 FloatRect uvRect(0, 0, 1, 1); 88 FloatRect uvRect(0, 0, 1, 1);
80 IntRect boundsRect(IntPoint(), bounds()); 89 IntRect boundsRect(IntPoint(), bounds());
81 IntRect contentBoundsRect(IntPoint(), contentBounds()); 90 IntRect contentBoundsRect(IntPoint(), contentBounds());
82 91
83 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ uadState()); 92 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ uadState());
84 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); 93 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData);
85 94
86 WebRect thumbRect, backTrackRect, foreTrackRect; 95 WebRect thumbRect, backTrackRect, foreTrackRect;
87 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba ckTrackRect, thumbRect, foreTrackRect); 96 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba ckTrackRect, thumbRect, foreTrackRect);
88 if (!m_geometry->hasThumb(&m_scrollbar)) 97 if (!m_geometry->hasThumb(&m_scrollbar))
89 thumbRect = WebRect(); 98 thumbRect = WebRect();
90 99
91 if (m_thumbResourceId && !thumbRect.isEmpty()) { 100 if (m_thumbResourceId && !thumbRect.isEmpty()) {
92 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::create(sharedQuadSta te, layerRectToContentRect(thumbRect), m_thumbResourceId, premultipledAlpha, uvR ect, flipped); 101 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::create(sharedQuadSta te, scrollbarLayerRectToContentRect(thumbRect), m_thumbResourceId, premultipledA lpha, uvRect, flipped);
93 quad->setNeedsBlending(); 102 quad->setNeedsBlending();
94 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); 103 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData);
95 } 104 }
96 105
97 if (!m_backTrackResourceId) 106 if (!m_backTrackResourceId)
98 return; 107 return;
99 108
100 // We only paint the track in two parts if we were given a texture for the f orward track part. 109 // We only paint the track in two parts if we were given a texture for the f orward track part.
101 if (m_foreTrackResourceId && !foreTrackRect.isEmpty()) 110 if (m_foreTrackResourceId && !foreTrackRect.isEmpty())
102 quadSink.append(TextureDrawQuad::create(sharedQuadState, layerRectToCont entRect(foreTrackRect), m_foreTrackResourceId, premultipledAlpha, toUVRect(foreT rackRect, boundsRect), flipped).PassAs<DrawQuad>(), appendQuadsData); 111 quadSink.append(TextureDrawQuad::create(sharedQuadState, scrollbarLayerR ectToContentRect(foreTrackRect), m_foreTrackResourceId, premultipledAlpha, toUVR ect(foreTrackRect, boundsRect), flipped).PassAs<DrawQuad>(), appendQuadsData);
103 112
104 // Order matters here: since the back track texture is being drawn to the en tire contents rect, we must append it after the thumb and 113 // Order matters here: since the back track texture is being drawn to the en tire contents rect, we must append it after the thumb and
105 // fore track quads. The back track texture contains (and displays) the butt ons. 114 // fore track quads. The back track texture contains (and displays) the butt ons.
106 if (!contentBoundsRect.isEmpty()) 115 if (!contentBoundsRect.isEmpty())
107 quadSink.append(TextureDrawQuad::create(sharedQuadState, IntRect(content BoundsRect), m_backTrackResourceId, premultipledAlpha, uvRect, flipped).PassAs<D rawQuad>(), appendQuadsData); 116 quadSink.append(TextureDrawQuad::create(sharedQuadState, IntRect(content BoundsRect), m_backTrackResourceId, premultipledAlpha, uvRect, flipped).PassAs<D rawQuad>(), appendQuadsData);
108 } 117 }
109 118
110 void ScrollbarLayerImpl::didLoseContext() 119 void ScrollbarLayerImpl::didLoseContext()
111 { 120 {
112 m_backTrackResourceId = 0; 121 m_backTrackResourceId = 0;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 { 202 {
194 return m_owner->m_isCustomScrollbar; 203 return m_owner->m_isCustomScrollbar;
195 } 204 }
196 205
197 const char* ScrollbarLayerImpl::layerTypeAsString() const 206 const char* ScrollbarLayerImpl::layerTypeAsString() const
198 { 207 {
199 return "ScrollbarLayer"; 208 return "ScrollbarLayer";
200 } 209 }
201 210
202 } 211 }
OLDNEW
« no previous file with comments | « cc/scrollbar_layer_impl.h ('k') | cc/test/tiled_layer_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698