Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / gl / gl_image_io_surface.cc
blob2bb328bb0e6d11f4d948c4babb1117579275b790
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.
5 #include "ui/gl/gl_image_io_surface.h"
7 #include "ui/gl/gl_bindings.h"
8 #include "ui/gl/gl_context.h"
10 // Note that this must be included after gl_bindings.h to avoid conflicts.
11 #include <OpenGL/CGLIOSurface.h>
13 namespace gfx {
15 GLImageIOSurface::GLImageIOSurface(const gfx::Size& size) : size_(size) {
18 GLImageIOSurface::~GLImageIOSurface() {
19 DCHECK(thread_checker_.CalledOnValidThread());
20 DCHECK(!io_surface_);
23 bool GLImageIOSurface::Initialize(IOSurfaceRef io_surface) {
24 DCHECK(thread_checker_.CalledOnValidThread());
25 DCHECK(!io_surface_);
26 io_surface_.reset(io_surface);
27 return true;
30 void GLImageIOSurface::Destroy(bool have_context) {
31 DCHECK(thread_checker_.CalledOnValidThread());
32 io_surface_.reset();
35 gfx::Size GLImageIOSurface::GetSize() { return size_; }
37 bool GLImageIOSurface::BindTexImage(unsigned target) {
38 DCHECK(thread_checker_.CalledOnValidThread());
39 if (target != GL_TEXTURE_RECTANGLE_ARB) {
40 // This might be supported in the future. For now, perform strict
41 // validation so we know what's going on.
42 LOG(ERROR) << "IOSurface requires TEXTURE_RECTANGLE_ARB target";
43 return false;
46 CGLContextObj cgl_context =
47 static_cast<CGLContextObj>(GLContext::GetCurrent()->GetHandle());
49 DCHECK(io_surface_);
50 CGLError cgl_error = CGLTexImageIOSurface2D(cgl_context,
51 target,
52 GL_RGBA,
53 size_.width(),
54 size_.height(),
55 GL_BGRA,
56 GL_UNSIGNED_INT_8_8_8_8_REV,
57 io_surface_.get(),
58 0);
59 if (cgl_error != kCGLNoError) {
60 LOG(ERROR) << "Error in CGLTexImageIOSurface2D";
61 return false;
64 return true;
67 bool GLImageIOSurface::CopyTexImage(unsigned target) {
68 return false;
71 bool GLImageIOSurface::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
72 int z_order,
73 OverlayTransform transform,
74 const Rect& bounds_rect,
75 const RectF& crop_rect) {
76 return false;
79 } // namespace gfx