Make GL bindings conditional
[chromium-blink-merge.git] / gpu / command_buffer / service / image_factory.cc
blob0b740d8f32b47eb1e179be288abcb61ae2714b00
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.
5 #include "gpu/command_buffer/service/image_factory.h"
7 #include "ui/gl/gl_bindings.h"
9 namespace gpu {
11 ImageFactory::ImageFactory() {
14 ImageFactory::~ImageFactory() {
17 // static
18 gfx::GpuMemoryBuffer::Format ImageFactory::ImageFormatToGpuMemoryBufferFormat(
19 unsigned internalformat) {
20 switch (internalformat) {
21 case GL_RGB:
22 return gfx::GpuMemoryBuffer::RGBX_8888;
23 case GL_RGBA:
24 return gfx::GpuMemoryBuffer::RGBA_8888;
25 default:
26 NOTREACHED();
27 return gfx::GpuMemoryBuffer::RGBA_8888;
31 // static
32 gfx::GpuMemoryBuffer::Usage ImageFactory::ImageUsageToGpuMemoryBufferUsage(
33 unsigned usage) {
34 switch (usage) {
35 case GL_MAP_CHROMIUM:
36 return gfx::GpuMemoryBuffer::MAP;
37 case GL_SCANOUT_CHROMIUM:
38 return gfx::GpuMemoryBuffer::SCANOUT;
39 default:
40 NOTREACHED();
41 return gfx::GpuMemoryBuffer::MAP;
45 // static
46 bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
47 unsigned internalformat,
48 gfx::GpuMemoryBuffer::Format format) {
49 switch (internalformat) {
50 case GL_RGB:
51 switch (format) {
52 case gfx::GpuMemoryBuffer::RGBX_8888:
53 return true;
54 case gfx::GpuMemoryBuffer::RGBA_8888:
55 case gfx::GpuMemoryBuffer::BGRA_8888:
56 return false;
58 NOTREACHED();
59 return false;
60 case GL_RGBA:
61 switch (format) {
62 case gfx::GpuMemoryBuffer::RGBX_8888:
63 return false;
64 case gfx::GpuMemoryBuffer::RGBA_8888:
65 case gfx::GpuMemoryBuffer::BGRA_8888:
66 return true;
68 NOTREACHED();
69 return false;
70 default:
71 NOTREACHED();
72 return false;
76 } // namespace gpu