summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-07 02:17:53 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-07 02:17:53 +0000
commit905e19a5d13fc8e2322cab9d01559b100591a4b9 (patch)
treeb32b9822ec7e63101909b4553da325b7eaaac8e4 /ui
parent4a6bef33b6897ceff27eee304afe1a6da5fee4ff (diff)
downloadchromium_src-905e19a5d13fc8e2322cab9d01559b100591a4b9.zip
chromium_src-905e19a5d13fc8e2322cab9d01559b100591a4b9.tar.gz
chromium_src-905e19a5d13fc8e2322cab9d01559b100591a4b9.tar.bz2
gfx::Compositor: SchedulePaint.
Add CompositorDelegate as an interface between the compositor and its owner, and implement SchedulePaint through the delegate. BUG=none TEST=none Review URL: http://codereview.chromium.org/7770002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99899 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/gfx/compositor/compositor.cc3
-rw-r--r--ui/gfx/compositor/compositor.h21
-rw-r--r--ui/gfx/compositor/compositor_gl.cc15
-rw-r--r--ui/gfx/compositor/compositor_gl.h5
-rw-r--r--ui/gfx/compositor/compositor_win.cc20
5 files changed, 37 insertions, 27 deletions
diff --git a/ui/gfx/compositor/compositor.cc b/ui/gfx/compositor/compositor.cc
index 1d68ffc..ed7a4dd 100644
--- a/ui/gfx/compositor/compositor.cc
+++ b/ui/gfx/compositor/compositor.cc
@@ -7,7 +7,8 @@
namespace ui {
// static
-Compositor* Compositor::Create(gfx::AcceleratedWidget widget,
+Compositor* Compositor::Create(CompositorDelegate* delegate,
+ gfx::AcceleratedWidget widget,
const gfx::Size& size) {
return NULL;
}
diff --git a/ui/gfx/compositor/compositor.h b/ui/gfx/compositor/compositor.h
index 01e20e7..a1210cd 100644
--- a/ui/gfx/compositor/compositor.h
+++ b/ui/gfx/compositor/compositor.h
@@ -63,6 +63,13 @@ class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> {
friend class base::RefCounted<Texture>;
};
+// An interface to allow the compositor to communicate with its owner.
+class COMPOSITOR_EXPORT CompositorDelegate {
+ public:
+ // Requests the owner to schedule a paint.
+ virtual void ScheduleCompositorPaint() = 0;
+};
+
// Compositor object to take care of GPU painting.
// A Browser compositor object is responsible for generating the final
// displayable form of pixels comprising a single widget's contents. It draws an
@@ -71,7 +78,8 @@ class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> {
class COMPOSITOR_EXPORT Compositor : public base::RefCounted<Compositor> {
public:
// Create a compositor from the provided handle.
- static Compositor* Create(gfx::AcceleratedWidget widget,
+ static Compositor* Create(CompositorDelegate* delegate,
+ gfx::AcceleratedWidget widget,
const gfx::Size& size);
// Creates a new texture. The caller owns the returned object.
@@ -87,7 +95,9 @@ class COMPOSITOR_EXPORT Compositor : public base::RefCounted<Compositor> {
virtual void Blur(const gfx::Rect& bounds) = 0;
// Schedules a paint on the widget this Compositor was created for.
- virtual void SchedulePaint() = 0;
+ virtual void SchedulePaint() {
+ delegate_->ScheduleCompositorPaint();
+ }
// Notifies the compositor that the size of the widget that it is
// drawing to has changed.
@@ -100,12 +110,17 @@ class COMPOSITOR_EXPORT Compositor : public base::RefCounted<Compositor> {
const gfx::Size& size() { return size_; }
protected:
- explicit Compositor(const gfx::Size& size) : size_(size) {}
+ Compositor(CompositorDelegate* delegate, const gfx::Size& size)
+ : delegate_(delegate),
+ size_(size) {}
virtual ~Compositor() {}
virtual void OnWidgetSizeChanged() = 0;
+ CompositorDelegate* delegate() { return delegate_; }
+
private:
+ CompositorDelegate* delegate_;
gfx::Size size_;
friend class base::RefCounted<Compositor>;
diff --git a/ui/gfx/compositor/compositor_gl.cc b/ui/gfx/compositor/compositor_gl.cc
index ee1a38d..1c4833f 100644
--- a/ui/gfx/compositor/compositor_gl.cc
+++ b/ui/gfx/compositor/compositor_gl.cc
@@ -441,9 +441,10 @@ void TextureGL::DrawInternal(const ui::TextureProgramGL& program,
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
-CompositorGL::CompositorGL(gfx::AcceleratedWidget widget,
+CompositorGL::CompositorGL(CompositorDelegate* delegate,
+ gfx::AcceleratedWidget widget,
const gfx::Size& size)
- : Compositor(size),
+ : Compositor(delegate, size),
started_(false) {
gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, widget);
gl_context_ = SharedResources::GetInstance()->
@@ -493,18 +494,14 @@ void CompositorGL::Blur(const gfx::Rect& bounds) {
NOTIMPLEMENTED();
}
-void CompositorGL::SchedulePaint() {
- // TODO: X doesn't provide coalescing of regions, its left to the toolkit.
- NOTIMPLEMENTED();
-}
-
// static
-Compositor* Compositor::Create(gfx::AcceleratedWidget widget,
+Compositor* Compositor::Create(CompositorDelegate* owner,
+ gfx::AcceleratedWidget widget,
const gfx::Size& size) {
if (SharedResources::GetInstance() == NULL)
return NULL;
else
- return new CompositorGL(widget, size);
+ return new CompositorGL(owner, widget, size);
}
} // namespace ui
diff --git a/ui/gfx/compositor/compositor_gl.h b/ui/gfx/compositor/compositor_gl.h
index c89d47b..cee38c4 100644
--- a/ui/gfx/compositor/compositor_gl.h
+++ b/ui/gfx/compositor/compositor_gl.h
@@ -93,7 +93,9 @@ class COMPOSITOR_EXPORT TextureGL : public Texture {
class COMPOSITOR_EXPORT CompositorGL : public Compositor {
public:
- CompositorGL(gfx::AcceleratedWidget widget, const gfx::Size& size);
+ CompositorGL(CompositorDelegate* delegate,
+ gfx::AcceleratedWidget widget,
+ const gfx::Size& size);
virtual ~CompositorGL();
void MakeCurrent();
@@ -108,7 +110,6 @@ class COMPOSITOR_EXPORT CompositorGL : public Compositor {
virtual void NotifyStart() OVERRIDE;
virtual void NotifyEnd() OVERRIDE;
virtual void Blur(const gfx::Rect& bounds) OVERRIDE;
- virtual void SchedulePaint() OVERRIDE;
// The GL context used for compositing.
scoped_refptr<gfx::GLSurface> gl_surface_;
diff --git a/ui/gfx/compositor/compositor_win.cc b/ui/gfx/compositor/compositor_win.cc
index 3c0a2ff..ae145a9 100644
--- a/ui/gfx/compositor/compositor_win.cc
+++ b/ui/gfx/compositor/compositor_win.cc
@@ -86,7 +86,8 @@ class ViewTexture : public Texture {
// D3D 10 Compositor implementation.
class CompositorWin : public Compositor {
public:
- CompositorWin(gfx::AcceleratedWidget widget,
+ CompositorWin(CompositorDelegate* delegate,
+ gfx::AcceleratedWidget widget,
const gfx::Size& size);
void Init();
@@ -104,7 +105,6 @@ class CompositorWin : public Compositor {
virtual void NotifyStart() OVERRIDE;
virtual void NotifyEnd() OVERRIDE;
virtual void Blur(const gfx::Rect& bounds) OVERRIDE;
- virtual void SchedulePaint() OVERRIDE;
protected:
virtual void OnWidgetSizeChanged() OVERRIDE;
@@ -321,9 +321,10 @@ void ViewTexture::CreateVertexBufferForRegion(const gfx::Rect& bounds) {
vertex_buffer_.Receive()));
}
-CompositorWin::CompositorWin(gfx::AcceleratedWidget widget,
+CompositorWin::CompositorWin(CompositorDelegate* delegate,
+ gfx::AcceleratedWidget widget,
const gfx::Size& size)
- : Compositor(size),
+ : Compositor(delegate, size),
host_(widget),
technique_(NULL) {
}
@@ -499,12 +500,6 @@ void CompositorWin::Blur(const gfx::Rect& bounds) {
#endif
}
-void CompositorWin::SchedulePaint() {
- RECT bounds;
- GetClientRect(host_, &bounds);
- InvalidateRect(host_, &bounds, FALSE);
-}
-
void CompositorWin::OnWidgetSizeChanged() {
dest_render_target_view_ = NULL;
depth_stencil_buffer_ = NULL;
@@ -796,9 +791,10 @@ ID3D10Buffer* CompositorWin::CreateVertexBufferForRegion(
} // namespace
// static
-Compositor* Compositor::Create(gfx::AcceleratedWidget widget,
+Compositor* Compositor::Create(CompositorDelegate* delegate,
+ gfx::AcceleratedWidget widget,
const gfx::Size& size) {
- CompositorWin* compositor = new CompositorWin(widget, size);
+ CompositorWin* compositor = new CompositorWin(delegate, widget, size);
compositor->Init();
return compositor;
}