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 2645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2656 | 2656 |
2657 LayerTestCommon::VerifyQuadsExactlyCoverRect( | 2657 LayerTestCommon::VerifyQuadsExactlyCoverRect( |
2658 frame.render_passes[0]->quad_list, gfx::Rect(viewport_size)); | 2658 frame.render_passes[0]->quad_list, gfx::Rect(viewport_size)); |
2659 host_impl_->DidDrawAllLayers(frame); | 2659 host_impl_->DidDrawAllLayers(frame); |
2660 } | 2660 } |
2661 } | 2661 } |
2662 | 2662 |
2663 | 2663 |
2664 class ReshapeTrackerContext: public TestWebGraphicsContext3D { | 2664 class ReshapeTrackerContext: public TestWebGraphicsContext3D { |
2665 public: | 2665 public: |
2666 ReshapeTrackerContext() : reshape_called_(false) {} | 2666 ReshapeTrackerContext() |
| 2667 : reshape_called_(false), |
| 2668 last_reshape_width_(-1), |
| 2669 last_reshape_height_(-1), |
| 2670 last_reshape_scale_factor_(-1.f) { |
| 2671 } |
2667 | 2672 |
2668 virtual void reshape(int width, int height) OVERRIDE { | 2673 virtual void reshapeWithScaleFactor( |
| 2674 int width, int height, float scale_factor) OVERRIDE { |
2669 reshape_called_ = true; | 2675 reshape_called_ = true; |
| 2676 last_reshape_width_ = width; |
| 2677 last_reshape_height_ = height; |
| 2678 last_reshape_scale_factor_ = scale_factor; |
2670 } | 2679 } |
2671 | 2680 |
2672 bool reshape_called() const { return reshape_called_; } | 2681 bool reshape_called() const { return reshape_called_; } |
| 2682 void clear_reshape_called() { reshape_called_ = false; } |
| 2683 int last_reshape_width() { return last_reshape_width_; } |
| 2684 int last_reshape_height() { return last_reshape_height_; } |
| 2685 int last_reshape_scale_factor() { return last_reshape_scale_factor_; } |
2673 | 2686 |
2674 private: | 2687 private: |
2675 bool reshape_called_; | 2688 bool reshape_called_; |
| 2689 int last_reshape_width_; |
| 2690 int last_reshape_height_; |
| 2691 float last_reshape_scale_factor_; |
2676 }; | 2692 }; |
2677 | 2693 |
2678 class FakeDrawableLayerImpl: public LayerImpl { | 2694 class FakeDrawableLayerImpl: public LayerImpl { |
2679 public: | 2695 public: |
2680 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 2696 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
2681 return scoped_ptr<LayerImpl>(new FakeDrawableLayerImpl(tree_impl, id)); | 2697 return scoped_ptr<LayerImpl>(new FakeDrawableLayerImpl(tree_impl, id)); |
2682 } | 2698 } |
2683 protected: | 2699 protected: |
2684 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) | 2700 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) |
2685 : LayerImpl(tree_impl, id) {} | 2701 : LayerImpl(tree_impl, id) {} |
(...skipping 11 matching lines...) Expand all Loading... |
2697 host_impl_->InitializeRenderer(output_surface.Pass()); | 2713 host_impl_->InitializeRenderer(output_surface.Pass()); |
2698 | 2714 |
2699 scoped_ptr<LayerImpl> root = | 2715 scoped_ptr<LayerImpl> root = |
2700 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 2716 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
2701 root->SetAnchorPoint(gfx::PointF()); | 2717 root->SetAnchorPoint(gfx::PointF()); |
2702 root->SetBounds(gfx::Size(10, 10)); | 2718 root->SetBounds(gfx::Size(10, 10)); |
2703 root->SetContentBounds(gfx::Size(10, 10)); | 2719 root->SetContentBounds(gfx::Size(10, 10)); |
2704 root->SetDrawsContent(true); | 2720 root->SetDrawsContent(true); |
2705 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2721 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
2706 EXPECT_FALSE(reshape_tracker->reshape_called()); | 2722 EXPECT_FALSE(reshape_tracker->reshape_called()); |
| 2723 reshape_tracker->clear_reshape_called(); |
2707 | 2724 |
2708 LayerTreeHostImpl::FrameData frame; | 2725 LayerTreeHostImpl::FrameData frame; |
| 2726 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 2727 host_impl_->SetDeviceScaleFactor(1.f); |
2709 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 2728 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
2710 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); | 2729 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); |
2711 EXPECT_TRUE(reshape_tracker->reshape_called()); | 2730 EXPECT_TRUE(reshape_tracker->reshape_called()); |
| 2731 EXPECT_EQ(reshape_tracker->last_reshape_width(), 10); |
| 2732 EXPECT_EQ(reshape_tracker->last_reshape_height(), 10); |
| 2733 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f); |
2712 host_impl_->DidDrawAllLayers(frame); | 2734 host_impl_->DidDrawAllLayers(frame); |
| 2735 reshape_tracker->clear_reshape_called(); |
| 2736 |
| 2737 host_impl_->SetViewportSize(gfx::Size(20, 30)); |
| 2738 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2739 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); |
| 2740 EXPECT_TRUE(reshape_tracker->reshape_called()); |
| 2741 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20); |
| 2742 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30); |
| 2743 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 1.f); |
| 2744 host_impl_->DidDrawAllLayers(frame); |
| 2745 reshape_tracker->clear_reshape_called(); |
| 2746 |
| 2747 host_impl_->SetDeviceScaleFactor(2.f); |
| 2748 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 2749 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); |
| 2750 EXPECT_TRUE(reshape_tracker->reshape_called()); |
| 2751 EXPECT_EQ(reshape_tracker->last_reshape_width(), 20); |
| 2752 EXPECT_EQ(reshape_tracker->last_reshape_height(), 30); |
| 2753 EXPECT_EQ(reshape_tracker->last_reshape_scale_factor(), 2.f); |
| 2754 host_impl_->DidDrawAllLayers(frame); |
| 2755 reshape_tracker->clear_reshape_called(); |
2713 } | 2756 } |
2714 | 2757 |
2715 class PartialSwapTrackerContext : public TestWebGraphicsContext3D { | 2758 class PartialSwapTrackerContext : public TestWebGraphicsContext3D { |
2716 public: | 2759 public: |
2717 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height) | 2760 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height) |
2718 OVERRIDE { | 2761 OVERRIDE { |
2719 partial_swap_rect_ = gfx::Rect(x, y, width, height); | 2762 partial_swap_rect_ = gfx::Rect(x, y, width, height); |
2720 } | 2763 } |
2721 | 2764 |
2722 virtual WebKit::WebString getString(WebKit::WGC3Denum name) OVERRIDE { | 2765 virtual WebKit::WebString getString(WebKit::WGC3Denum name) OVERRIDE { |
(...skipping 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4500 | 4543 |
4501 virtual bool HaveCachedResourcesForRenderPassId(RenderPass::Id id) const | 4544 virtual bool HaveCachedResourcesForRenderPassId(RenderPass::Id id) const |
4502 OVERRIDE { | 4545 OVERRIDE { |
4503 return textures_.count(id); | 4546 return textures_.count(id); |
4504 } | 4547 } |
4505 | 4548 |
4506 // RendererClient implementation. | 4549 // RendererClient implementation. |
4507 virtual gfx::Size DeviceViewportSize() const OVERRIDE { | 4550 virtual gfx::Size DeviceViewportSize() const OVERRIDE { |
4508 return viewport_size_; | 4551 return viewport_size_; |
4509 } | 4552 } |
| 4553 virtual float DeviceScaleFactor() const OVERRIDE { |
| 4554 return 1.f; |
| 4555 } |
4510 virtual const LayerTreeSettings& Settings() const OVERRIDE { | 4556 virtual const LayerTreeSettings& Settings() const OVERRIDE { |
4511 return settings_; | 4557 return settings_; |
4512 } | 4558 } |
4513 virtual void SetFullRootLayerDamage() OVERRIDE {} | 4559 virtual void SetFullRootLayerDamage() OVERRIDE {} |
4514 virtual void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy) | 4560 virtual void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy) |
4515 OVERRIDE {} | 4561 OVERRIDE {} |
4516 virtual void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) | 4562 virtual void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) |
4517 OVERRIDE {} | 4563 OVERRIDE {} |
4518 virtual bool HasImplThread() const OVERRIDE { return false; } | 4564 virtual bool HasImplThread() const OVERRIDE { return false; } |
4519 virtual bool ShouldClearRootRenderPass() const OVERRIDE { return true; } | 4565 virtual bool ShouldClearRootRenderPass() const OVERRIDE { return true; } |
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5695 EXPECT_EQ(0, software_device->frames_ended_); | 5741 EXPECT_EQ(0, software_device->frames_ended_); |
5696 | 5742 |
5697 DrawFrame(); | 5743 DrawFrame(); |
5698 | 5744 |
5699 EXPECT_EQ(1, software_device->frames_began_); | 5745 EXPECT_EQ(1, software_device->frames_began_); |
5700 EXPECT_EQ(1, software_device->frames_ended_); | 5746 EXPECT_EQ(1, software_device->frames_ended_); |
5701 } | 5747 } |
5702 | 5748 |
5703 } // namespace | 5749 } // namespace |
5704 } // namespace cc | 5750 } // namespace cc |
OLD | NEW |