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

Side by Side Diff: gpu/command_buffer/service/image_factory.cc

Issue 665463003: gpu: Add CHROMIUM_image support to in-process command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-gpu-memory-buffer-factory-to-gpu-image-factory
Patch Set: make code more consistent with command buffer proxy Created 6 years, 2 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "gpu/command_buffer/service/image_factory.h"
6
7 #include "ui/gl/gl_bindings.h"
8
9 namespace gpu {
10
11 // static
12 gfx::GpuMemoryBuffer::Format ImageFactory::ImageFormatToGpuMemoryBufferFormat(
13 unsigned internalformat) {
14 switch (internalformat) {
15 case GL_RGB:
16 return gfx::GpuMemoryBuffer::RGBX_8888;
17 case GL_RGBA:
18 return gfx::GpuMemoryBuffer::RGBA_8888;
19 default:
20 NOTREACHED();
21 return gfx::GpuMemoryBuffer::RGBA_8888;
22 }
23 }
24
25 // static
26 gfx::GpuMemoryBuffer::Usage ImageFactory::ImageUsageToGpuMemoryBufferUsage(
27 unsigned usage) {
28 switch (usage) {
29 case GL_MAP_CHROMIUM:
30 return gfx::GpuMemoryBuffer::MAP;
31 case GL_SCANOUT_CHROMIUM:
32 return gfx::GpuMemoryBuffer::SCANOUT;
33 default:
34 NOTREACHED();
35 return gfx::GpuMemoryBuffer::MAP;
36 }
37 }
38
39 // static
40 bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
41 unsigned internalformat,
42 gfx::GpuMemoryBuffer::Format format) {
43 switch (internalformat) {
44 case GL_RGB:
45 switch (format) {
46 case gfx::GpuMemoryBuffer::RGBX_8888:
47 return true;
48 case gfx::GpuMemoryBuffer::RGBA_8888:
49 case gfx::GpuMemoryBuffer::BGRA_8888:
50 return false;
51 }
52 NOTREACHED();
53 return false;
54 case GL_RGBA:
55 switch (format) {
56 case gfx::GpuMemoryBuffer::RGBX_8888:
57 return false;
58 case gfx::GpuMemoryBuffer::RGBA_8888:
59 case gfx::GpuMemoryBuffer::BGRA_8888:
60 return true;
61 }
62 NOTREACHED();
63 return false;
64 default:
65 NOTREACHED();
66 return false;
67 }
68 }
69
70 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698