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"
11 ImageFactory::ImageFactory() {
14 ImageFactory::~ImageFactory() {
18 gfx::GpuMemoryBuffer::Format
ImageFactory::ImageFormatToGpuMemoryBufferFormat(
19 unsigned internalformat
) {
20 switch (internalformat
) {
22 return gfx::GpuMemoryBuffer::RGBX_8888
;
24 return gfx::GpuMemoryBuffer::RGBA_8888
;
27 return gfx::GpuMemoryBuffer::RGBA_8888
;
32 gfx::GpuMemoryBuffer::Usage
ImageFactory::ImageUsageToGpuMemoryBufferUsage(
36 return gfx::GpuMemoryBuffer::MAP
;
37 case GL_SCANOUT_CHROMIUM
:
38 return gfx::GpuMemoryBuffer::SCANOUT
;
41 return gfx::GpuMemoryBuffer::MAP
;
46 bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
47 unsigned internalformat
,
48 gfx::GpuMemoryBuffer::Format format
) {
49 switch (internalformat
) {
52 case gfx::GpuMemoryBuffer::RGBX_8888
:
54 case gfx::GpuMemoryBuffer::RGBA_8888
:
55 case gfx::GpuMemoryBuffer::BGRA_8888
:
62 case gfx::GpuMemoryBuffer::RGBX_8888
:
64 case gfx::GpuMemoryBuffer::RGBA_8888
:
65 case gfx::GpuMemoryBuffer::BGRA_8888
: