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

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

Issue 2786103003: Add half-float IOSurface GpuMemoryBuffer support (Closed)
Patch Set: Review feedback Created 3 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
« no previous file with comments | « ui/gl/gl_image_native_pixmap.cc ('k') | no next file » | 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 "ui/gl/test/gl_image_test_support.h" 5 #include "ui/gl/test/gl_image_test_support.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ui/gfx/half_float.h"
9 #include "ui/gl/gl_implementation.h" 10 #include "ui/gl/gl_implementation.h"
10 #include "ui/gl/init/gl_factory.h" 11 #include "ui/gl/init/gl_factory.h"
11 #include "ui/gl/test/gl_surface_test_support.h" 12 #include "ui/gl/test/gl_surface_test_support.h"
12 13
13 #if defined(USE_OZONE) 14 #if defined(USE_OZONE)
14 #include "base/run_loop.h" 15 #include "base/run_loop.h"
15 #include "ui/ozone/public/ozone_platform.h" 16 #include "ui/ozone/public/ozone_platform.h"
16 #endif 17 #endif
17 18
18 namespace gl { 19 namespace gl {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 DCHECK_EQ(0, plane); 107 DCHECK_EQ(0, plane);
107 for (int y = 0; y < height; ++y) { 108 for (int y = 0; y < height; ++y) {
108 for (int x = 0; x < width; ++x) { 109 for (int x = 0; x < width; ++x) {
109 data[y * stride + x * 4 + 0] = color[2]; 110 data[y * stride + x * 4 + 0] = color[2];
110 data[y * stride + x * 4 + 1] = color[1]; 111 data[y * stride + x * 4 + 1] = color[1];
111 data[y * stride + x * 4 + 2] = color[0]; 112 data[y * stride + x * 4 + 2] = color[0];
112 data[y * stride + x * 4 + 3] = color[3]; 113 data[y * stride + x * 4 + 3] = color[3];
113 } 114 }
114 } 115 }
115 return; 116 return;
117 case gfx::BufferFormat::RGBA_F16: {
118 DCHECK_EQ(0, plane);
119 float float_color[4] = {
120 color[0] / 255.f, color[1] / 255.f, color[2] / 255.f,
121 color[3] / 255.f,
122 };
123 uint16_t half_float_color[4];
124 gfx::FloatToHalfFloat(float_color, half_float_color, 4);
125 for (int y = 0; y < height; ++y) {
126 uint16_t* row = reinterpret_cast<uint16_t*>(data + y * stride);
127 for (int x = 0; x < width; ++x) {
128 row[x * 4 + 0] = half_float_color[0];
129 row[x * 4 + 1] = half_float_color[1];
130 row[x * 4 + 2] = half_float_color[2];
131 row[x * 4 + 3] = half_float_color[3];
132 }
133 }
134 return;
135 }
116 case gfx::BufferFormat::YVU_420: { 136 case gfx::BufferFormat::YVU_420: {
117 DCHECK_LT(plane, 3); 137 DCHECK_LT(plane, 3);
118 DCHECK_EQ(0, height % 2); 138 DCHECK_EQ(0, height % 2);
119 DCHECK_EQ(0, width % 2); 139 DCHECK_EQ(0, width % 2);
120 // These values are used in the transformation from YUV to RGB color 140 // These values are used in the transformation from YUV to RGB color
121 // values. They are taken from the following webpage: 141 // values. They are taken from the following webpage:
122 // http://www.fourcc.org/fccyvrgb.php 142 // http://www.fourcc.org/fccyvrgb.php
123 uint8_t yvu[] = { 143 uint8_t yvu[] = {
124 (0.257 * color[0]) + (0.504 * color[1]) + (0.098 * color[2]) + 16, 144 (0.257 * color[0]) + (0.504 * color[1]) + (0.098 * color[2]) + 16,
125 (0.439 * color[0]) - (0.368 * color[1]) - (0.071 * color[2]) + 128, 145 (0.439 * color[0]) - (0.368 * color[1]) - (0.071 * color[2]) + 128,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 case gfx::BufferFormat::ETC1: 193 case gfx::BufferFormat::ETC1:
174 case gfx::BufferFormat::RGBA_4444: 194 case gfx::BufferFormat::RGBA_4444:
175 case gfx::BufferFormat::UYVY_422: 195 case gfx::BufferFormat::UYVY_422:
176 NOTREACHED(); 196 NOTREACHED();
177 return; 197 return;
178 } 198 }
179 NOTREACHED(); 199 NOTREACHED();
180 } 200 }
181 201
182 } // namespace gl 202 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_native_pixmap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698