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 // Only simple overlay planes are currently supported. | 202 NOTREACHED(); |
203 DCHECK_EQ(0, z_order); | 203 return false; |
204 DCHECK_EQ(gfx::RectF(0, 0, 1, 1).ToString(), crop_rect.ToString()); | 204 } |
205 DCHECK_EQ(gfx::OVERLAY_TRANSFORM_NONE, transform); | |
206 | 205 |
207 // Convert the phony widget to the appropriate CALayer. | 206 base::ScopedCFTypeRef<IOSurfaceRef> GLImageIOSurface::io_surface() { |
208 auto found = g_widget_to_layer_map.Pointer()->find(widget); | 207 return io_surface_; |
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; | |
218 } | 208 } |
219 | 209 |
220 // static | 210 // static |
221 void GLImageIOSurface::SetLayerForWidget( | 211 void GLImageIOSurface::SetLayerForWidget( |
222 gfx::AcceleratedWidget widget, CALayer* layer) { | 212 gfx::AcceleratedWidget widget, CALayer* layer) { |
223 if (layer) | 213 if (layer) |
224 g_widget_to_layer_map.Pointer()->insert(std::make_pair(widget, layer)); | 214 g_widget_to_layer_map.Pointer()->insert(std::make_pair(widget, layer)); |
225 else | 215 else |
226 g_widget_to_layer_map.Pointer()->erase(widget); | 216 g_widget_to_layer_map.Pointer()->erase(widget); |
227 } | 217 } |
228 | 218 |
229 } // namespace gfx | 219 } // namespace gfx |
OLD | NEW |