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 17 matching lines...) Expand all Loading... |
28 #include "cc/output/begin_frame_args.h" | 28 #include "cc/output/begin_frame_args.h" |
29 #include "cc/output/compositor_frame_ack.h" | 29 #include "cc/output/compositor_frame_ack.h" |
30 #include "cc/output/compositor_frame_metadata.h" | 30 #include "cc/output/compositor_frame_metadata.h" |
31 #include "cc/output/copy_output_request.h" | 31 #include "cc/output/copy_output_request.h" |
32 #include "cc/output/copy_output_result.h" | 32 #include "cc/output/copy_output_result.h" |
33 #include "cc/output/gl_renderer.h" | 33 #include "cc/output/gl_renderer.h" |
34 #include "cc/quads/render_pass_draw_quad.h" | 34 #include "cc/quads/render_pass_draw_quad.h" |
35 #include "cc/quads/solid_color_draw_quad.h" | 35 #include "cc/quads/solid_color_draw_quad.h" |
36 #include "cc/quads/texture_draw_quad.h" | 36 #include "cc/quads/texture_draw_quad.h" |
37 #include "cc/quads/tile_draw_quad.h" | 37 #include "cc/quads/tile_draw_quad.h" |
38 #include "cc/resources/etc1_pixel_ref.h" | |
39 #include "cc/resources/layer_tiling_data.h" | 38 #include "cc/resources/layer_tiling_data.h" |
40 #include "cc/test/animation_test_common.h" | 39 #include "cc/test/animation_test_common.h" |
41 #include "cc/test/fake_layer_tree_host_impl.h" | 40 #include "cc/test/fake_layer_tree_host_impl.h" |
42 #include "cc/test/fake_output_surface.h" | 41 #include "cc/test/fake_output_surface.h" |
43 #include "cc/test/fake_output_surface_client.h" | 42 #include "cc/test/fake_output_surface_client.h" |
44 #include "cc/test/fake_picture_layer_impl.h" | 43 #include "cc/test/fake_picture_layer_impl.h" |
45 #include "cc/test/fake_picture_pile_impl.h" | 44 #include "cc/test/fake_picture_pile_impl.h" |
46 #include "cc/test/fake_proxy.h" | 45 #include "cc/test/fake_proxy.h" |
47 #include "cc/test/fake_rendering_stats_instrumentation.h" | 46 #include "cc/test/fake_rendering_stats_instrumentation.h" |
48 #include "cc/test/fake_video_frame_provider.h" | 47 #include "cc/test/fake_video_frame_provider.h" |
49 #include "cc/test/geometry_test_utils.h" | 48 #include "cc/test/geometry_test_utils.h" |
50 #include "cc/test/layer_test_common.h" | 49 #include "cc/test/layer_test_common.h" |
51 #include "cc/test/render_pass_test_common.h" | 50 #include "cc/test/render_pass_test_common.h" |
52 #include "cc/test/test_web_graphics_context_3d.h" | 51 #include "cc/test/test_web_graphics_context_3d.h" |
53 #include "cc/trees/layer_tree_impl.h" | 52 #include "cc/trees/layer_tree_impl.h" |
54 #include "cc/trees/single_thread_proxy.h" | 53 #include "cc/trees/single_thread_proxy.h" |
55 #include "media/base/media.h" | 54 #include "media/base/media.h" |
56 #include "testing/gmock/include/gmock/gmock.h" | 55 #include "testing/gmock/include/gmock/gmock.h" |
57 #include "testing/gtest/include/gtest/gtest.h" | 56 #include "testing/gtest/include/gtest/gtest.h" |
| 57 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
58 #include "ui/gfx/frame_time.h" | 58 #include "ui/gfx/frame_time.h" |
59 #include "ui/gfx/rect_conversions.h" | 59 #include "ui/gfx/rect_conversions.h" |
60 #include "ui/gfx/size_conversions.h" | 60 #include "ui/gfx/size_conversions.h" |
61 #include "ui/gfx/vector2d_conversions.h" | 61 #include "ui/gfx/vector2d_conversions.h" |
62 | 62 |
63 using ::testing::Mock; | 63 using ::testing::Mock; |
64 using ::testing::Return; | 64 using ::testing::Return; |
65 using ::testing::AnyNumber; | 65 using ::testing::AnyNumber; |
66 using ::testing::AtLeast; | 66 using ::testing::AtLeast; |
67 using ::testing::_; | 67 using ::testing::_; |
(...skipping 5078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5146 | 5146 |
5147 TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) { | 5147 TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) { |
5148 scoped_ptr<TestWebGraphicsContext3D> context = | 5148 scoped_ptr<TestWebGraphicsContext3D> context = |
5149 TestWebGraphicsContext3D::Create(); | 5149 TestWebGraphicsContext3D::Create(); |
5150 TestWebGraphicsContext3D* context3d = context.get(); | 5150 TestWebGraphicsContext3D* context3d = context.get(); |
5151 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface(); | 5151 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface(); |
5152 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 5152 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
5153 | 5153 |
5154 EXPECT_EQ(0u, context3d->NumTextures()); | 5154 EXPECT_EQ(0u, context3d->NumTextures()); |
5155 | 5155 |
5156 SkImageInfo info = {4, 4, kPMColor_SkColorType, kPremul_SkAlphaType}; | 5156 SkImageInfo info = |
5157 size_t rowBytes = info.minRowBytes(); | 5157 SkImageInfo::Make(4, 4, kPMColor_SkColorType, kPremul_SkAlphaType); |
5158 scoped_ptr<uint8_t[]> pixels(new uint8_t[rowBytes * info.fHeight]); | 5158 skia::RefPtr<SkPixelRef> pixel_ref = |
5159 skia::RefPtr<ETC1PixelRef> etc1_pixel_ref = | 5159 skia::AdoptRef(SkMallocPixelRef::NewAllocate(info, 0, 0)); |
5160 skia::AdoptRef(new ETC1PixelRef(info, rowBytes, pixels.Pass())); | 5160 pixel_ref->setImmutable(); |
5161 UIResourceBitmap bitmap(etc1_pixel_ref, gfx::Size(info.fWidth, info.fHeight)); | 5161 UIResourceBitmap bitmap(pixel_ref); |
5162 // TODO(powel) Now that pixel_refs have info, the UIResourceBitmap | |
5163 // constructor can get the can size from (pixelref->info().fWidth, | |
5164 // pixelref->info().fHeight). | |
5165 | |
5166 UIResourceId ui_resource_id = 1; | 5162 UIResourceId ui_resource_id = 1; |
5167 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 5163 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
5168 EXPECT_EQ(1u, context3d->NumTextures()); | 5164 EXPECT_EQ(1u, context3d->NumTextures()); |
5169 ResourceProvider::ResourceId id1 = | 5165 ResourceProvider::ResourceId id1 = |
5170 host_impl_->ResourceIdForUIResource(ui_resource_id); | 5166 host_impl_->ResourceIdForUIResource(ui_resource_id); |
5171 EXPECT_NE(0u, id1); | 5167 EXPECT_NE(0u, id1); |
5172 } | 5168 } |
5173 | 5169 |
5174 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) { | 5170 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) { |
5175 } | 5171 } |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5456 &set_needs_redraw_count)); | 5452 &set_needs_redraw_count)); |
5457 // Empty damage rect won't signal the monitor. | 5453 // Empty damage rect won't signal the monitor. |
5458 host_impl_->SetNeedsRedrawRect(gfx::Rect()); | 5454 host_impl_->SetNeedsRedrawRect(gfx::Rect()); |
5459 EXPECT_EQ(0, set_needs_commit_count); | 5455 EXPECT_EQ(0, set_needs_commit_count); |
5460 EXPECT_EQ(2, set_needs_redraw_count); | 5456 EXPECT_EQ(2, set_needs_redraw_count); |
5461 } | 5457 } |
5462 } | 5458 } |
5463 | 5459 |
5464 } // namespace | 5460 } // namespace |
5465 } // namespace cc | 5461 } // namespace cc |
OLD | NEW |