diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-30 06:28:34 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-30 06:28:34 +0000 |
commit | b945425ee28d986f665f9a51ceadbc787ddef0e2 (patch) | |
tree | c5155bc836fe8aaf1df04de46f6b1582b6d607b3 /ui | |
parent | 08e0dc220ea1635a6d7c5c0d1650832b8e495617 (diff) | |
download | chromium_src-b945425ee28d986f665f9a51ceadbc787ddef0e2.zip chromium_src-b945425ee28d986f665f9a51ceadbc787ddef0e2.tar.gz chromium_src-b945425ee28d986f665f9a51ceadbc787ddef0e2.tar.bz2 |
Makes TestWebGraphicsContext3D::initialize create a stub context and
surface. This is needed otherwise we crash when code tries to access
the current context. Also makes GLContextStub::MakeCurrent set itself
as the current context.
BUG=104360
TEST=none
R=piman@chromium.org,kbr@chromium.org
Review URL: http://codereview.chromium.org/8733010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112145 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gfx/compositor/compositor.gyp | 3 | ||||
-rw-r--r-- | ui/gfx/compositor/test_web_graphics_context_3d.cc | 21 | ||||
-rw-r--r-- | ui/gfx/compositor/test_web_graphics_context_3d.h | 13 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context.cc | 3 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_stub.cc | 1 |
5 files changed, 35 insertions, 6 deletions
diff --git a/ui/gfx/compositor/compositor.gyp b/ui/gfx/compositor/compositor.gyp index 20c6ab7..648d25b 100644 --- a/ui/gfx/compositor/compositor.gyp +++ b/ui/gfx/compositor/compositor.gyp @@ -60,7 +60,8 @@ 'layer_animator.h', 'screen_rotation.cc', 'screen_rotation.h', - # This is needed for ui tests, so it's always compiled. + # UI tests need TestWebGraphicsContext3D, so we always build it. + 'test_web_graphics_context_3d.cc', 'test_web_graphics_context_3d.h', ], 'conditions': [ diff --git a/ui/gfx/compositor/test_web_graphics_context_3d.cc b/ui/gfx/compositor/test_web_graphics_context_3d.cc new file mode 100644 index 0000000..976919d --- /dev/null +++ b/ui/gfx/compositor/test_web_graphics_context_3d.cc @@ -0,0 +1,21 @@ +// Copyright (c) 2011 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/gfx/compositor/test_web_graphics_context_3d.h" + +#include "ui/gfx/gl/gl_context_stub.h" +#include "ui/gfx/gl/gl_surface_stub.h" + +namespace ui { + +bool TestWebGraphicsContext3D::initialize(Attributes attributes, + WebKit::WebView* view, + bool render_directly_to_web_view) { + gl_surface_ = new gfx::GLSurfaceStub; + gl_context_ = new gfx::GLContextStub; + gl_context_->MakeCurrent(gl_surface_.get()); + return true; +} + +} // namespace ui diff --git a/ui/gfx/compositor/test_web_graphics_context_3d.h b/ui/gfx/compositor/test_web_graphics_context_3d.h index 31e6725..3b1c929 100644 --- a/ui/gfx/compositor/test_web_graphics_context_3d.h +++ b/ui/gfx/compositor/test_web_graphics_context_3d.h @@ -7,10 +7,16 @@ #pragma once #include "base/logging.h" +#include "base/memory/ref_counted.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "ui/gfx/gl/gl_bindings.h" +namespace gfx { +class GLContext; +class GLSurface; +} + namespace ui { // WebGraphicsContext3D that does nothing. Suitable for testing. @@ -21,9 +27,7 @@ class TestWebGraphicsContext3D : public WebKit::WebGraphicsContext3D { virtual bool initialize(Attributes attributes, WebKit::WebView* view, - bool render_directly_to_web_view) { - return false; - } + bool render_directly_to_web_view); virtual bool makeContextCurrent() { return true; } virtual int width() { return 0; } virtual int height() { return 0; } @@ -457,6 +461,9 @@ class TestWebGraphicsContext3D : public WebKit::WebGraphicsContext3D { virtual void deleteTexture(WebKit::WebGLId id) {} private: + scoped_refptr<gfx::GLContext> gl_context_; + scoped_refptr<gfx::GLSurface> gl_surface_; + DISALLOW_COPY_AND_ASSIGN(TestWebGraphicsContext3D); }; diff --git a/ui/gfx/gl/gl_context.cc b/ui/gfx/gl/gl_context.cc index 9fc5411..e3b9612 100644 --- a/ui/gfx/gl/gl_context.cc +++ b/ui/gfx/gl/gl_context.cc @@ -69,8 +69,7 @@ GLShareGroup* GLContext::share_group() { return share_group_.get(); } -bool GLContext::LosesAllContextsOnContextLost() -{ +bool GLContext::LosesAllContextsOnContextLost() { switch (GetGLImplementation()) { case kGLImplementationDesktopGL: return false; diff --git a/ui/gfx/gl/gl_context_stub.cc b/ui/gfx/gl/gl_context_stub.cc index 5067413..94c9e1f 100644 --- a/ui/gfx/gl/gl_context_stub.cc +++ b/ui/gfx/gl/gl_context_stub.cc @@ -21,6 +21,7 @@ void GLContextStub::Destroy() { } bool GLContextStub::MakeCurrent(GLSurface* surface) { + SetCurrent(this, surface); return true; } |