summaryrefslogtreecommitdiffstats
path: root/o3d
diff options
context:
space:
mode:
authormilligan@google.com <milligan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 17:20:52 +0000
committermilligan@google.com <milligan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 17:20:52 +0000
commit06d226e82b3b1f54c22339bdc39ffe97294a3c6a (patch)
tree5638c823aa16a3488671376e2227bd5c11de5bb0 /o3d
parent1fac8c3b0aa869bee4a04b293f0585210b7ff682 (diff)
downloadchromium_src-06d226e82b3b1f54c22339bdc39ffe97294a3c6a.zip
chromium_src-06d226e82b3b1f54c22339bdc39ffe97294a3c6a.tar.gz
chromium_src-06d226e82b3b1f54c22339bdc39ffe97294a3c6a.tar.bz2
Remove FORCE_CAIRO flag and replace with a new feature.
The possible feature values are: RenderMode=Auto RenderMode=2D RenderMode=3D The default if no feature is specified is 3D for backwards compatibility. Review URL: http://codereview.chromium.org/6576007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75895 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r--o3d/build/common.gypi9
-rw-r--r--o3d/core/cross/features.cc12
-rw-r--r--o3d/core/cross/features.h5
-rw-r--r--o3d/core/cross/renderer.h6
-rw-r--r--o3d/core/cross/renderer_test.cc4
-rw-r--r--o3d/plugin/cross/o3d_glue.cc33
6 files changed, 41 insertions, 28 deletions
diff --git a/o3d/build/common.gypi b/o3d/build/common.gypi
index 833d76e..2afc49a 100644
--- a/o3d/build/common.gypi
+++ b/o3d/build/common.gypi
@@ -29,7 +29,6 @@
# If the DEPS file exists two levels up, then we're in a Chrome tree.
'o3d_in_chrome%': '<!(python <(DEPTH)/o3d/build/file_exists.py <(DEPTH)/DEPS)',
'gles2_backend%': 'desktop_gl',
- 'force_cairo%' : 0,
'conditions' : [
# These have to come first because GYP doesn't like it when
# they're part of the same conditional as a conditions clause that
@@ -63,7 +62,6 @@
'o3d_in_chrome%': '<(o3d_in_chrome)',
'renderer%': '<(renderer)',
'support_cairo%': '<(support_cairo)',
- 'force_cairo%': '<(force_cairo)',
'cgdir%': '<(cgdir)',
'gles2_backend%': '<(gles2_backend)',
'swiftshaderdir%': '<(swiftshaderdir)',
@@ -108,13 +106,6 @@
],
},
],
- ['force_cairo == 1',
- {
- 'defines': [
- 'FORCE_CAIRO',
- ],
- },
- ],
['renderer == "d3d9"',
{
'defines': [
diff --git a/o3d/core/cross/features.cc b/o3d/core/cross/features.cc
index 7feb248..308c331 100644
--- a/o3d/core/cross/features.cc
+++ b/o3d/core/cross/features.cc
@@ -49,7 +49,8 @@ Features::Features(ServiceLocator* service_locator)
windowless_(false),
not_anti_aliased_(false),
flip_textures_(true),
- init_status_(Renderer::SUCCESS) {
+ init_status_(Renderer::SUCCESS),
+ render_mode_(Renderer::RENDER_MODE_3D) {
// NOTE: For backward compatibility floating_point_textures and
// large_geometry default to true. o3djs.util.makeClients before 0.1.35.0
// does not set the o3d_features plugin parameters and therefore
@@ -98,6 +99,15 @@ void Features::ParseFeatures(const std::vector<std::string>& features,
int value;
StringToInt(arguments[0], &value);
init_status_ = static_cast<Renderer::InitStatus>(value);
+ } else if (feature.compare("RenderMode") == 0 &&
+ arguments.size() == 1) {
+ if (arguments[0].compare("Auto") == 0) {
+ render_mode_ = Renderer::RENDER_MODE_AUTO;
+ } else if (arguments[0].compare("3D") == 0) {
+ render_mode_ = Renderer::RENDER_MODE_3D;
+ } else if (arguments[0].compare("2D") == 0) {
+ render_mode_ = Renderer::RENDER_MODE_2D;
+ }
}
}
}
diff --git a/o3d/core/cross/features.h b/o3d/core/cross/features.h
index efd3266..7aed90b 100644
--- a/o3d/core/cross/features.h
+++ b/o3d/core/cross/features.h
@@ -82,6 +82,10 @@ class Features {
return init_status_;
}
+ Renderer::RenderModes render_modes() const {
+ return render_mode_;
+ }
+
private:
// Parses the features strings.
// Parameters:
@@ -99,6 +103,7 @@ class Features {
bool not_anti_aliased_;
bool flip_textures_;
Renderer::InitStatus init_status_;
+ Renderer::RenderModes render_mode_;
DISALLOW_COPY_AND_ASSIGN(Features);
};
diff --git a/o3d/core/cross/renderer.h b/o3d/core/cross/renderer.h
index f006fb5..311fb6d 100644
--- a/o3d/core/cross/renderer.h
+++ b/o3d/core/cross/renderer.h
@@ -112,6 +112,12 @@ class Renderer {
DISPLAY_MODE_DEFAULT = 0
};
+ enum RenderModes {
+ RENDER_MODE_AUTO,
+ RENDER_MODE_3D,
+ RENDER_MODE_2D,
+ };
+
// A StateHandler takes a param and sets or resets a render state.
class StateHandler {
public:
diff --git a/o3d/core/cross/renderer_test.cc b/o3d/core/cross/renderer_test.cc
index 6fa1efb..9eb0942 100644
--- a/o3d/core/cross/renderer_test.cc
+++ b/o3d/core/cross/renderer_test.cc
@@ -89,11 +89,9 @@ TEST_F(RendererTest, InitAndDestroyRenderer) {
RendererD3D9* d3d_renderer = down_cast<RendererD3D9*>(renderer.get());
EXPECT_TRUE(d3d_renderer->d3d_device() != NULL);
#elif defined(RENDERER_GL)
-#if !defined(FORCE_CAIRO)
// test that the Cg Context was correctly created
RendererGL* gl_renderer = down_cast<RendererGL*>(renderer.get());
EXPECT_TRUE(gl_renderer->cg_context() != NULL);
-#endif
#elif defined(RENDERER_GLES2)
RendererGLES2* gles2_renderer = down_cast<RendererGLES2*>(renderer.get());
#endif
@@ -104,10 +102,8 @@ TEST_F(RendererTest, InitAndDestroyRenderer) {
// check that the renderer no longer had the D3D device.
EXPECT_FALSE(d3d_renderer->d3d_device() != NULL);
#elif defined(RENDERER_GL)
-#if !defined(FORCE_CAIRO)
// check that the renderer no longer has a Cg Context.
EXPECT_FALSE(gl_renderer->cg_context() != NULL);
-#endif
#elif defined(RENDERER_GLES2)
#if defined(GLES2_BACKEND_DESKTOP_GL)
#if defined(OS_LINUX)
diff --git a/o3d/plugin/cross/o3d_glue.cc b/o3d/plugin/cross/o3d_glue.cc
index 7666c71..d3da84d 100644
--- a/o3d/plugin/cross/o3d_glue.cc
+++ b/o3d/plugin/cross/o3d_glue.cc
@@ -262,23 +262,28 @@ void PluginObject::CreateRenderer(const o3d::DisplayWindow& display_window) {
DeleteRenderer();
renderer_init_status_ = o3d::Renderer::UNINITIALIZED;
-#if !defined(FORCE_CAIRO)
- if (!o3d::CheckConfig(npp_)) {
- renderer_init_status_ = o3d::Renderer::GPU_NOT_UP_TO_SPEC;
- } else {
- renderer_ = o3d::Renderer::CreateDefaultRenderer(&service_locator_);
- DCHECK(renderer_);
+ if (features_->render_modes() != Renderer::RENDER_MODE_2D) {
+ if (!o3d::CheckConfig(npp_)) {
+ renderer_init_status_ = o3d::Renderer::GPU_NOT_UP_TO_SPEC;
+ } else {
+ renderer_ = o3d::Renderer::CreateDefaultRenderer(&service_locator_);
+ DCHECK(renderer_);
- // Attempt to initialize renderer.
- renderer_init_status_ = renderer_->Init(display_window, false);
- if (renderer_init_status_ != o3d::Renderer::SUCCESS) {
- DeleteRenderer();
+ // Attempt to initialize renderer.
+ renderer_init_status_ = renderer_->Init(display_window, false);
+ if (renderer_init_status_ != o3d::Renderer::SUCCESS) {
+ DeleteRenderer();
+ }
}
+#if !defined(SUPPORT_CAIRO)
+ } else {
+ // The caller requested 2D only mode, but this platform does not support 2d
+ renderer_init_status_ = o3d::Renderer::INITIALIZATION_ERROR;
}
-#endif
-
-#if defined(SUPPORT_CAIRO)
- if (renderer_init_status_ != o3d::Renderer::SUCCESS) {
+#else
+ }
+ if ((renderer_init_status_ != o3d::Renderer::SUCCESS) &&
+ (features_->render_modes() != Renderer::RENDER_MODE_3D)) {
// Attempt to fall back to o2d renderer
renderer_ = o3d::Renderer::Create2DRenderer(&service_locator_);
if (renderer_) {