OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 "base/debug/trace_event.h" |
| 6 |
| 7 #include "ui/gl/gl_bindings.h" |
| 8 #include "ui/gl/gl_image_foobar.h" |
| 9 |
| 10 namespace gfx { |
| 11 |
| 12 GLImageFoobar::GLImageFoobar(gfx::Size size) : size_(size), prime_fd(-1) { |
| 13 } |
| 14 |
| 15 GLImageFoobar::~GLImageFoobar() { |
| 16 Destroy(); |
| 17 } |
| 18 |
| 19 bool GLImageFoobar::Initialize(gfx::GpuMemoryBufferHandle buffer) { |
| 20 prime_fd = dup(buffer.handle.fd); |
| 21 return prime_fd >= 0; |
| 22 } |
| 23 |
| 24 void GLImageFoobar::Destroy() { |
| 25 if (prime_fd >= 0) |
| 26 close(prime_fd); |
| 27 } |
| 28 |
| 29 gfx::Size GLImageFoobar::GetSize() { |
| 30 return size_; |
| 31 } |
| 32 |
| 33 #define MAGIC(x) ( (void*) ((((uintptr_t)x) << 48) + 0xf00ba4f00ba4) ) |
| 34 |
| 35 bool GLImageFoobar::BindTexImage(unsigned target) { |
| 36 TRACE_EVENT0("zcopy", "BindTexImage"); |
| 37 glTexImage2D( |
| 38 target, |
| 39 0, // mip level |
| 40 GL_BGRA_EXT, |
| 41 size_.width(), |
| 42 size_.height(), |
| 43 0, // border |
| 44 GL_BGRA_EXT, |
| 45 GL_UNSIGNED_BYTE, |
| 46 MAGIC(prime_fd) |
| 47 ); |
| 48 return true; |
| 49 } |
| 50 |
| 51 void GLImageFoobar::ReleaseTexImage(unsigned target) { |
| 52 } |
| 53 |
| 54 void GLImageFoobar::WillUseTexImage() { |
| 55 } |
| 56 |
| 57 void GLImageFoobar::DidUseTexImage() { |
| 58 } |
| 59 |
| 60 } // namespace gfx |
OLD | NEW |