OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gl/gl_image_io_surface.h" | 5 #include "ui/gl/gl_image_io_surface.h" |
6 | 6 |
7 #include "ui/gl/gl_bindings.h" | 7 #include "ui/gl/gl_bindings.h" |
8 #include "ui/gl/gl_context.h" | 8 #include "ui/gl/gl_context.h" |
9 #include "ui/gl/io_surface_support_mac.h" | 9 #include "ui/gl/io_surface_support_mac.h" |
10 | 10 |
11 namespace gfx { | 11 namespace gfx { |
12 | 12 |
13 GLImageIOSurface::GLImageIOSurface(gfx::Size size) | 13 GLImageIOSurface::GLImageIOSurface(gfx::Size size) |
14 : io_surface_support_(IOSurfaceSupport::Initialize()), size_(size) { | 14 : io_surface_support_(IOSurfaceSupport::Initialize()), size_(size) { |
15 CHECK(io_surface_support_); | 15 CHECK(io_surface_support_); |
16 } | 16 } |
17 | 17 |
18 GLImageIOSurface::~GLImageIOSurface() { Destroy(); } | 18 GLImageIOSurface::~GLImageIOSurface() { |
19 DCHECK(!io_surface_); | |
20 } | |
19 | 21 |
20 bool GLImageIOSurface::Initialize(gfx::GpuMemoryBufferHandle buffer) { | 22 bool GLImageIOSurface::Initialize(gfx::GpuMemoryBufferHandle buffer) { |
21 io_surface_.reset(io_surface_support_->IOSurfaceLookup(buffer.io_surface_id)); | 23 io_surface_.reset(io_surface_support_->IOSurfaceLookup(buffer.io_surface_id)); |
22 if (!io_surface_) { | 24 if (!io_surface_) { |
23 LOG(ERROR) << "IOSurface lookup failed"; | 25 LOG(ERROR) << "IOSurface lookup failed"; |
24 return false; | 26 return false; |
25 } | 27 } |
26 | 28 |
27 return true; | 29 return true; |
28 } | 30 } |
29 | 31 |
32 void GLImageIOSurface::Destroy(bool have_context) { | |
33 DCHECK(io_surface_); | |
reveman
2014/05/31 05:05:06
This DCHECK seems inconsistent with other implemen
sohanjg
2014/06/02 13:59:42
Done.
| |
34 io_surface_.reset() | |
35 } | |
36 | |
30 gfx::Size GLImageIOSurface::GetSize() { return size_; } | 37 gfx::Size GLImageIOSurface::GetSize() { return size_; } |
31 | 38 |
32 bool GLImageIOSurface::BindTexImage(unsigned target) { | 39 bool GLImageIOSurface::BindTexImage(unsigned target) { |
33 if (target != GL_TEXTURE_RECTANGLE_ARB) { | 40 if (target != GL_TEXTURE_RECTANGLE_ARB) { |
34 // This might be supported in the future. For now, perform strict | 41 // This might be supported in the future. For now, perform strict |
35 // validation so we know what's going on. | 42 // validation so we know what's going on. |
36 LOG(ERROR) << "IOSurface requires TEXTURE_RECTANGLE_ARB target"; | 43 LOG(ERROR) << "IOSurface requires TEXTURE_RECTANGLE_ARB target"; |
37 return false; | 44 return false; |
38 } | 45 } |
39 | 46 |
(...skipping 13 matching lines...) Expand all Loading... | |
53 0); | 60 0); |
54 if (cgl_error != kCGLNoError) { | 61 if (cgl_error != kCGLNoError) { |
55 LOG(ERROR) << "Error in CGLTexImageIOSurface2D"; | 62 LOG(ERROR) << "Error in CGLTexImageIOSurface2D"; |
56 return false; | 63 return false; |
57 } | 64 } |
58 | 65 |
59 return true; | 66 return true; |
60 } | 67 } |
61 | 68 |
62 } // namespace gfx | 69 } // namespace gfx |
OLD | NEW |