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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_image_io_surface.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_image_io_surface.mm
diff --git a/ui/gl/gl_image_io_surface.cc b/ui/gl/gl_image_io_surface.mm
similarity index 82%
rename from ui/gl/gl_image_io_surface.cc
rename to ui/gl/gl_image_io_surface.mm
index adcadee363ab5499ca14bd43fbf5bff11378ba51..b1f95f47beb229fa9e3cf15b0edfefaac5cbf86c 100644
--- a/ui/gl/gl_image_io_surface.cc
+++ b/ui/gl/gl_image_io_surface.mm
@@ -4,15 +4,23 @@
#include "ui/gl/gl_image_io_surface.h"
+#include <map>
+
+#include "base/lazy_instance.h"
+#include "base/mac/foundation_util.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
// Note that this must be included after gl_bindings.h to avoid conflicts.
#include <OpenGL/CGLIOSurface.h>
+#include <Quartz/Quartz.h>
namespace gfx {
namespace {
+typedef std::map<gfx::AcceleratedWidget,CALayer*> WidgetToLayerMap;
+base::LazyInstance<WidgetToLayerMap> g_widget_to_layer_map;
+
bool ValidInternalFormat(unsigned internalformat) {
switch (internalformat) {
case GL_R8:
@@ -192,7 +200,31 @@ bool GLImageIOSurface::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
OverlayTransform transform,
const Rect& bounds_rect,
const RectF& crop_rect) {
- return false;
+ // Only simple overlay planes are currently supported.
+ DCHECK_EQ(0, z_order);
+ DCHECK_EQ(gfx::RectF(0, 0, 1, 1).ToString(), crop_rect.ToString());
+ DCHECK_EQ(gfx::OVERLAY_TRANSFORM_NONE, transform);
+
+ // Convert the phony widget to the appropriate CALayer.
+ auto found = g_widget_to_layer_map.Pointer()->find(widget);
+ if (found == g_widget_to_layer_map.Pointer()->end())
+ return false;
+ CALayer* layer = found->second;
+
+ // Also note that transactions are not disabled. The caller must ensure that
+ // all changes to the CALayer tree happen atomically.
+ [layer setContents:static_cast<id>(io_surface_.get())];
+ [layer setFrame:bounds_rect.ToCGRect()];
+ return true;
+}
+
+// static
+void GLImageIOSurface::SetLayerForWidget(
+ gfx::AcceleratedWidget widget, CALayer* layer) {
+ if (layer)
+ g_widget_to_layer_map.Pointer()->insert(std::make_pair(widget, layer));
+ else
+ g_widget_to_layer_map.Pointer()->erase(widget);
}
} // namespace gfx
« 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