From f78ac522f8fc1463797b4de6831f9f0ee58566f8 Mon Sep 17 00:00:00 2001
From: "ccameron@chromium.org"
 <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Tue, 2 Apr 2013 23:45:16 +0000
Subject: Separate CompositingIOSurface from its GL context

This is towards making all CompositingIOSurfaces in a window
to share a single GL context.

BUG=180463


Review URL: https://chromiumcodereview.appspot.com/13363002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191935 0039d316-1c4b-4281-b951-d872f2087c98
---
 .../compositing_iosurface_context_mac.h            | 56 ++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 content/browser/renderer_host/compositing_iosurface_context_mac.h

(limited to 'content/browser/renderer_host/compositing_iosurface_context_mac.h')

diff --git a/content/browser/renderer_host/compositing_iosurface_context_mac.h b/content/browser/renderer_host/compositing_iosurface_context_mac.h
new file mode 100644
index 0000000..bf4dd56
--- /dev/null
+++ b/content/browser/renderer_host/compositing_iosurface_context_mac.h
@@ -0,0 +1,56 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_CONTEXT_MAC_H_
+#define CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_CONTEXT_MAC_H_
+
+#import <AppKit/NSOpenGL.h>
+#include <OpenGL/OpenGL.h>
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_nsobject.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/browser/renderer_host/compositing_iosurface_mac.h"
+
+namespace content {
+
+class CompositingIOSurfaceShaderPrograms;
+
+class CompositingIOSurfaceContext
+    : public base::RefCounted<CompositingIOSurfaceContext> {
+ public:
+  static scoped_refptr<CompositingIOSurfaceContext> Get(
+      CompositingIOSurfaceMac::SurfaceOrder surface_order);
+
+  CompositingIOSurfaceShaderPrograms* shader_program_cache() const {
+    return shader_program_cache_.get();
+  }
+  NSOpenGLContext* nsgl_context() const { return nsgl_context_; }
+  CGLContextObj cgl_context() const { return cgl_context_; }
+  bool is_vsync_disabled() const { return is_vsync_disabled_; }
+
+ private:
+  friend class base::RefCounted<CompositingIOSurfaceContext>;
+
+  CompositingIOSurfaceContext(
+      CompositingIOSurfaceMac::SurfaceOrder surface_order,
+      NSOpenGLContext* nsgl_context,
+      CGLContextObj clg_context,
+      bool is_vsync_disabled_,
+      scoped_ptr<CompositingIOSurfaceShaderPrograms> shader_program_cache);
+  ~CompositingIOSurfaceContext();
+
+  // The value for NSOpenGLCPSurfaceOrder for this GL context,  1 will
+  // render above the window and -1 will render below the window.
+  GLint surface_order_;
+  scoped_nsobject<NSOpenGLContext> nsgl_context_;
+  CGLContextObj cgl_context_; // weak, backed by |nsgl_context_|
+  bool is_vsync_disabled_;
+  scoped_ptr<CompositingIOSurfaceShaderPrograms> shader_program_cache_;
+};
+
+}  // namespace content
+
+#endif  // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_CONTEXT_MAC_H_
-- 
cgit v1.1