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 <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 4477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4488 SetContentBounds(gfx::Size(10, 10)); | 4488 SetContentBounds(gfx::Size(10, 10)); |
4489 SetDrawsContent(true); | 4489 SetDrawsContent(true); |
4490 } | 4490 } |
4491 | 4491 |
4492 bool blend_; | 4492 bool blend_; |
4493 bool has_render_surface_; | 4493 bool has_render_surface_; |
4494 bool quads_appended_; | 4494 bool quads_appended_; |
4495 gfx::Rect quad_rect_; | 4495 gfx::Rect quad_rect_; |
4496 gfx::Rect opaque_content_rect_; | 4496 gfx::Rect opaque_content_rect_; |
4497 gfx::Rect quad_visible_rect_; | 4497 gfx::Rect quad_visible_rect_; |
4498 ResourceProvider::ResourceId resource_id_; | 4498 ResourceId resource_id_; |
4499 }; | 4499 }; |
4500 | 4500 |
4501 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 4501 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
4502 { | 4502 { |
4503 scoped_ptr<LayerImpl> root = | 4503 scoped_ptr<LayerImpl> root = |
4504 LayerImpl::Create(host_impl_->active_tree(), 1); | 4504 LayerImpl::Create(host_impl_->active_tree(), 1); |
4505 root->SetBounds(gfx::Size(10, 10)); | 4505 root->SetBounds(gfx::Size(10, 10)); |
4506 root->SetContentBounds(root->bounds()); | 4506 root->SetContentBounds(root->bounds()); |
4507 root->SetDrawsContent(false); | 4507 root->SetDrawsContent(false); |
4508 root->SetHasRenderSurface(true); | 4508 root->SetHasRenderSurface(true); |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5675 EXPECT_FALSE(host_impl_->GetRendererCapabilities().allow_rasterize_on_demand); | 5675 EXPECT_FALSE(host_impl_->GetRendererCapabilities().allow_rasterize_on_demand); |
5676 } | 5676 } |
5677 | 5677 |
5678 class FakeMaskLayerImpl : public LayerImpl { | 5678 class FakeMaskLayerImpl : public LayerImpl { |
5679 public: | 5679 public: |
5680 static scoped_ptr<FakeMaskLayerImpl> Create(LayerTreeImpl* tree_impl, | 5680 static scoped_ptr<FakeMaskLayerImpl> Create(LayerTreeImpl* tree_impl, |
5681 int id) { | 5681 int id) { |
5682 return make_scoped_ptr(new FakeMaskLayerImpl(tree_impl, id)); | 5682 return make_scoped_ptr(new FakeMaskLayerImpl(tree_impl, id)); |
5683 } | 5683 } |
5684 | 5684 |
5685 void GetContentsResourceId(ResourceProvider::ResourceId* resource_id, | 5685 void GetContentsResourceId(ResourceId* resource_id, |
5686 gfx::Size* resource_size) const override { | 5686 gfx::Size* resource_size) const override { |
5687 *resource_id = 0; | 5687 *resource_id = 0; |
5688 } | 5688 } |
5689 | 5689 |
5690 private: | 5690 private: |
5691 FakeMaskLayerImpl(LayerTreeImpl* tree_impl, int id) | 5691 FakeMaskLayerImpl(LayerTreeImpl* tree_impl, int id) |
5692 : LayerImpl(tree_impl, id) {} | 5692 : LayerImpl(tree_impl, id) {} |
5693 }; | 5693 }; |
5694 | 5694 |
5695 class GLRendererWithSetupQuadForAntialiasing : public GLRenderer { | 5695 class GLRendererWithSetupQuadForAntialiasing : public GLRenderer { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6025 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); | 6025 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); |
6026 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 6026 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
6027 | 6027 |
6028 EXPECT_EQ(0u, context3d->NumTextures()); | 6028 EXPECT_EQ(0u, context3d->NumTextures()); |
6029 | 6029 |
6030 UIResourceId ui_resource_id = 1; | 6030 UIResourceId ui_resource_id = 1; |
6031 bool is_opaque = false; | 6031 bool is_opaque = false; |
6032 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque); | 6032 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque); |
6033 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 6033 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
6034 EXPECT_EQ(1u, context3d->NumTextures()); | 6034 EXPECT_EQ(1u, context3d->NumTextures()); |
6035 ResourceProvider::ResourceId id1 = | 6035 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); |
6036 host_impl_->ResourceIdForUIResource(ui_resource_id); | |
6037 EXPECT_NE(0u, id1); | 6036 EXPECT_NE(0u, id1); |
6038 | 6037 |
6039 // Multiple requests with the same id is allowed. The previous texture is | 6038 // Multiple requests with the same id is allowed. The previous texture is |
6040 // deleted. | 6039 // deleted. |
6041 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 6040 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
6042 EXPECT_EQ(1u, context3d->NumTextures()); | 6041 EXPECT_EQ(1u, context3d->NumTextures()); |
6043 ResourceProvider::ResourceId id2 = | 6042 ResourceId id2 = host_impl_->ResourceIdForUIResource(ui_resource_id); |
6044 host_impl_->ResourceIdForUIResource(ui_resource_id); | |
6045 EXPECT_NE(0u, id2); | 6043 EXPECT_NE(0u, id2); |
6046 EXPECT_NE(id1, id2); | 6044 EXPECT_NE(id1, id2); |
6047 | 6045 |
6048 // Deleting invalid UIResourceId is allowed and does not change state. | 6046 // Deleting invalid UIResourceId is allowed and does not change state. |
6049 host_impl_->DeleteUIResource(-1); | 6047 host_impl_->DeleteUIResource(-1); |
6050 EXPECT_EQ(1u, context3d->NumTextures()); | 6048 EXPECT_EQ(1u, context3d->NumTextures()); |
6051 | 6049 |
6052 // Should return zero for invalid UIResourceId. Number of textures should | 6050 // Should return zero for invalid UIResourceId. Number of textures should |
6053 // not change. | 6051 // not change. |
6054 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(-1)); | 6052 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(-1)); |
(...skipping 22 matching lines...) Expand all Loading... |
6077 // correct width/height are passed directly to UIResourceBitmap. | 6075 // correct width/height are passed directly to UIResourceBitmap. |
6078 SkImageInfo info = | 6076 SkImageInfo info = |
6079 SkImageInfo::Make(4, 2, kAlpha_8_SkColorType, kPremul_SkAlphaType); | 6077 SkImageInfo::Make(4, 2, kAlpha_8_SkColorType, kPremul_SkAlphaType); |
6080 skia::RefPtr<SkPixelRef> pixel_ref = | 6078 skia::RefPtr<SkPixelRef> pixel_ref = |
6081 skia::AdoptRef(SkMallocPixelRef::NewAllocate(info, 0, 0)); | 6079 skia::AdoptRef(SkMallocPixelRef::NewAllocate(info, 0, 0)); |
6082 pixel_ref->setImmutable(); | 6080 pixel_ref->setImmutable(); |
6083 UIResourceBitmap bitmap(pixel_ref, size); | 6081 UIResourceBitmap bitmap(pixel_ref, size); |
6084 UIResourceId ui_resource_id = 1; | 6082 UIResourceId ui_resource_id = 1; |
6085 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 6083 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
6086 EXPECT_EQ(1u, context3d->NumTextures()); | 6084 EXPECT_EQ(1u, context3d->NumTextures()); |
6087 ResourceProvider::ResourceId id1 = | 6085 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); |
6088 host_impl_->ResourceIdForUIResource(ui_resource_id); | |
6089 EXPECT_NE(0u, id1); | 6086 EXPECT_NE(0u, id1); |
6090 } | 6087 } |
6091 | 6088 |
6092 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) { | 6089 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) { |
6093 } | 6090 } |
6094 | 6091 |
6095 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 6092 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
6096 scoped_refptr<TestContextProvider> context_provider = | 6093 scoped_refptr<TestContextProvider> context_provider = |
6097 TestContextProvider::Create(); | 6094 TestContextProvider::Create(); |
6098 | 6095 |
(...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7772 | 7769 |
7773 host_impl_->SetHasGpuRasterizationTrigger(false); | 7770 host_impl_->SetHasGpuRasterizationTrigger(false); |
7774 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 7771 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
7775 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, | 7772 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, |
7776 host_impl_->gpu_rasterization_status()); | 7773 host_impl_->gpu_rasterization_status()); |
7777 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 7774 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
7778 } | 7775 } |
7779 | 7776 |
7780 } // namespace | 7777 } // namespace |
7781 } // namespace cc | 7778 } // namespace cc |
OLD | NEW |