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

Unified Diff: ui/gfx/compositor/compositor_gl.h

Issue 7552039: Vend common GL context (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address reviewer comments. Created 9 years, 4 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/gfx/compositor/compositor.h ('k') | ui/gfx/compositor/compositor_gl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/compositor/compositor_gl.h
diff --git a/ui/gfx/compositor/compositor_gl.h b/ui/gfx/compositor/compositor_gl.h
index 0872d1ece0dda8042b6236c71244b570f823a0c0..cfa4756738bff30773e9a3082595b8b6de694442 100644
--- a/ui/gfx/compositor/compositor_gl.h
+++ b/ui/gfx/compositor/compositor_gl.h
@@ -8,6 +8,8 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/singleton.h"
+#include "base/memory/ref_counted.h"
#include "ui/gfx/compositor/compositor.h"
#include "ui/gfx/size.h"
@@ -22,9 +24,48 @@ namespace ui {
class CompositorGL;
class TextureProgramGL;
+// We share resources (such as shaders) between different Compositors via
+// GLContext sharing so that we only have to create/destroy them once.
+class COMPOSITOR_EXPORT SharedResources {
+ public:
+ static SharedResources* GetInstance();
+
+ bool MakeSharedContextCurrent();
+
+ // Creates a context that shares the resources hosted by this singleton.
+ scoped_refptr<gfx::GLContext> CreateContext(gfx::GLSurface* surface);
+
+ ui::TextureProgramGL* program_no_swizzle() {
+ return program_no_swizzle_.get();
+ }
+
+ ui::TextureProgramGL* program_swizzle() {
+ return program_swizzle_.get();
+ }
+
+ private:
+ friend struct DefaultSingletonTraits<SharedResources>;
+
+ SharedResources();
+ virtual ~SharedResources();
+
+ bool Initialize();
+ void Destroy();
+
+ bool initialized_;
+
+ scoped_refptr<gfx::GLContext> context_;
+ scoped_refptr<gfx::GLSurface> surface_;
+
+ scoped_ptr<ui::TextureProgramGL> program_swizzle_;
+ scoped_ptr<ui::TextureProgramGL> program_no_swizzle_;
+
+ DISALLOW_COPY_AND_ASSIGN(SharedResources);
+};
+
class COMPOSITOR_EXPORT TextureGL : public Texture {
public:
- explicit TextureGL(CompositorGL* compositor);
+ TextureGL();
virtual void SetCanvas(const SkCanvas& canvas,
const gfx::Point& origin,
@@ -39,7 +80,7 @@ class COMPOSITOR_EXPORT TextureGL : public Texture {
const gfx::Rect& clip_bounds_in_texture) OVERRIDE;
protected:
- TextureGL(CompositorGL* compositor, const gfx::Size& size);
+ explicit TextureGL(const gfx::Size& size);
virtual ~TextureGL();
// Actually draws the texture.
@@ -50,7 +91,6 @@ class COMPOSITOR_EXPORT TextureGL : public Texture {
unsigned int texture_id_;
gfx::Size size_;
- CompositorGL* compositor_;
private:
DISALLOW_COPY_AND_ASSIGN(TextureGL);
@@ -64,8 +104,8 @@ class COMPOSITOR_EXPORT CompositorGL : public Compositor {
void MakeCurrent();
gfx::Size GetSize();
- TextureProgramGL* program_no_swizzle();
- TextureProgramGL* program_swizzle();
+ protected:
+ virtual void OnWidgetSizeChanged() OVERRIDE;
private:
// Overridden from Compositor.
@@ -74,14 +114,11 @@ class COMPOSITOR_EXPORT CompositorGL : public Compositor {
virtual void NotifyEnd() OVERRIDE;
virtual void Blur(const gfx::Rect& bounds) OVERRIDE;
virtual void SchedulePaint() OVERRIDE;
- virtual void OnWidgetSizeChanged(const gfx::Size& size) OVERRIDE;
// The GL context used for compositing.
scoped_refptr<gfx::GLSurface> gl_surface_;
scoped_refptr<gfx::GLContext> gl_context_;
- gfx::Size size_;
-
// Keep track of whether compositing has started or not.
bool started_;
« no previous file with comments | « ui/gfx/compositor/compositor.h ('k') | ui/gfx/compositor/compositor_gl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698