Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: ui/gl/gl_image_io_surface.mm

Issue 2945673002: Allow creating GLImage-backed textures with glTexStorage2D. (Closed)
Patch Set: rebase Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_image_io_surface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/mac/foundation_util.h" 11 #include "base/mac/foundation_util.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/trace_event/memory_allocator_dump.h" 13 #include "base/trace_event/memory_allocator_dump.h"
14 #include "base/trace_event/memory_dump_manager.h" 14 #include "base/trace_event/memory_dump_manager.h"
15 #include "base/trace_event/process_memory_dump.h" 15 #include "base/trace_event/process_memory_dump.h"
16 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
17 #include "ui/gfx/icc_profile.h"
17 #include "ui/gl/gl_bindings.h" 18 #include "ui/gl/gl_bindings.h"
18 #include "ui/gl/gl_context.h" 19 #include "ui/gl/gl_context.h"
19 #include "ui/gl/scoped_binders.h" 20 #include "ui/gl/scoped_binders.h"
20 #include "ui/gl/yuv_to_rgb_converter.h" 21 #include "ui/gl/yuv_to_rgb_converter.h"
21 22
22 // Note that this must be included after gl_bindings.h to avoid conflicts. 23 // Note that this must be included after gl_bindings.h to avoid conflicts.
23 #include <OpenGL/CGLIOSurface.h> 24 #include <OpenGL/CGLIOSurface.h>
24 #include <Quartz/Quartz.h> 25 #include <Quartz/Quartz.h>
25 #include <stddef.h> 26 #include <stddef.h>
26 27
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 411 }
411 412
412 base::ScopedCFTypeRef<CVPixelBufferRef> GLImageIOSurface::cv_pixel_buffer() { 413 base::ScopedCFTypeRef<CVPixelBufferRef> GLImageIOSurface::cv_pixel_buffer() {
413 return cv_pixel_buffer_; 414 return cv_pixel_buffer_;
414 } 415 }
415 416
416 GLImage::Type GLImageIOSurface::GetType() const { 417 GLImage::Type GLImageIOSurface::GetType() const {
417 return Type::IOSURFACE; 418 return Type::IOSURFACE;
418 } 419 }
419 420
421 void GLImageIOSurface::SetColorSpaceForScanout(
422 const gfx::ColorSpace& color_space) {
423 GLImage::SetColorSpaceForScanout(color_space);
424
425 // Retrieve the ICC profile data.
426 gfx::ICCProfile icc_profile;
427 if (!color_space.GetAsFullRangeRGB().GetICCProfile(&icc_profile)) {
428 LOG(ERROR) << "Failed to set color space for scanout: no ICC profile.";
429 return;
430 }
431
432 // Package it as a CFDataRef and send it to the IOSurface.
433 base::ScopedCFTypeRef<CFDataRef> cf_data_icc_profile(CFDataCreate(
434 nullptr, reinterpret_cast<const UInt8*>(icc_profile.GetData().data()),
435 icc_profile.GetData().size()));
436 IOSurfaceSetValue(io_surface_, CFSTR("IOSurfaceColorSpace"),
437 cf_data_icc_profile);
438 }
439
420 // static 440 // static
421 unsigned GLImageIOSurface::GetInternalFormatForTesting( 441 unsigned GLImageIOSurface::GetInternalFormatForTesting(
422 gfx::BufferFormat format) { 442 gfx::BufferFormat format) {
423 DCHECK(ValidFormat(format)); 443 DCHECK(ValidFormat(format));
424 return TextureFormat(format); 444 return TextureFormat(format);
425 } 445 }
426 446
427 // static 447 // static
428 GLImageIOSurface* GLImageIOSurface::FromGLImage(GLImage* image) { 448 GLImageIOSurface* GLImageIOSurface::FromGLImage(GLImage* image) {
429 if (!image || image->GetType() != Type::IOSURFACE) 449 if (!image || image->GetType() != Type::IOSURFACE)
430 return nullptr; 450 return nullptr;
431 return static_cast<GLImageIOSurface*>(image); 451 return static_cast<GLImageIOSurface*>(image);
432 } 452 }
433 453
434 } // namespace gl 454 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_io_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698