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

Side by Side Diff: ui/gl/test/gl_image_test_support.cc

Issue 1484473003: gl, ozone: enable GLImageBindTest unittests Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase based on crrev.com/1879243002 Created 4 years, 8 months 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
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 "ui/gl/test/gl_image_test_support.h" 5 #include "ui/gl/test/gl_image_test_support.h"
6 6
7 #include <stdio.h>
7 #include <vector> 8 #include <vector>
8 9
9 #include "ui/gl/gl_implementation.h" 10 #include "ui/gl/gl_implementation.h"
10 #include "ui/gl/test/gl_surface_test_support.h" 11 #include "ui/gl/test/gl_surface_test_support.h"
11 12
12 #if defined(USE_OZONE)
13 #include "base/message_loop/message_loop.h"
14 #endif
15
16 namespace gl { 13 namespace gl {
17 14
18 // static 15 // static
19 void GLImageTestSupport::InitializeGL() { 16 void GLImageTestSupport::InitializeGL() {
20 #if defined(USE_OZONE)
21 // On Ozone, the backend initializes the event system using a UI thread.
22 base::MessageLoopForUI main_loop;
23 #endif
24
25 std::vector<gfx::GLImplementation> allowed_impls; 17 std::vector<gfx::GLImplementation> allowed_impls;
26 GetAllowedGLImplementations(&allowed_impls); 18 GetAllowedGLImplementations(&allowed_impls);
27 DCHECK(!allowed_impls.empty()); 19 DCHECK(!allowed_impls.empty());
28 20
29 gfx::GLImplementation impl = allowed_impls[0]; 21 gfx::GLImplementation impl = allowed_impls[0];
30 gfx::GLSurfaceTestSupport::InitializeOneOffImplementation(impl, true); 22 gfx::GLSurfaceTestSupport::InitializeOneOffImplementation(impl, true);
31 } 23 }
32 24
33 // static 25 // static
34 void GLImageTestSupport::CleanupGL() { 26 void GLImageTestSupport::CleanupGL() {
35 gfx::ClearGLBindings(); 27 gfx::ClearGLBindings();
36 } 28 }
37 29
38 // static 30 // static
39 void GLImageTestSupport::SetBufferDataToColor(int width, 31 void GLImageTestSupport::SetBufferDataToColor(int width,
40 int height, 32 int height,
41 int stride, 33 int stride,
42 int plane, 34 int plane,
43 gfx::BufferFormat format, 35 gfx::BufferFormat format,
44 const uint8_t color[4], 36 const uint8_t color[4],
45 uint8_t* data) { 37 uint8_t* data) {
46 switch (format) { 38 switch (format) {
39 case gfx::BufferFormat::R_8:
40 DCHECK_EQ(0, plane);
41 for (int y = 0; y < height; ++y) {
42 memset(&data[y * stride], color[0], width);
43 }
44 return;
47 case gfx::BufferFormat::RGBX_8888: 45 case gfx::BufferFormat::RGBX_8888:
48 DCHECK_EQ(0, plane); 46 DCHECK_EQ(0, plane);
49 for (int y = 0; y < height; ++y) { 47 for (int y = 0; y < height; ++y) {
50 for (int x = 0; x < width; ++x) { 48 for (int x = 0; x < width; ++x) {
51 data[y * stride + x * 4 + 0] = color[0]; 49 data[y * stride + x * 4 + 0] = color[0];
52 data[y * stride + x * 4 + 1] = color[1]; 50 data[y * stride + x * 4 + 1] = color[1];
53 data[y * stride + x * 4 + 2] = color[2]; 51 data[y * stride + x * 4 + 2] = color[2];
54 data[y * stride + x * 4 + 3] = 0xaa; // unused 52 data[y * stride + x * 4 + 3] = 0xaa; // unused
55 } 53 }
56 } 54 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 111 }
114 } 112 }
115 } 113 }
116 return; 114 return;
117 } 115 }
118 case gfx::BufferFormat::ATC: 116 case gfx::BufferFormat::ATC:
119 case gfx::BufferFormat::ATCIA: 117 case gfx::BufferFormat::ATCIA:
120 case gfx::BufferFormat::DXT1: 118 case gfx::BufferFormat::DXT1:
121 case gfx::BufferFormat::DXT5: 119 case gfx::BufferFormat::DXT5:
122 case gfx::BufferFormat::ETC1: 120 case gfx::BufferFormat::ETC1:
123 case gfx::BufferFormat::R_8:
124 case gfx::BufferFormat::RGBA_4444: 121 case gfx::BufferFormat::RGBA_4444:
125 case gfx::BufferFormat::UYVY_422: 122 case gfx::BufferFormat::UYVY_422:
126 case gfx::BufferFormat::YUV_420: 123 case gfx::BufferFormat::YUV_420:
127 NOTREACHED(); 124 NOTREACHED();
128 return; 125 return;
129 } 126 }
130 NOTREACHED(); 127 NOTREACHED();
131 } 128 }
132 129
133 } // namespace gl 130 } // namespace gl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698