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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 const Point& offset, | 192 const Point& offset, |
193 const Rect& rect) { | 193 const Rect& rect) { |
194 return false; | 194 return false; |
195 } | 195 } |
196 | 196 |
197 bool GLImageIOSurface::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 197 bool GLImageIOSurface::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
198 int z_order, | 198 int z_order, |
199 OverlayTransform transform, | 199 OverlayTransform transform, |
200 const Rect& bounds_rect, | 200 const Rect& bounds_rect, |
201 const RectF& crop_rect) { | 201 const RectF& crop_rect) { |
202 NOTREACHED(); | 202 // Only simple overlay planes are currently supported. |
203 return false; | 203 DCHECK_EQ(0, z_order); |
204 } | 204 DCHECK_EQ(gfx::RectF(0, 0, 1, 1).ToString(), crop_rect.ToString()); |
| 205 DCHECK_EQ(gfx::OVERLAY_TRANSFORM_NONE, transform); |
205 | 206 |
206 base::ScopedCFTypeRef<IOSurfaceRef> GLImageIOSurface::io_surface() { | 207 // Convert the phony widget to the appropriate CALayer. |
207 return io_surface_; | 208 auto found = g_widget_to_layer_map.Pointer()->find(widget); |
| 209 if (found == g_widget_to_layer_map.Pointer()->end()) |
| 210 return false; |
| 211 CALayer* layer = found->second; |
| 212 |
| 213 // Also note that transactions are not disabled. The caller must ensure that |
| 214 // all changes to the CALayer tree happen atomically. |
| 215 [layer setContents:static_cast<id>(io_surface_.get())]; |
| 216 [layer setFrame:bounds_rect.ToCGRect()]; |
| 217 return true; |
208 } | 218 } |
209 | 219 |
210 // static | 220 // static |
211 void GLImageIOSurface::SetLayerForWidget( | 221 void GLImageIOSurface::SetLayerForWidget( |
212 gfx::AcceleratedWidget widget, CALayer* layer) { | 222 gfx::AcceleratedWidget widget, CALayer* layer) { |
213 if (layer) | 223 if (layer) |
214 g_widget_to_layer_map.Pointer()->insert(std::make_pair(widget, layer)); | 224 g_widget_to_layer_map.Pointer()->insert(std::make_pair(widget, layer)); |
215 else | 225 else |
216 g_widget_to_layer_map.Pointer()->erase(widget); | 226 g_widget_to_layer_map.Pointer()->erase(widget); |
217 } | 227 } |
218 | 228 |
219 } // namespace gfx | 229 } // namespace gfx |
OLD | NEW |