Chromium Code Reviews| 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> | |
| 8 | |
| 9 #include "base/lazy_instance.h" | |
| 10 #include "base/mac/foundation_util.h" | |
| 7 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
| 8 #include "ui/gl/gl_context.h" | 12 #include "ui/gl/gl_context.h" |
| 9 | 13 |
| 10 // Note that this must be included after gl_bindings.h to avoid conflicts. | 14 // Note that this must be included after gl_bindings.h to avoid conflicts. |
| 15 #include <Quartz/Quartz.h> | |
| 11 #include <OpenGL/CGLIOSurface.h> | 16 #include <OpenGL/CGLIOSurface.h> |
|
Avi (use Gerrit)
2015/07/23 20:13:57
Alphabetical?
ccameron
2015/07/23 22:16:39
Done.
| |
| 12 | 17 |
| 13 namespace gfx { | 18 namespace gfx { |
| 14 namespace { | 19 namespace { |
| 15 | 20 |
| 21 typedef std::map<gfx::AcceleratedWidget,CALayer*> WidgetToLayerMap; | |
| 22 base::LazyInstance<WidgetToLayerMap> g_widget_to_layer_map; | |
| 23 | |
| 16 bool ValidInternalFormat(unsigned internalformat) { | 24 bool ValidInternalFormat(unsigned internalformat) { |
| 17 switch (internalformat) { | 25 switch (internalformat) { |
| 18 case GL_R8: | 26 case GL_R8: |
| 19 case GL_BGRA_EXT: | 27 case GL_BGRA_EXT: |
| 20 return true; | 28 return true; |
| 21 default: | 29 default: |
| 22 return false; | 30 return false; |
| 23 } | 31 } |
| 24 } | 32 } |
| 25 | 33 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 const Point& offset, | 193 const Point& offset, |
| 186 const Rect& rect) { | 194 const Rect& rect) { |
| 187 return false; | 195 return false; |
| 188 } | 196 } |
| 189 | 197 |
| 190 bool GLImageIOSurface::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 198 bool GLImageIOSurface::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
| 191 int z_order, | 199 int z_order, |
| 192 OverlayTransform transform, | 200 OverlayTransform transform, |
| 193 const Rect& bounds_rect, | 201 const Rect& bounds_rect, |
| 194 const RectF& crop_rect) { | 202 const RectF& crop_rect) { |
| 195 return false; | 203 // Only simple overlay planes are currently supported. |
| 204 DCHECK_EQ(z_order, 0); | |
|
Avi (use Gerrit)
2015/07/23 20:13:57
expected value first.
ccameron
2015/07/23 22:16:39
Done.
| |
| 205 DCHECK_EQ(crop_rect.ToString(), gfx::RectF(0, 0, 1, 1).ToString()); | |
| 206 DCHECK_EQ(transform, gfx::OVERLAY_TRANSFORM_NONE); | |
|
Avi (use Gerrit)
2015/07/23 20:13:57
expected value first
ccameron
2015/07/23 22:16:39
Done.
| |
| 207 | |
| 208 // Convert the phony widget to the appropriate CALayer. | |
| 209 auto found = g_widget_to_layer_map.Pointer()->find(widget); | |
| 210 if (found == g_widget_to_layer_map.Pointer()->end()) | |
| 211 return false; | |
| 212 CALayer* layer = found->second; | |
| 213 | |
| 214 // Also note that transactions are not disabled. The caller must ensure that | |
| 215 // all changes to the CALayer tree happen atomically. | |
| 216 [layer setContents:static_cast<id>(io_surface_.get())]; | |
| 217 [layer setFrame:bounds_rect.ToCGRect()]; | |
| 218 return true; | |
| 219 } | |
| 220 | |
| 221 // static | |
| 222 void GLImageIOSurface::SetLayerForWidget( | |
| 223 gfx::AcceleratedWidget widget, CALayer* layer) { | |
| 224 if (layer) | |
| 225 g_widget_to_layer_map.Pointer()->insert(std::make_pair(widget, layer)); | |
| 226 else | |
| 227 g_widget_to_layer_map.Pointer()->erase(widget); | |
| 196 } | 228 } |
| 197 | 229 |
| 198 } // namespace gfx | 230 } // namespace gfx |
| OLD | NEW |