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 <map> | 7 #include <map> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/mac/bind_objc_block.h" | 10 #include "base/mac/bind_objc_block.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 GLImageIOSurface::GLImageIOSurface(const gfx::Size& size, | 176 GLImageIOSurface::GLImageIOSurface(const gfx::Size& size, |
177 unsigned internalformat) | 177 unsigned internalformat) |
178 : size_(size), | 178 : size_(size), |
179 internalformat_(ConvertRequestedInternalFormat(internalformat)), | 179 internalformat_(ConvertRequestedInternalFormat(internalformat)), |
180 client_internalformat_(internalformat), | 180 client_internalformat_(internalformat), |
181 format_(gfx::BufferFormat::RGBA_8888) {} | 181 format_(gfx::BufferFormat::RGBA_8888) {} |
182 | 182 |
183 GLImageIOSurface::~GLImageIOSurface() { | 183 GLImageIOSurface::~GLImageIOSurface() { |
184 DCHECK(thread_checker_.CalledOnValidThread()); | 184 DCHECK(thread_checker_.CalledOnValidThread()); |
185 DCHECK(!io_surface_); | |
186 } | 185 } |
187 | 186 |
188 bool GLImageIOSurface::Initialize(IOSurfaceRef io_surface, | 187 bool GLImageIOSurface::Initialize(IOSurfaceRef io_surface, |
189 gfx::GenericSharedMemoryId io_surface_id, | 188 gfx::GenericSharedMemoryId io_surface_id, |
190 gfx::BufferFormat format) { | 189 gfx::BufferFormat format) { |
191 DCHECK(thread_checker_.CalledOnValidThread()); | 190 DCHECK(thread_checker_.CalledOnValidThread()); |
192 DCHECK(!io_surface_); | 191 DCHECK(!io_surface_); |
193 | 192 |
194 if (!ValidInternalFormat(internalformat_)) { | 193 if (!ValidInternalFormat(internalformat_)) { |
195 LOG(ERROR) << "Invalid internalformat: " << internalformat_; | 194 LOG(ERROR) << "Invalid internalformat: " << internalformat_; |
(...skipping 21 matching lines...) Expand all Loading... |
217 return false; | 216 return false; |
218 } | 217 } |
219 | 218 |
220 if (!Initialize(io_surface, io_surface_id, format)) | 219 if (!Initialize(io_surface, io_surface_id, format)) |
221 return false; | 220 return false; |
222 | 221 |
223 cv_pixel_buffer_.reset(cv_pixel_buffer, base::scoped_policy::RETAIN); | 222 cv_pixel_buffer_.reset(cv_pixel_buffer, base::scoped_policy::RETAIN); |
224 return true; | 223 return true; |
225 } | 224 } |
226 | 225 |
227 void GLImageIOSurface::Destroy(bool have_context) { | |
228 DCHECK(thread_checker_.CalledOnValidThread()); | |
229 io_surface_.reset(); | |
230 cv_pixel_buffer_.reset(); | |
231 } | |
232 | |
233 gfx::Size GLImageIOSurface::GetSize() { | 226 gfx::Size GLImageIOSurface::GetSize() { |
234 return size_; | 227 return size_; |
235 } | 228 } |
236 | 229 |
237 unsigned GLImageIOSurface::GetInternalFormat() { | 230 unsigned GLImageIOSurface::GetInternalFormat() { |
238 return internalformat_; | 231 return internalformat_; |
239 } | 232 } |
240 | 233 |
241 bool GLImageIOSurface::BindTexImage(unsigned target) { | 234 bool GLImageIOSurface::BindTexImage(unsigned target) { |
242 DCHECK(thread_checker_.CalledOnValidThread()); | 235 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 } | 398 } |
406 | 399 |
407 // static | 400 // static |
408 GLImageIOSurface* GLImageIOSurface::FromGLImage(GLImage* image) { | 401 GLImageIOSurface* GLImageIOSurface::FromGLImage(GLImage* image) { |
409 if (!image || image->GetType() != Type::IOSURFACE) | 402 if (!image || image->GetType() != Type::IOSURFACE) |
410 return nullptr; | 403 return nullptr; |
411 return static_cast<GLImageIOSurface*>(image); | 404 return static_cast<GLImageIOSurface*>(image); |
412 } | 405 } |
413 | 406 |
414 } // namespace gl | 407 } // namespace gl |
OLD | NEW |