| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // This has to be included first. | 5 // This has to be included first. |
| 6 // See http://code.google.com/p/googletest/issues/detail?id=371 | 6 // See http://code.google.com/p/googletest/issues/detail?id=371 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 } | 389 } |
| 390 | 390 |
| 391 bool JpegDecodeAcceleratorTestEnvironment::CreateTestJpegImage( | 391 bool JpegDecodeAcceleratorTestEnvironment::CreateTestJpegImage( |
| 392 int width, | 392 int width, |
| 393 int height, | 393 int height, |
| 394 base::FilePath* filename) { | 394 base::FilePath* filename) { |
| 395 const int kBytesPerPixel = 4; | 395 const int kBytesPerPixel = 4; |
| 396 const int kJpegQuality = 100; | 396 const int kJpegQuality = 100; |
| 397 std::vector<unsigned char> input_buffer(width * height * kBytesPerPixel); | 397 std::vector<unsigned char> input_buffer(width * height * kBytesPerPixel); |
| 398 std::vector<unsigned char> encoded; | 398 std::vector<unsigned char> encoded; |
| 399 if (!gfx::JPEGCodec::Encode(&input_buffer[0], gfx::JPEGCodec::FORMAT_RGBA, | 399 SkImageInfo info = SkImageInfo::Make(width, height, kRGBA_8888_SkColorType, |
| 400 width, height, width * kBytesPerPixel, | 400 kOpaque_SkAlphaType); |
| 401 kJpegQuality, &encoded)) { | 401 SkPixmap src(info, &input_buffer[0], width * kBytesPerPixel); |
| 402 if (!gfx::JPEGCodec::Encode(src, kJpegQuality, &encoded)) { |
| 402 return false; | 403 return false; |
| 403 } | 404 } |
| 404 | 405 |
| 405 LOG_ASSERT(base::CreateTemporaryFile(filename)); | 406 LOG_ASSERT(base::CreateTemporaryFile(filename)); |
| 406 EXPECT_TRUE(base::AppendToFile( | 407 EXPECT_TRUE(base::AppendToFile( |
| 407 *filename, reinterpret_cast<char*>(&encoded[0]), encoded.size())); | 408 *filename, reinterpret_cast<char*>(&encoded[0]), encoded.size())); |
| 408 return true; | 409 return true; |
| 409 } | 410 } |
| 410 | 411 |
| 411 void JpegDecodeAcceleratorTestEnvironment::ReadTestJpegImage( | 412 void JpegDecodeAcceleratorTestEnvironment::ReadTestJpegImage( |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 584 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 584 media::VaapiWrapper::PreSandboxInitialization(); | 585 media::VaapiWrapper::PreSandboxInitialization(); |
| 585 #endif | 586 #endif |
| 586 | 587 |
| 587 media::g_env = reinterpret_cast<media::JpegDecodeAcceleratorTestEnvironment*>( | 588 media::g_env = reinterpret_cast<media::JpegDecodeAcceleratorTestEnvironment*>( |
| 588 testing::AddGlobalTestEnvironment( | 589 testing::AddGlobalTestEnvironment( |
| 589 new media::JpegDecodeAcceleratorTestEnvironment(jpeg_filenames))); | 590 new media::JpegDecodeAcceleratorTestEnvironment(jpeg_filenames))); |
| 590 | 591 |
| 591 return RUN_ALL_TESTS(); | 592 return RUN_ALL_TESTS(); |
| 592 } | 593 } |
| OLD | NEW |