| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 for (size_t i = 0; i < scroll_info.scrolls.size(); ++i) { | 197 for (size_t i = 0; i < scroll_info.scrolls.size(); ++i) { |
| 198 if (scroll_info.scrolls[i].layer_id != id) | 198 if (scroll_info.scrolls[i].layer_id != id) |
| 199 continue; | 199 continue; |
| 200 times_encountered++; | 200 times_encountered++; |
| 201 } | 201 } |
| 202 | 202 |
| 203 ASSERT_EQ(0, times_encountered); | 203 ASSERT_EQ(0, times_encountered); |
| 204 } | 204 } |
| 205 | 205 |
| 206 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, | 206 LayerImpl* CreateScrollAndContentsLayers(LayerTreeImpl* layer_tree_impl, |
| 207 const gfx::Size& content_size) { | 207 gfx::Size content_size) { |
| 208 scoped_ptr<LayerImpl> root = | 208 scoped_ptr<LayerImpl> root = |
| 209 LayerImpl::Create(layer_tree_impl, 1); | 209 LayerImpl::Create(layer_tree_impl, 1); |
| 210 root->SetBounds(content_size); | 210 root->SetBounds(content_size); |
| 211 root->SetContentBounds(content_size); | 211 root->SetContentBounds(content_size); |
| 212 root->SetPosition(gfx::PointF()); | 212 root->SetPosition(gfx::PointF()); |
| 213 root->SetAnchorPoint(gfx::PointF()); | 213 root->SetAnchorPoint(gfx::PointF()); |
| 214 | 214 |
| 215 scoped_ptr<LayerImpl> scroll = | 215 scoped_ptr<LayerImpl> scroll = |
| 216 LayerImpl::Create(layer_tree_impl, 2); | 216 LayerImpl::Create(layer_tree_impl, 2); |
| 217 LayerImpl* scroll_layer = scroll.get(); | 217 LayerImpl* scroll_layer = scroll.get(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 232 contents->SetPosition(gfx::PointF()); | 232 contents->SetPosition(gfx::PointF()); |
| 233 contents->SetAnchorPoint(gfx::PointF()); | 233 contents->SetAnchorPoint(gfx::PointF()); |
| 234 | 234 |
| 235 scroll->AddChild(contents.Pass()); | 235 scroll->AddChild(contents.Pass()); |
| 236 root->AddChild(scroll.Pass()); | 236 root->AddChild(scroll.Pass()); |
| 237 | 237 |
| 238 layer_tree_impl->SetRootLayer(root.Pass()); | 238 layer_tree_impl->SetRootLayer(root.Pass()); |
| 239 return scroll_layer; | 239 return scroll_layer; |
| 240 } | 240 } |
| 241 | 241 |
| 242 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { | 242 LayerImpl* SetupScrollAndContentsLayers(gfx::Size content_size) { |
| 243 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( | 243 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( |
| 244 host_impl_->active_tree(), content_size); | 244 host_impl_->active_tree(), content_size); |
| 245 host_impl_->active_tree()->DidBecomeActive(); | 245 host_impl_->active_tree()->DidBecomeActive(); |
| 246 return scroll_layer; | 246 return scroll_layer; |
| 247 } | 247 } |
| 248 | 248 |
| 249 scoped_ptr<LayerImpl> CreateScrollableLayer(int id, const gfx::Size& size) { | 249 scoped_ptr<LayerImpl> CreateScrollableLayer(int id, gfx::Size size) { |
| 250 scoped_ptr<LayerImpl> layer = | 250 scoped_ptr<LayerImpl> layer = |
| 251 LayerImpl::Create(host_impl_->active_tree(), id); | 251 LayerImpl::Create(host_impl_->active_tree(), id); |
| 252 layer->SetScrollable(true); | 252 layer->SetScrollable(true); |
| 253 layer->SetDrawsContent(true); | 253 layer->SetDrawsContent(true); |
| 254 layer->SetBounds(size); | 254 layer->SetBounds(size); |
| 255 layer->SetContentBounds(size); | 255 layer->SetContentBounds(size); |
| 256 layer->SetMaxScrollOffset(gfx::Vector2d(size.width() * 2, | 256 layer->SetMaxScrollOffset(gfx::Vector2d(size.width() * 2, |
| 257 size.height() * 2)); | 257 size.height() * 2)); |
| 258 return layer.Pass(); | 258 return layer.Pass(); |
| 259 } | 259 } |
| (...skipping 2902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3162 host_impl_->DidDrawAllLayers(frame); | 3162 host_impl_->DidDrawAllLayers(frame); |
| 3163 } | 3163 } |
| 3164 | 3164 |
| 3165 virtual void DidActivatePendingTree() OVERRIDE { | 3165 virtual void DidActivatePendingTree() OVERRIDE { |
| 3166 did_activate_pending_tree_ = true; | 3166 did_activate_pending_tree_ = true; |
| 3167 } | 3167 } |
| 3168 | 3168 |
| 3169 void set_gutter_quad_material(DrawQuad::Material material) { | 3169 void set_gutter_quad_material(DrawQuad::Material material) { |
| 3170 gutter_quad_material_ = material; | 3170 gutter_quad_material_ = material; |
| 3171 } | 3171 } |
| 3172 void set_gutter_texture_size(const gfx::Size& gutter_texture_size) { | 3172 void set_gutter_texture_size(gfx::Size gutter_texture_size) { |
| 3173 gutter_texture_size_ = gutter_texture_size; | 3173 gutter_texture_size_ = gutter_texture_size; |
| 3174 } | 3174 } |
| 3175 | 3175 |
| 3176 protected: | 3176 protected: |
| 3177 size_t CountGutterQuads(const QuadList& quad_list) { | 3177 size_t CountGutterQuads(const QuadList& quad_list) { |
| 3178 size_t num_gutter_quads = 0; | 3178 size_t num_gutter_quads = 0; |
| 3179 for (size_t i = 0; i < quad_list.size(); ++i) { | 3179 for (size_t i = 0; i < quad_list.size(); ++i) { |
| 3180 num_gutter_quads += (quad_list[i]->material == | 3180 num_gutter_quads += (quad_list[i]->material == |
| 3181 gutter_quad_material_) ? 1 : 0; | 3181 gutter_quad_material_) ? 1 : 0; |
| 3182 } | 3182 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3200 quad->rect.x() / gutter_texture_size_pixels.width()); | 3200 quad->rect.x() / gutter_texture_size_pixels.width()); |
| 3201 EXPECT_EQ(quad->uv_top_left.y(), | 3201 EXPECT_EQ(quad->uv_top_left.y(), |
| 3202 quad->rect.y() / gutter_texture_size_pixels.height()); | 3202 quad->rect.y() / gutter_texture_size_pixels.height()); |
| 3203 EXPECT_EQ(quad->uv_bottom_right.x(), | 3203 EXPECT_EQ(quad->uv_bottom_right.x(), |
| 3204 quad->rect.right() / gutter_texture_size_pixels.width()); | 3204 quad->rect.right() / gutter_texture_size_pixels.width()); |
| 3205 EXPECT_EQ(quad->uv_bottom_right.y(), | 3205 EXPECT_EQ(quad->uv_bottom_right.y(), |
| 3206 quad->rect.bottom() / gutter_texture_size_pixels.height()); | 3206 quad->rect.bottom() / gutter_texture_size_pixels.height()); |
| 3207 } | 3207 } |
| 3208 } | 3208 } |
| 3209 | 3209 |
| 3210 gfx::Size DipSizeToPixelSize(const gfx::Size& size) { | 3210 gfx::Size DipSizeToPixelSize(gfx::Size size) { |
| 3211 return gfx::ToRoundedSize( | 3211 return gfx::ToRoundedSize( |
| 3212 gfx::ScaleSize(size, host_impl_->device_scale_factor())); | 3212 gfx::ScaleSize(size, host_impl_->device_scale_factor())); |
| 3213 } | 3213 } |
| 3214 | 3214 |
| 3215 DrawQuad::Material gutter_quad_material_; | 3215 DrawQuad::Material gutter_quad_material_; |
| 3216 gfx::Size gutter_texture_size_; | 3216 gfx::Size gutter_texture_size_; |
| 3217 gfx::Size viewport_size_; | 3217 gfx::Size viewport_size_; |
| 3218 BlendStateCheckLayer* child_; | 3218 BlendStateCheckLayer* child_; |
| 3219 bool did_activate_pending_tree_; | 3219 bool did_activate_pending_tree_; |
| 3220 }; | 3220 }; |
| (...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5453 &set_needs_redraw_count)); | 5453 &set_needs_redraw_count)); |
| 5454 // Empty damage rect won't signal the monitor. | 5454 // Empty damage rect won't signal the monitor. |
| 5455 host_impl_->SetNeedsRedrawRect(gfx::Rect()); | 5455 host_impl_->SetNeedsRedrawRect(gfx::Rect()); |
| 5456 EXPECT_EQ(0, set_needs_commit_count); | 5456 EXPECT_EQ(0, set_needs_commit_count); |
| 5457 EXPECT_EQ(2, set_needs_redraw_count); | 5457 EXPECT_EQ(2, set_needs_redraw_count); |
| 5458 } | 5458 } |
| 5459 } | 5459 } |
| 5460 | 5460 |
| 5461 } // namespace | 5461 } // namespace |
| 5462 } // namespace cc | 5462 } // namespace cc |
| OLD | NEW |