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 "cc/resources/resource_provider.h" | 7 #include "cc/resources/resource_provider.h" |
8 #include "cc/test/fake_output_surface.h" | 8 #include "cc/test/fake_output_surface.h" |
9 #include "cc/test/fake_output_surface_client.h" | 9 #include "cc/test/fake_output_surface_client.h" |
10 #include "cc/test/fake_resource_provider.h" | 10 #include "cc/test/fake_resource_provider.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 output_surface_software_.get(), shared_bitmap_manager_.get()); | 77 output_surface_software_.get(), shared_bitmap_manager_.get()); |
78 } | 78 } |
79 | 79 |
80 scoped_refptr<media::VideoFrame> CreateTestYUVVideoFrame() { | 80 scoped_refptr<media::VideoFrame> CreateTestYUVVideoFrame() { |
81 const int kDimension = 10; | 81 const int kDimension = 10; |
82 gfx::Size size(kDimension, kDimension); | 82 gfx::Size size(kDimension, kDimension); |
83 static uint8 y_data[kDimension * kDimension] = { 0 }; | 83 static uint8 y_data[kDimension * kDimension] = { 0 }; |
84 static uint8 u_data[kDimension * kDimension / 2] = { 0 }; | 84 static uint8 u_data[kDimension * kDimension / 2] = { 0 }; |
85 static uint8 v_data[kDimension * kDimension / 2] = { 0 }; | 85 static uint8 v_data[kDimension * kDimension / 2] = { 0 }; |
86 | 86 |
87 return media::VideoFrame::WrapExternalYuvData( | 87 scoped_refptr<media::VideoFrame> video_frame = |
88 media::PIXEL_FORMAT_YV16, // format | 88 media::VideoFrame::WrapExternalYuvData( |
89 size, // coded_size | 89 media::PIXEL_FORMAT_YV16, // format |
90 gfx::Rect(size), // visible_rect | 90 size, // coded_size |
91 size, // natural_size | 91 gfx::Rect(size), // visible_rect |
92 size.width(), // y_stride | 92 size, // natural_size |
93 size.width() / 2, // u_stride | 93 size.width(), // y_stride |
94 size.width() / 2, // v_stride | 94 size.width() / 2, // u_stride |
95 y_data, // y_data | 95 size.width() / 2, // v_stride |
96 u_data, // u_data | 96 y_data, // y_data |
97 v_data, // v_data | 97 u_data, // u_data |
98 base::TimeDelta()); // timestamp | 98 v_data, // v_data |
99 base::TimeDelta()); // timestamp | |
100 CHECK(video_frame); | |
101 return video_frame; | |
99 } | 102 } |
100 | 103 |
101 static void ReleaseMailboxCB(const gpu::SyncToken& sync_token) {} | 104 static void ReleaseMailboxCB(const gpu::SyncToken& sync_token) {} |
102 | 105 |
103 scoped_refptr<media::VideoFrame> CreateTestRGBAHardwareVideoFrame() { | 106 scoped_refptr<media::VideoFrame> CreateTestRGBAHardwareVideoFrame() { |
104 const int kDimension = 10; | 107 const int kDimension = 10; |
105 gfx::Size size(kDimension, kDimension); | 108 gfx::Size size(kDimension, kDimension); |
106 | 109 |
107 gpu::Mailbox mailbox; | 110 gpu::Mailbox mailbox; |
108 mailbox.name[0] = 51; | 111 mailbox.name[0] = 51; |
109 | 112 |
110 const gpu::SyncToken sync_token(7); | 113 const gpu::SyncToken sync_token(7); |
111 const unsigned target = GL_TEXTURE_2D; | 114 const unsigned target = GL_TEXTURE_2D; |
112 return media::VideoFrame::WrapNativeTexture( | 115 scoped_refptr<media::VideoFrame> video_frame = |
113 media::PIXEL_FORMAT_ARGB, | 116 media::VideoFrame::WrapNativeTexture( |
114 gpu::MailboxHolder(mailbox, sync_token, target), | 117 media::PIXEL_FORMAT_ARGB, |
115 base::Bind(&ReleaseMailboxCB), | 118 gpu::MailboxHolder(mailbox, sync_token, target), |
116 size, // coded_size | 119 base::Bind(&ReleaseMailboxCB), |
117 gfx::Rect(size), // visible_rect | 120 size, // coded_size |
118 size, // natural_size | 121 gfx::Rect(size), // visible_rect |
119 base::TimeDelta()); // timestamp | 122 size, // natural_size |
123 base::TimeDelta()); // timestamp | |
124 CHECK(video_frame); | |
125 return video_frame; | |
120 } | 126 } |
121 | 127 |
122 scoped_refptr<media::VideoFrame> CreateTestYUVHardareVideoFrame() { | 128 scoped_refptr<media::VideoFrame> CreateTestYUVHardareVideoFrame() { |
123 const int kDimension = 10; | 129 const int kDimension = 10; |
124 gfx::Size size(kDimension, kDimension); | 130 gfx::Size size(kDimension, kDimension); |
125 | 131 |
126 const int kPlanesNum = 3; | 132 const int kPlanesNum = 3; |
127 gpu::Mailbox mailbox[kPlanesNum]; | 133 gpu::Mailbox mailbox[kPlanesNum]; |
128 for (int i = 0; i < kPlanesNum; ++i) { | 134 for (int i = 0; i < kPlanesNum; ++i) { |
129 mailbox[i].name[0] = 50 + 1; | 135 mailbox[i].name[0] = 50 + 1; |
130 } | 136 } |
131 const gpu::SyncToken sync_token(7); | 137 const gpu::SyncToken sync_token(7); |
132 const unsigned target = GL_TEXTURE_RECTANGLE_ARB; | 138 const unsigned target = GL_TEXTURE_RECTANGLE_ARB; |
133 return media::VideoFrame::WrapYUV420NativeTextures( | 139 scoped_refptr<media::VideoFrame> video_frame = |
134 gpu::MailboxHolder(mailbox[media::VideoFrame::kYPlane], sync_token, | 140 media::VideoFrame::WrapYUV420NativeTextures( |
135 target), | 141 gpu::MailboxHolder(mailbox[media::VideoFrame::kYPlane], sync_token, |
136 gpu::MailboxHolder(mailbox[media::VideoFrame::kUPlane], sync_token, | 142 target), |
137 target), | 143 gpu::MailboxHolder(mailbox[media::VideoFrame::kUPlane], sync_token, |
138 gpu::MailboxHolder(mailbox[media::VideoFrame::kVPlane], sync_token, | 144 target), |
139 target), | 145 gpu::MailboxHolder(mailbox[media::VideoFrame::kVPlane], sync_token, |
140 base::Bind(&ReleaseMailboxCB), | 146 target), |
141 size, // coded_size | 147 base::Bind(&ReleaseMailboxCB), |
142 gfx::Rect(size), // visible_rect | 148 size, // coded_size |
143 size, // natural_size | 149 gfx::Rect(size), // visible_rect |
144 base::TimeDelta()); // timestamp | 150 size, // natural_size |
151 base::TimeDelta()); // timestamp | |
152 CHECK(video_frame); | |
mcasas
2015/12/15 17:14:33
Prefer ASSERT_xx() to CHECK (see last
entry in [1]
emircan
2015/12/16 15:57:10
Thanks, changing all to ASSERT_TRUE.
| |
153 return video_frame; | |
145 } | 154 } |
146 | 155 |
147 WebGraphicsContext3DUploadCounter* context3d_; | 156 WebGraphicsContext3DUploadCounter* context3d_; |
148 FakeOutputSurfaceClient client_; | 157 FakeOutputSurfaceClient client_; |
149 scoped_ptr<FakeOutputSurface> output_surface3d_; | 158 scoped_ptr<FakeOutputSurface> output_surface3d_; |
150 scoped_ptr<FakeOutputSurface> output_surface_software_; | 159 scoped_ptr<FakeOutputSurface> output_surface_software_; |
151 scoped_ptr<SharedBitmapManagerAllocationCounter> shared_bitmap_manager_; | 160 scoped_ptr<SharedBitmapManagerAllocationCounter> shared_bitmap_manager_; |
152 scoped_ptr<ResourceProvider> resource_provider3d_; | 161 scoped_ptr<ResourceProvider> resource_provider3d_; |
153 scoped_ptr<ResourceProvider> resource_provider_software_; | 162 scoped_ptr<ResourceProvider> resource_provider_software_; |
154 }; | 163 }; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 | 316 |
308 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame); | 317 resources = updater.CreateExternalResourcesFromVideoFrame(video_frame); |
309 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); | 318 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); |
310 EXPECT_TRUE(resources.read_lock_fences_enabled); | 319 EXPECT_TRUE(resources.read_lock_fences_enabled); |
311 EXPECT_EQ(3u, resources.mailboxes.size()); | 320 EXPECT_EQ(3u, resources.mailboxes.size()); |
312 EXPECT_EQ(3u, resources.release_callbacks.size()); | 321 EXPECT_EQ(3u, resources.release_callbacks.size()); |
313 EXPECT_EQ(0u, resources.software_resources.size()); | 322 EXPECT_EQ(0u, resources.software_resources.size()); |
314 } | 323 } |
315 } // namespace | 324 } // namespace |
316 } // namespace cc | 325 } // namespace cc |
OLD | NEW |