| 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/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // Note that this must be included after gl_bindings.h to avoid conflicts. | 21 // Note that this must be included after gl_bindings.h to avoid conflicts. |
| 22 #include <OpenGL/CGLIOSurface.h> | 22 #include <OpenGL/CGLIOSurface.h> |
| 23 #include <Quartz/Quartz.h> | 23 #include <Quartz/Quartz.h> |
| 24 #include <stddef.h> | 24 #include <stddef.h> |
| 25 | 25 |
| 26 using gfx::BufferFormat; | 26 using gfx::BufferFormat; |
| 27 | 27 |
| 28 namespace gl { | 28 namespace gl { |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 using WidgetToLayerMap = std::map<gfx::AcceleratedWidget, CALayer*>; | |
| 32 base::LazyInstance<WidgetToLayerMap> g_widget_to_layer_map; | |
| 33 | |
| 34 const char kGLSLVersion[] = "#version 110"; | 31 const char kGLSLVersion[] = "#version 110"; |
| 35 | 32 |
| 36 const char kTextureRectangleRequired[] = | 33 const char kTextureRectangleRequired[] = |
| 37 "#extension GL_ARB_texture_rectangle : require"; | 34 "#extension GL_ARB_texture_rectangle : require"; |
| 38 | 35 |
| 39 // clang-format off | 36 // clang-format off |
| 40 const char kVertexShader[] = | 37 const char kVertexShader[] = |
| 41 STRINGIZE( | 38 STRINGIZE( |
| 42 attribute vec2 a_position; | 39 attribute vec2 a_position; |
| 43 uniform vec2 a_texScale; | 40 uniform vec2 a_texScale; |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 GetGenericSharedMemoryGUIDForTracing(process_tracing_id, io_surface_id_); | 400 GetGenericSharedMemoryGUIDForTracing(process_tracing_id, io_surface_id_); |
| 404 pmd->CreateSharedGlobalAllocatorDump(guid); | 401 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 405 pmd->AddOwnershipEdge(dump->guid(), guid); | 402 pmd->AddOwnershipEdge(dump->guid(), guid); |
| 406 } | 403 } |
| 407 | 404 |
| 408 base::ScopedCFTypeRef<IOSurfaceRef> GLImageIOSurface::io_surface() { | 405 base::ScopedCFTypeRef<IOSurfaceRef> GLImageIOSurface::io_surface() { |
| 409 return io_surface_; | 406 return io_surface_; |
| 410 } | 407 } |
| 411 | 408 |
| 412 // static | 409 // static |
| 413 void GLImageIOSurface::SetLayerForWidget(gfx::AcceleratedWidget widget, | |
| 414 CALayer* layer) { | |
| 415 if (layer) | |
| 416 g_widget_to_layer_map.Pointer()->insert(std::make_pair(widget, layer)); | |
| 417 else | |
| 418 g_widget_to_layer_map.Pointer()->erase(widget); | |
| 419 } | |
| 420 | |
| 421 // static | |
| 422 unsigned GLImageIOSurface::GetInternalFormatForTesting( | 410 unsigned GLImageIOSurface::GetInternalFormatForTesting( |
| 423 gfx::BufferFormat format) { | 411 gfx::BufferFormat format) { |
| 424 DCHECK(ValidFormat(format)); | 412 DCHECK(ValidFormat(format)); |
| 425 return TextureFormat(format); | 413 return TextureFormat(format); |
| 426 } | 414 } |
| 427 } // namespace gl | 415 } // namespace gl |
| OLD | NEW |