Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 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 "ui/gl/gl_image_io_surface.h" | |
| 6 | |
| 7 #include "ui/gl/gl_bindings.h" | |
| 8 #include "ui/gl/gl_context.h" | |
| 9 #include "ui/gl/io_surface_support_mac.h" | |
| 10 | |
| 11 namespace gfx { | |
| 12 | |
| 13 GLImageIOSurface::GLImageIOSurface(gfx::Size size) : size_(size) { | |
| 14 } | |
| 15 | |
| 16 GLImageIOSurface::~GLImageIOSurface() { | |
| 17 Destroy(); | |
| 18 } | |
| 19 | |
| 20 bool GLImageIOSurface::Initialize(gfx::GpuMemoryBufferHandle buffer) { | |
| 21 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); | |
| 22 if (!io_surface_support) { | |
| 23 LOG(ERROR) << "IOSurfaces only supported on 10.6."; | |
|
Ken Russell (switch to Gerrit)
2013/12/03 22:36:13
Same comment as in earlier file about these LOG me
reveman
2013/12/04 02:00:31
Done.
| |
| 24 return false; | |
| 25 } | |
| 26 | |
| 27 io_surface_.reset(io_surface_support->IOSurfaceLookup(buffer.io_surface_id)); | |
| 28 if (!io_surface_) { | |
| 29 LOG(ERROR) << "IOSurface lookup failed"; | |
| 30 return false; | |
| 31 } | |
| 32 | |
| 33 return true; | |
| 34 } | |
| 35 | |
| 36 void GLImageIOSurface::Destroy() { | |
| 37 } | |
| 38 | |
| 39 gfx::Size GLImageIOSurface::GetSize() { | |
| 40 return size_; | |
| 41 } | |
| 42 | |
| 43 bool GLImageIOSurface::BindTexImage(unsigned target) { | |
| 44 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); | |
| 45 DCHECK(io_surface_support); | |
| 46 | |
| 47 if (target != GL_TEXTURE_RECTANGLE_ARB) { | |
| 48 // This might be supported in the future. For now, perform strict | |
| 49 // validation so we know what's going on. | |
| 50 LOG(ERROR) << "IOSurface requires TEXTURE_RECTANGLE_ARB target"; | |
| 51 return false; | |
| 52 } | |
| 53 | |
| 54 CGLContextObj cgl_context = static_cast<CGLContextObj>( | |
| 55 GLContext::GetCurrent()->GetHandle()); | |
| 56 | |
| 57 DCHECK(io_surface_); | |
| 58 CGLError cgl_error = io_surface_support->CGLTexImageIOSurface2D( | |
| 59 cgl_context, | |
| 60 target, | |
| 61 GL_RGBA, | |
| 62 size_.width(), | |
| 63 size_.height(), | |
| 64 GL_BGRA, | |
| 65 GL_UNSIGNED_INT_8_8_8_8_REV, | |
| 66 io_surface_.get(), | |
| 67 0); | |
| 68 if (cgl_error != kCGLNoError) { | |
| 69 LOG(ERROR) << "Error in CGLTexImageIOSurface2D"; | |
| 70 return false; | |
| 71 } | |
| 72 | |
| 73 return true; | |
| 74 } | |
| 75 | |
| 76 void GLImageIOSurface::ReleaseTexImage(unsigned target) { | |
| 77 } | |
| 78 | |
| 79 void GLImageIOSurface::WillUseTexImage() { | |
| 80 } | |
| 81 | |
| 82 void GLImageIOSurface::DidUseTexImage() { | |
| 83 } | |
| 84 | |
| 85 } // namespace gfx | |
| OLD | NEW |