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

Unified Diff: ui/compositor/test/test_compositor_host_ozone.cc

Issue 17932004: Support ozone=1 compositor_unittests with OSMesa (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: include order version Created 7 years, 6 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/compositor/compositor.gyp ('k') | ui/gl/gl.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/test/test_compositor_host_ozone.cc
diff --git a/ui/compositor/test/test_compositor_host_ozone.cc b/ui/compositor/test/test_compositor_host_ozone.cc
new file mode 100644
index 0000000000000000000000000000000000000000..044ed51bbcc084a0ca7df3f3745d89aa5b989741
--- /dev/null
+++ b/ui/compositor/test/test_compositor_host_ozone.cc
@@ -0,0 +1,85 @@
+// 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.
+
+#include "ui/compositor/test/test_compositor_host.h"
+
+#include "base/basictypes.h"
+#include "base/bind.h"
+#include "base/compiler_specific.h"
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/message_loop.h"
+#include "ui/compositor/compositor.h"
+#include "ui/gfx/rect.h"
+
+namespace ui {
+
+class TestCompositorHostOzone : public TestCompositorHost,
+ public CompositorDelegate {
+ public:
+ TestCompositorHostOzone(const gfx::Rect& bounds);
+ virtual ~TestCompositorHostOzone();
+
+ private:
+ // Overridden from TestCompositorHost:
+ virtual void Show() OVERRIDE;
+ virtual ui::Compositor* GetCompositor() OVERRIDE;
+
+ // Overridden from CompositorDelegate:
+ virtual void ScheduleDraw() OVERRIDE;
+
+ void Draw();
+
+ gfx::Rect bounds_;
+
+ scoped_ptr<ui::Compositor> compositor_;
+
+ base::WeakPtrFactory<TestCompositorHostOzone> method_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestCompositorHostOzone);
+};
+
+TestCompositorHostOzone::TestCompositorHostOzone(const gfx::Rect& bounds)
+ : bounds_(bounds), method_factory_(this) {}
+
+TestCompositorHostOzone::~TestCompositorHostOzone() {}
+
+void TestCompositorHostOzone::Show() {
+ // Ozone should rightly have a backing native framebuffer
+ // An in-memory array draw into by OSMesa is a reasonble
+ // fascimile of a dumb framebuffer at present.
+ // GLSurface will allocate the array so long as it is provided
+ // with a non-0 widget.
+ // TODO(rjkroege): Use a "real" ozone widget when it is
+ // available: http://crbug.com/255128
+ compositor_.reset(new ui::Compositor(this, 1));
+ compositor_->SetScaleAndSize(1.0f, bounds_.size());
+}
+
+ui::Compositor* TestCompositorHostOzone::GetCompositor() {
+ return compositor_.get();
+}
+
+void TestCompositorHostOzone::ScheduleDraw() {
+ DCHECK(!ui::Compositor::WasInitializedWithThread());
+ if (!method_factory_.HasWeakPtrs()) {
+ base::MessageLoopForUI::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&TestCompositorHostOzone::Draw,
+ method_factory_.GetWeakPtr()));
+ }
+}
+
+void TestCompositorHostOzone::Draw() {
+ if (compositor_.get())
+ compositor_->Draw();
+}
+
+// static
+TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) {
+ return new TestCompositorHostOzone(bounds);
+}
+
+} // namespace ui
« no previous file with comments | « ui/compositor/compositor.gyp ('k') | ui/gl/gl.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698