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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1144523003: Rename cc::ResourceProvider::ResourceId to cc::ResourceId and move it to its own file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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
OLDNEW
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
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
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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
6027 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); 6027 scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d();
6028 CreateHostImpl(DefaultSettings(), output_surface.Pass()); 6028 CreateHostImpl(DefaultSettings(), output_surface.Pass());
6029 6029
6030 EXPECT_EQ(0u, context3d->NumTextures()); 6030 EXPECT_EQ(0u, context3d->NumTextures());
6031 6031
6032 UIResourceId ui_resource_id = 1; 6032 UIResourceId ui_resource_id = 1;
6033 bool is_opaque = false; 6033 bool is_opaque = false;
6034 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque); 6034 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque);
6035 host_impl_->CreateUIResource(ui_resource_id, bitmap); 6035 host_impl_->CreateUIResource(ui_resource_id, bitmap);
6036 EXPECT_EQ(1u, context3d->NumTextures()); 6036 EXPECT_EQ(1u, context3d->NumTextures());
6037 ResourceProvider::ResourceId id1 = 6037 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id);
6038 host_impl_->ResourceIdForUIResource(ui_resource_id);
6039 EXPECT_NE(0u, id1); 6038 EXPECT_NE(0u, id1);
6040 6039
6041 // Multiple requests with the same id is allowed. The previous texture is 6040 // Multiple requests with the same id is allowed. The previous texture is
6042 // deleted. 6041 // deleted.
6043 host_impl_->CreateUIResource(ui_resource_id, bitmap); 6042 host_impl_->CreateUIResource(ui_resource_id, bitmap);
6044 EXPECT_EQ(1u, context3d->NumTextures()); 6043 EXPECT_EQ(1u, context3d->NumTextures());
6045 ResourceProvider::ResourceId id2 = 6044 ResourceId id2 = host_impl_->ResourceIdForUIResource(ui_resource_id);
6046 host_impl_->ResourceIdForUIResource(ui_resource_id);
6047 EXPECT_NE(0u, id2); 6045 EXPECT_NE(0u, id2);
6048 EXPECT_NE(id1, id2); 6046 EXPECT_NE(id1, id2);
6049 6047
6050 // Deleting invalid UIResourceId is allowed and does not change state. 6048 // Deleting invalid UIResourceId is allowed and does not change state.
6051 host_impl_->DeleteUIResource(-1); 6049 host_impl_->DeleteUIResource(-1);
6052 EXPECT_EQ(1u, context3d->NumTextures()); 6050 EXPECT_EQ(1u, context3d->NumTextures());
6053 6051
6054 // Should return zero for invalid UIResourceId. Number of textures should 6052 // Should return zero for invalid UIResourceId. Number of textures should
6055 // not change. 6053 // not change.
6056 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(-1)); 6054 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(-1));
(...skipping 22 matching lines...) Expand all
6079 // correct width/height are passed directly to UIResourceBitmap. 6077 // correct width/height are passed directly to UIResourceBitmap.
6080 SkImageInfo info = 6078 SkImageInfo info =
6081 SkImageInfo::Make(4, 2, kAlpha_8_SkColorType, kPremul_SkAlphaType); 6079 SkImageInfo::Make(4, 2, kAlpha_8_SkColorType, kPremul_SkAlphaType);
6082 skia::RefPtr<SkPixelRef> pixel_ref = 6080 skia::RefPtr<SkPixelRef> pixel_ref =
6083 skia::AdoptRef(SkMallocPixelRef::NewAllocate(info, 0, 0)); 6081 skia::AdoptRef(SkMallocPixelRef::NewAllocate(info, 0, 0));
6084 pixel_ref->setImmutable(); 6082 pixel_ref->setImmutable();
6085 UIResourceBitmap bitmap(pixel_ref, size); 6083 UIResourceBitmap bitmap(pixel_ref, size);
6086 UIResourceId ui_resource_id = 1; 6084 UIResourceId ui_resource_id = 1;
6087 host_impl_->CreateUIResource(ui_resource_id, bitmap); 6085 host_impl_->CreateUIResource(ui_resource_id, bitmap);
6088 EXPECT_EQ(1u, context3d->NumTextures()); 6086 EXPECT_EQ(1u, context3d->NumTextures());
6089 ResourceProvider::ResourceId id1 = 6087 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id);
6090 host_impl_->ResourceIdForUIResource(ui_resource_id);
6091 EXPECT_NE(0u, id1); 6088 EXPECT_NE(0u, id1);
6092 } 6089 }
6093 6090
6094 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) { 6091 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) {
6095 } 6092 }
6096 6093
6097 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { 6094 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) {
6098 scoped_refptr<TestContextProvider> context_provider = 6095 scoped_refptr<TestContextProvider> context_provider =
6099 TestContextProvider::Create(); 6096 TestContextProvider::Create();
6100 6097
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after
7780 host_impl_->set_has_gpu_rasterization_trigger(false); 7777 host_impl_->set_has_gpu_rasterization_trigger(false);
7781 host_impl_->set_content_is_suitable_for_gpu_rasterization(false); 7778 host_impl_->set_content_is_suitable_for_gpu_rasterization(false);
7782 host_impl_->UpdateGpuRasterizationStatus(); 7779 host_impl_->UpdateGpuRasterizationStatus();
7783 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, 7780 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED,
7784 host_impl_->gpu_rasterization_status()); 7781 host_impl_->gpu_rasterization_status());
7785 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 7782 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
7786 } 7783 }
7787 7784
7788 } // namespace 7785 } // namespace
7789 } // namespace cc 7786 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698