Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: ui/gl/gl_image_ref_counted_memory_unittest.cc

Issue 1415723006: ui: Add RGBX_8888 buffer format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gles but no conversion needed case Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_image_ozone_native_pixmap.cc ('k') | ui/gl/gl_image_shared_memory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <vector> 5 #include <vector>
6 6
7 #include "base/memory/ref_counted_memory.h" 7 #include "base/memory/ref_counted_memory.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gl/gl_image_ref_counted_memory.h" 9 #include "ui/gl/gl_image_ref_counted_memory.h"
10 #include "ui/gl/test/gl_image_test_template.h" 10 #include "ui/gl/test/gl_image_test_template.h"
11 11
12 namespace gfx { 12 namespace gfx {
13 namespace { 13 namespace {
14 14
15 template <BufferFormat format>
15 class GLImageRefCountedMemoryTestDelegate { 16 class GLImageRefCountedMemoryTestDelegate {
16 public: 17 public:
17 scoped_refptr<GLImage> CreateSolidColorImage(const Size& size, 18 scoped_refptr<GLImage> CreateSolidColorImage(const Size& size,
18 unsigned internalformat,
19 BufferFormat format,
20 const uint8_t color[4]) const { 19 const uint8_t color[4]) const {
21 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u); 20 DCHECK_EQ(NumberOfPlanesForBufferFormat(format), 1u);
22 std::vector<uint8_t> data(BufferSizeForBufferFormat(size, format)); 21 std::vector<uint8_t> data(BufferSizeForBufferFormat(size, format));
23 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); 22 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data));
24 GLImageTestSupport::SetBufferDataToColor( 23 GLImageTestSupport::SetBufferDataToColor(
25 size.width(), size.height(), 24 size.width(), size.height(),
26 static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)), 25 static_cast<int>(RowSizeForBufferFormat(size.width(), format, 0)),
27 format, color, &bytes->data().front()); 26 format, color, &bytes->data().front());
28 scoped_refptr<GLImageRefCountedMemory> image( 27 scoped_refptr<GLImageRefCountedMemory> image(new GLImageRefCountedMemory(
29 new GLImageRefCountedMemory(size, internalformat)); 28 size, GLImageMemory::GetInternalFormatForTesting(format)));
30 bool rv = image->Initialize(bytes.get(), format); 29 bool rv = image->Initialize(bytes.get(), format);
31 EXPECT_TRUE(rv); 30 EXPECT_TRUE(rv);
32 return image; 31 return image;
33 } 32 }
34 }; 33 };
35 34
35 using GLImageTestTypes = testing::Types<
36 GLImageRefCountedMemoryTestDelegate<BufferFormat::RGBX_8888>,
37 GLImageRefCountedMemoryTestDelegate<BufferFormat::RGBA_8888>,
38 GLImageRefCountedMemoryTestDelegate<BufferFormat::BGRX_8888>,
39 GLImageRefCountedMemoryTestDelegate<BufferFormat::BGRA_8888>>;
40
36 INSTANTIATE_TYPED_TEST_CASE_P(GLImageRefCountedMemory, 41 INSTANTIATE_TYPED_TEST_CASE_P(GLImageRefCountedMemory,
37 GLImageTest, 42 GLImageTest,
38 GLImageRefCountedMemoryTestDelegate); 43 GLImageTestTypes);
39 44
40 INSTANTIATE_TYPED_TEST_CASE_P(GLImageRefCountedMemory, 45 INSTANTIATE_TYPED_TEST_CASE_P(GLImageRefCountedMemory,
41 GLImageCopyTest, 46 GLImageCopyTest,
42 GLImageRefCountedMemoryTestDelegate); 47 GLImageTestTypes);
43 48
44 } // namespace 49 } // namespace
45 } // namespace gfx 50 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_ozone_native_pixmap.cc ('k') | ui/gl/gl_image_shared_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698