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

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

Issue 2920793005: gpu: support R16 GPUMemoryBuffer (Closed)
Patch Set: Fix Aleks's comments Created 3 years, 6 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 <vector> 7 #include <vector>
8 8
9 #include "ui/gfx/half_float.h" 9 #include "ui/gfx/half_float.h"
10 #include "ui/gl/gl_implementation.h" 10 #include "ui/gl/gl_implementation.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 const uint8_t color[4], 53 const uint8_t color[4],
54 uint8_t* data) { 54 uint8_t* data) {
55 switch (format) { 55 switch (format) {
56 case gfx::BufferFormat::R_8: 56 case gfx::BufferFormat::R_8:
57 case gfx::BufferFormat::RG_88: 57 case gfx::BufferFormat::RG_88:
58 DCHECK_EQ(0, plane); 58 DCHECK_EQ(0, plane);
59 for (int y = 0; y < height; ++y) { 59 for (int y = 0; y < height; ++y) {
60 memset(&data[y * stride], color[0], width); 60 memset(&data[y * stride], color[0], width);
61 } 61 }
62 return; 62 return;
63 case gfx::BufferFormat::R_16:
64 DCHECK_EQ(0, plane);
65 uint16_t red;
66 red = (uint16_t)color[0] << 8;
reveman 2017/06/14 17:47:21 nit: "uint16_t red = static_cast<uint16_t>(color[0
riju_ 2017/06/20 13:21:31 Done.
67 for (int y = 0; y < height; ++y) {
68 uint16_t* row = reinterpret_cast<uint16_t*>(data + y * stride);
69 for (int x = 0; x < width; ++x) {
70 row[x] = red;
71 }
72 }
73 return;
63 case gfx::BufferFormat::BGR_565: 74 case gfx::BufferFormat::BGR_565:
64 DCHECK_EQ(0, plane); 75 DCHECK_EQ(0, plane);
65 for (int y = 0; y < height; ++y) { 76 for (int y = 0; y < height; ++y) {
66 for (int x = 0; x < width; ++x) { 77 for (int x = 0; x < width; ++x) {
67 *reinterpret_cast<uint16_t*>(&data[y * stride + x * 2]) = 78 *reinterpret_cast<uint16_t*>(&data[y * stride + x * 2]) =
68 ((color[2] >> 3) << 11) | ((color[1] >> 2) << 5) | 79 ((color[2] >> 3) << 11) | ((color[1] >> 2) << 5) |
69 (color[0] >> 3); 80 (color[0] >> 3);
70 } 81 }
71 } 82 }
72 return; 83 return;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 case gfx::BufferFormat::ETC1: 204 case gfx::BufferFormat::ETC1:
194 case gfx::BufferFormat::RGBA_4444: 205 case gfx::BufferFormat::RGBA_4444:
195 case gfx::BufferFormat::UYVY_422: 206 case gfx::BufferFormat::UYVY_422:
196 NOTREACHED(); 207 NOTREACHED();
197 return; 208 return;
198 } 209 }
199 NOTREACHED(); 210 NOTREACHED();
200 } 211 }
201 212
202 } // namespace gl 213 } // namespace gl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698