Index: ui/gl/gl_image_foobar.cc |
diff --git a/ui/gl/gl_image_foobar.cc b/ui/gl/gl_image_foobar.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f5137c15933cd06e18218464d73f96a45c92c744 |
--- /dev/null |
+++ b/ui/gl/gl_image_foobar.cc |
@@ -0,0 +1,60 @@ |
+// Copyright 2013 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 "base/debug/trace_event.h" |
+ |
+#include "ui/gl/gl_bindings.h" |
+#include "ui/gl/gl_image_foobar.h" |
+ |
+namespace gfx { |
+ |
+GLImageFoobar::GLImageFoobar(gfx::Size size) : size_(size), prime_fd(-1) { |
+} |
+ |
+GLImageFoobar::~GLImageFoobar() { |
+ Destroy(); |
+} |
+ |
+bool GLImageFoobar::Initialize(gfx::GpuMemoryBufferHandle buffer) { |
+ prime_fd = dup(buffer.handle.fd); |
+ return prime_fd >= 0; |
+} |
+ |
+void GLImageFoobar::Destroy() { |
+ if (prime_fd >= 0) |
+ close(prime_fd); |
+} |
+ |
+gfx::Size GLImageFoobar::GetSize() { |
+ return size_; |
+} |
+ |
+#define MAGIC(x) ( (void*) ((((uintptr_t)x) << 48) + 0xf00ba4f00ba4) ) |
+ |
+bool GLImageFoobar::BindTexImage(unsigned target) { |
+ TRACE_EVENT0("zcopy", "BindTexImage"); |
+ glTexImage2D( |
+ target, |
+ 0, // mip level |
+ GL_BGRA_EXT, |
+ size_.width(), |
+ size_.height(), |
+ 0, // border |
+ GL_BGRA_EXT, |
+ GL_UNSIGNED_BYTE, |
+ MAGIC(prime_fd) |
+ ); |
+ return true; |
+} |
+ |
+void GLImageFoobar::ReleaseTexImage(unsigned target) { |
+} |
+ |
+void GLImageFoobar::WillUseTexImage() { |
+} |
+ |
+void GLImageFoobar::DidUseTexImage() { |
+} |
+ |
+} // namespace gfx |