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

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

Issue 1251783002: Mac Overlays: Wire up overlays on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@part22
Patch Set: Leave widget type unchanged Created 5 years, 5 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.cc ('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>
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.
11 #include <OpenGL/CGLIOSurface.h> 15 #include <OpenGL/CGLIOSurface.h>
16 #include <Quartz/Quartz.h>
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
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(0, z_order);
205 DCHECK_EQ(gfx::RectF(0, 0, 1, 1).ToString(), crop_rect.ToString());
206 DCHECK_EQ(gfx::OVERLAY_TRANSFORM_NONE, transform);
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
OLDNEW
« no previous file with comments | « ui/gl/gl_image_io_surface.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698