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

Unified Diff: gpu/command_buffer/service/image_factory.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/image_factory.h ('k') | gpu/command_buffer/service/in_process_command_buffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/image_factory.cc
diff --git a/gpu/command_buffer/service/image_factory.cc b/gpu/command_buffer/service/image_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0b740d8f32b47eb1e179be288abcb61ae2714b00
--- /dev/null
+++ b/gpu/command_buffer/service/image_factory.cc
@@ -0,0 +1,76 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/command_buffer/service/image_factory.h"
+
+#include "ui/gl/gl_bindings.h"
+
+namespace gpu {
+
+ImageFactory::ImageFactory() {
+}
+
+ImageFactory::~ImageFactory() {
+}
+
+// static
+gfx::GpuMemoryBuffer::Format ImageFactory::ImageFormatToGpuMemoryBufferFormat(
+ unsigned internalformat) {
+ switch (internalformat) {
+ case GL_RGB:
+ return gfx::GpuMemoryBuffer::RGBX_8888;
+ case GL_RGBA:
+ return gfx::GpuMemoryBuffer::RGBA_8888;
+ default:
+ NOTREACHED();
+ return gfx::GpuMemoryBuffer::RGBA_8888;
+ }
+}
+
+// static
+gfx::GpuMemoryBuffer::Usage ImageFactory::ImageUsageToGpuMemoryBufferUsage(
+ unsigned usage) {
+ switch (usage) {
+ case GL_MAP_CHROMIUM:
+ return gfx::GpuMemoryBuffer::MAP;
+ case GL_SCANOUT_CHROMIUM:
+ return gfx::GpuMemoryBuffer::SCANOUT;
+ default:
+ NOTREACHED();
+ return gfx::GpuMemoryBuffer::MAP;
+ }
+}
+
+// static
+bool ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
+ unsigned internalformat,
+ gfx::GpuMemoryBuffer::Format format) {
+ switch (internalformat) {
+ case GL_RGB:
+ switch (format) {
+ case gfx::GpuMemoryBuffer::RGBX_8888:
+ return true;
+ case gfx::GpuMemoryBuffer::RGBA_8888:
+ case gfx::GpuMemoryBuffer::BGRA_8888:
+ return false;
+ }
+ NOTREACHED();
+ return false;
+ case GL_RGBA:
+ switch (format) {
+ case gfx::GpuMemoryBuffer::RGBX_8888:
+ return false;
+ case gfx::GpuMemoryBuffer::RGBA_8888:
+ case gfx::GpuMemoryBuffer::BGRA_8888:
+ return true;
+ }
+ NOTREACHED();
+ return false;
+ default:
+ NOTREACHED();
+ return false;
+ }
+}
+
+} // namespace gpu
« no previous file with comments | « gpu/command_buffer/service/image_factory.h ('k') | gpu/command_buffer/service/in_process_command_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698