| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 TEST_F(VideoResourceUpdaterTest, SoftwareFrame) { | 246 TEST_F(VideoResourceUpdaterTest, SoftwareFrame) { |
| 247 VideoResourceUpdater updater(context_provider_.get(), | 247 VideoResourceUpdater updater(context_provider_.get(), |
| 248 resource_provider3d_.get()); | 248 resource_provider3d_.get()); |
| 249 scoped_refptr<media::VideoFrame> video_frame = CreateTestYUVVideoFrame(); | 249 scoped_refptr<media::VideoFrame> video_frame = CreateTestYUVVideoFrame(); |
| 250 | 250 |
| 251 VideoFrameExternalResources resources = | 251 VideoFrameExternalResources resources = |
| 252 updater.CreateExternalResourcesFromVideoFrame(video_frame); | 252 updater.CreateExternalResourcesFromVideoFrame(video_frame); |
| 253 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); | 253 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); |
| 254 } | 254 } |
| 255 | 255 |
| 256 TEST_F(VideoResourceUpdaterTest, HighBitFrameNoF16) { | 256 TEST_F(VideoResourceUpdaterTest, HighBitFrameNo16bitTexture) { |
| 257 VideoResourceUpdater updater(context_provider_.get(), | 257 VideoResourceUpdater updater(context_provider_.get(), |
| 258 resource_provider3d_.get()); | 258 resource_provider3d_.get()); |
| 259 scoped_refptr<media::VideoFrame> video_frame = CreateTestHighBitFrame(); | 259 scoped_refptr<media::VideoFrame> video_frame = CreateTestHighBitFrame(); |
| 260 | 260 |
| 261 VideoFrameExternalResources resources = | 261 VideoFrameExternalResources resources = |
| 262 updater.CreateExternalResourcesFromVideoFrame(video_frame); | 262 updater.CreateExternalResourcesFromVideoFrame(video_frame); |
| 263 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); | 263 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); |
| 264 } | 264 } |
| 265 | 265 |
| 266 class VideoResourceUpdaterTestWithF16 : public VideoResourceUpdaterTest { | 266 class VideoResourceUpdaterTestWithF16 : public VideoResourceUpdaterTest { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 283 | 283 |
| 284 // Create the resource again, to test the path where the | 284 // Create the resource again, to test the path where the |
| 285 // resources are cached. | 285 // resources are cached. |
| 286 VideoFrameExternalResources resources2 = | 286 VideoFrameExternalResources resources2 = |
| 287 updater.CreateExternalResourcesFromVideoFrame(video_frame); | 287 updater.CreateExternalResourcesFromVideoFrame(video_frame); |
| 288 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources2.type); | 288 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources2.type); |
| 289 EXPECT_NEAR(resources2.multiplier, 2.0, 0.1); | 289 EXPECT_NEAR(resources2.multiplier, 2.0, 0.1); |
| 290 EXPECT_NEAR(resources2.offset, 0.5, 0.1); | 290 EXPECT_NEAR(resources2.offset, 0.5, 0.1); |
| 291 } | 291 } |
| 292 | 292 |
| 293 class VideoResourceUpdaterTestWithRG : public VideoResourceUpdaterTest { |
| 294 public: |
| 295 VideoResourceUpdaterTestWithRG() : VideoResourceUpdaterTest() { |
| 296 context3d_->set_support_texture_rg(true); |
| 297 } |
| 298 }; |
| 299 |
| 300 TEST_F(VideoResourceUpdaterTestWithRG, HighBitFrame) { |
| 301 VideoResourceUpdater updater(context_provider_.get(), |
| 302 resource_provider3d_.get()); |
| 303 scoped_refptr<media::VideoFrame> video_frame = CreateTestHighBitFrame(); |
| 304 |
| 305 VideoFrameExternalResources resources = |
| 306 updater.CreateExternalResourcesFromVideoFrame(video_frame); |
| 307 EXPECT_EQ(VideoFrameExternalResources::YUV_RESOURCE, resources.type); |
| 308 } |
| 309 |
| 293 TEST_F(VideoResourceUpdaterTest, HighBitFrameSoftwareCompositor) { | 310 TEST_F(VideoResourceUpdaterTest, HighBitFrameSoftwareCompositor) { |
| 294 VideoResourceUpdater updater(nullptr, resource_provider_software_.get()); | 311 VideoResourceUpdater updater(nullptr, resource_provider_software_.get()); |
| 295 scoped_refptr<media::VideoFrame> video_frame = CreateTestHighBitFrame(); | 312 scoped_refptr<media::VideoFrame> video_frame = CreateTestHighBitFrame(); |
| 296 | 313 |
| 297 VideoFrameExternalResources resources = | 314 VideoFrameExternalResources resources = |
| 298 updater.CreateExternalResourcesFromVideoFrame(video_frame); | 315 updater.CreateExternalResourcesFromVideoFrame(video_frame); |
| 299 EXPECT_EQ(VideoFrameExternalResources::SOFTWARE_RESOURCE, resources.type); | 316 EXPECT_EQ(VideoFrameExternalResources::SOFTWARE_RESOURCE, resources.type); |
| 300 } | 317 } |
| 301 | 318 |
| 302 TEST_F(VideoResourceUpdaterTest, WonkySoftwareFrame) { | 319 TEST_F(VideoResourceUpdaterTest, WonkySoftwareFrame) { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 FromHalfFloat(half_floats[i] + 1) - FromHalfFloat(half_floats[i]); | 575 FromHalfFloat(half_floats[i] + 1) - FromHalfFloat(half_floats[i]); |
| 559 EXPECT_NEAR(FromHalfFloat(half_floats[i]), integers[i] * multiplier, | 576 EXPECT_NEAR(FromHalfFloat(half_floats[i]), integers[i] * multiplier, |
| 560 expected_precision) | 577 expected_precision) |
| 561 << "i = " << i << " bits = " << bits; | 578 << "i = " << i << " bits = " << bits; |
| 562 } | 579 } |
| 563 } | 580 } |
| 564 } | 581 } |
| 565 | 582 |
| 566 } // namespace | 583 } // namespace |
| 567 } // namespace cc | 584 } // namespace cc |
| OLD | NEW |