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

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

Issue 41903003: cc: Fix incomplete changes to add ETC1 support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased and moved pixel ref class to public cc Created 7 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
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 <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 16 matching lines...) Expand all
27 #include "cc/output/begin_frame_args.h" 27 #include "cc/output/begin_frame_args.h"
28 #include "cc/output/compositor_frame_ack.h" 28 #include "cc/output/compositor_frame_ack.h"
29 #include "cc/output/compositor_frame_metadata.h" 29 #include "cc/output/compositor_frame_metadata.h"
30 #include "cc/output/copy_output_request.h" 30 #include "cc/output/copy_output_request.h"
31 #include "cc/output/copy_output_result.h" 31 #include "cc/output/copy_output_result.h"
32 #include "cc/output/gl_renderer.h" 32 #include "cc/output/gl_renderer.h"
33 #include "cc/quads/render_pass_draw_quad.h" 33 #include "cc/quads/render_pass_draw_quad.h"
34 #include "cc/quads/solid_color_draw_quad.h" 34 #include "cc/quads/solid_color_draw_quad.h"
35 #include "cc/quads/texture_draw_quad.h" 35 #include "cc/quads/texture_draw_quad.h"
36 #include "cc/quads/tile_draw_quad.h" 36 #include "cc/quads/tile_draw_quad.h"
37 #include "cc/resources/etc1_pixel_ref.h"
37 #include "cc/resources/layer_tiling_data.h" 38 #include "cc/resources/layer_tiling_data.h"
38 #include "cc/test/animation_test_common.h" 39 #include "cc/test/animation_test_common.h"
39 #include "cc/test/fake_layer_tree_host_impl.h" 40 #include "cc/test/fake_layer_tree_host_impl.h"
40 #include "cc/test/fake_output_surface.h" 41 #include "cc/test/fake_output_surface.h"
41 #include "cc/test/fake_output_surface_client.h" 42 #include "cc/test/fake_output_surface_client.h"
42 #include "cc/test/fake_picture_layer_impl.h" 43 #include "cc/test/fake_picture_layer_impl.h"
43 #include "cc/test/fake_picture_pile_impl.h" 44 #include "cc/test/fake_picture_pile_impl.h"
44 #include "cc/test/fake_proxy.h" 45 #include "cc/test/fake_proxy.h"
45 #include "cc/test/fake_rendering_stats_instrumentation.h" 46 #include "cc/test/fake_rendering_stats_instrumentation.h"
46 #include "cc/test/fake_video_frame_provider.h" 47 #include "cc/test/fake_video_frame_provider.h"
(...skipping 5117 matching lines...) Expand 10 before | Expand all | Expand 10 after
5164 5165
5165 host_impl_->DeleteUIResource(ui_resource_id); 5166 host_impl_->DeleteUIResource(ui_resource_id);
5166 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); 5167 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id));
5167 EXPECT_EQ(0u, context3d->NumTextures()); 5168 EXPECT_EQ(0u, context3d->NumTextures());
5168 5169
5169 // Should not change state for multiple deletion on one UIResourceId 5170 // Should not change state for multiple deletion on one UIResourceId
5170 host_impl_->DeleteUIResource(ui_resource_id); 5171 host_impl_->DeleteUIResource(ui_resource_id);
5171 EXPECT_EQ(0u, context3d->NumTextures()); 5172 EXPECT_EQ(0u, context3d->NumTextures());
5172 } 5173 }
5173 5174
5175 TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) {
5176 scoped_ptr<TestWebGraphicsContext3D> context =
5177 TestWebGraphicsContext3D::Create();
5178 TestWebGraphicsContext3D* context3d = context.get();
5179 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface();
5180 host_impl_->InitializeRenderer(output_surface.Pass());
5181
5182 EXPECT_EQ(0u, context3d->NumTextures());
5183
5184 scoped_ptr<uint8_t[]> pixels(new uint8_t[8]);
5185 skia::RefPtr<ETC1PixelRef> etc1_pixel_ref =
5186 skia::AdoptRef(new ETC1PixelRef(pixels.Pass()));
5187 UIResourceBitmap bitmap(etc1_pixel_ref, gfx::Size(4, 4));
5188
5189 UIResourceId ui_resource_id = 1;
5190 host_impl_->CreateUIResource(ui_resource_id, bitmap);
5191 EXPECT_EQ(1u, context3d->NumTextures());
5192 ResourceProvider::ResourceId id1 =
5193 host_impl_->ResourceIdForUIResource(ui_resource_id);
5194 EXPECT_NE(0u, id1);
5195 }
5196
5174 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) { 5197 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) {
5175 } 5198 }
5176 5199
5177 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { 5200 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) {
5178 scoped_refptr<TestContextProvider> context_provider = 5201 scoped_refptr<TestContextProvider> context_provider =
5179 TestContextProvider::Create(); 5202 TestContextProvider::Create();
5180 5203
5181 host_impl_ = LayerTreeHostImpl::Create( 5204 host_impl_ = LayerTreeHostImpl::Create(
5182 LayerTreeSettings(), this, &proxy_, &stats_instrumentation_, NULL); 5205 LayerTreeSettings(), this, &proxy_, &stats_instrumentation_, NULL);
5183 host_impl_->InitializeRenderer(FakeOutputSurface::Create3d(context_provider) 5206 host_impl_->InitializeRenderer(FakeOutputSurface::Create3d(context_provider)
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
5329 // The root should have scrolled. 5352 // The root should have scrolled.
5330 ASSERT_EQ(2u, scroll_info->scrolls.size()); 5353 ASSERT_EQ(2u, scroll_info->scrolls.size());
5331 ExpectContains(*scroll_info.get(), 5354 ExpectContains(*scroll_info.get(),
5332 host_impl_->active_tree()->root_layer()->id(), 5355 host_impl_->active_tree()->root_layer()->id(),
5333 gfx::Vector2d(0, 10)); 5356 gfx::Vector2d(0, 10));
5334 } 5357 }
5335 } 5358 }
5336 5359
5337 } // namespace 5360 } // namespace
5338 } // namespace cc 5361 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698