| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/resources/video_resource_updater.h" | 5 #include "cc/resources/video_resource_updater.h" |
| 6 | 6 |
| 7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
| 8 #include "cc/resources/resource_provider.h" | 8 #include "cc/resources/resource_provider.h" |
| 9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
| 10 #include "cc/test/fake_output_surface_client.h" | 10 #include "cc/test/fake_output_surface_client.h" |
| 11 #include "cc/test/test_shared_bitmap_manager.h" | 11 #include "cc/test/test_shared_bitmap_manager.h" |
| 12 #include "cc/test/test_web_graphics_context_3d.h" | 12 #include "cc/test/test_web_graphics_context_3d.h" |
| 13 #include "cc/trees/blocking_task_runner.h" |
| 13 #include "media/base/video_frame.h" | 14 #include "media/base/video_frame.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 namespace cc { | 17 namespace cc { |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 class VideoResourceUpdaterTest : public testing::Test { | 20 class VideoResourceUpdaterTest : public testing::Test { |
| 20 protected: | 21 protected: |
| 21 VideoResourceUpdaterTest() { | 22 VideoResourceUpdaterTest() { |
| 22 scoped_ptr<TestWebGraphicsContext3D> context3d = | 23 scoped_ptr<TestWebGraphicsContext3D> context3d = |
| 23 TestWebGraphicsContext3D::Create(); | 24 TestWebGraphicsContext3D::Create(); |
| 24 context3d_ = context3d.get(); | 25 context3d_ = context3d.get(); |
| 25 | 26 |
| 26 output_surface3d_ = | 27 output_surface3d_ = |
| 27 FakeOutputSurface::Create3d(context3d.Pass()); | 28 FakeOutputSurface::Create3d(context3d.Pass()); |
| 28 CHECK(output_surface3d_->BindToClient(&client_)); | 29 CHECK(output_surface3d_->BindToClient(&client_)); |
| 29 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 30 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
| 30 resource_provider3d_ = ResourceProvider::Create( | 31 resource_provider3d_ = |
| 31 output_surface3d_.get(), shared_bitmap_manager_.get(), 0, false, 1, | 32 ResourceProvider::Create(output_surface3d_.get(), |
| 32 false); | 33 shared_bitmap_manager_.get(), |
| 34 NULL, |
| 35 0, |
| 36 false, |
| 37 1, |
| 38 false); |
| 33 } | 39 } |
| 34 | 40 |
| 35 scoped_refptr<media::VideoFrame> CreateTestYUVVideoFrame() { | 41 scoped_refptr<media::VideoFrame> CreateTestYUVVideoFrame() { |
| 36 const int kDimension = 10; | 42 const int kDimension = 10; |
| 37 gfx::Size size(kDimension, kDimension); | 43 gfx::Size size(kDimension, kDimension); |
| 38 static uint8 y_data[kDimension * kDimension] = { 0 }; | 44 static uint8 y_data[kDimension * kDimension] = { 0 }; |
| 39 static uint8 u_data[kDimension * kDimension / 2] = { 0 }; | 45 static uint8 u_data[kDimension * kDimension / 2] = { 0 }; |
| 40 static uint8 v_data[kDimension * kDimension / 2] = { 0 }; | 46 static uint8 v_data[kDimension * kDimension / 2] = { 0 }; |
| 41 | 47 |
| 42 return media::VideoFrame::WrapExternalYuvData( | 48 return media::VideoFrame::WrapExternalYuvData( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 66 resource_provider3d_.get()); | 72 resource_provider3d_.get()); |
| 67 scoped_refptr<media::VideoFrame> video_frame = CreateTestYUVVideoFrame(); | 73 scoped_refptr<media::VideoFrame> video_frame = CreateTestYUVVideoFrame(); |
| 68 | 74 |
| 69 VideoFrameExternalResources resources = | 75 VideoFrameExternalResources resources = |
| 70 updater.CreateExternalResourcesFromVideoFrame(video_frame); | 76 updater.CreateExternalResourcesFromVideoFrame(video_frame); |
| 71 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); | 77 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); |
| 72 } | 78 } |
| 73 | 79 |
| 74 } // namespace | 80 } // namespace |
| 75 } // namespace cc | 81 } // namespace cc |
| OLD | NEW |