summaryrefslogtreecommitdiffstats
path: root/o3d
diff options
context:
space:
mode:
authormilligan@google.com <milligan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-22 18:58:08 +0000
committermilligan@google.com <milligan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-22 18:58:08 +0000
commitbd513291051d0d75c7a2052aa98fa2ce2742f8c3 (patch)
tree61cd63ea56c6c02bfba4932a290b1fabd57158ee /o3d
parent01ac68fa4b00341fc5afc63cc6e8a16bf9d2d5c8 (diff)
downloadchromium_src-bd513291051d0d75c7a2052aa98fa2ce2742f8c3.zip
chromium_src-bd513291051d0d75c7a2052aa98fa2ce2742f8c3.tar.gz
chromium_src-bd513291051d0d75c7a2052aa98fa2ce2742f8c3.tar.bz2
Baby steps toward o2d and o3d dynamic switching in the video accelerator
browser plugin. This step rolls the o2d renderer and the gl renderer into the same linux plugin. Unfortunately the code path for which one gets used is still controlled by a compile time switch. That switch is force_cairo which is set to 0 by default (meaning o3d) in common.gypi. Review URL: http://codereview.chromium.org/6532010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75614 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r--o3d/build/common.gypi25
-rw-r--r--o3d/converter/cross/converter.cc9
-rw-r--r--o3d/converter/cross/renderer_stub.cc9
-rw-r--r--o3d/core/core.gyp2
-rw-r--r--o3d/core/cross/cairo/renderer_cairo.cc4
-rw-r--r--o3d/core/cross/class_manager.cc4
-rw-r--r--o3d/core/cross/client_info.h7
-rw-r--r--o3d/core/cross/gl/renderer_gl.cc7
-rw-r--r--o3d/core/cross/renderer_platform.h6
-rw-r--r--o3d/core/cross/renderer_test.cc4
-rw-r--r--o3d/import/cross/collada_conditioner.cc4
-rw-r--r--o3d/import/import.gyp12
-rw-r--r--o3d/plugin/idl/idl.gyp2
-rw-r--r--o3d/tests/common/linux/testing_common.cc6
14 files changed, 47 insertions, 54 deletions
diff --git a/o3d/build/common.gypi b/o3d/build/common.gypi
index e4bb0dd..833d76e 100644
--- a/o3d/build/common.gypi
+++ b/o3d/build/common.gypi
@@ -29,6 +29,7 @@
# 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
@@ -38,6 +39,7 @@
'cgdir': 'third_party/cg/files/win',
'renderer%': 'd3d9',
'swiftshaderdir': 'o3d-internal/third_party/swiftshader/files',
+ 'support_cairo%' : 0,
},
],
['OS == "mac"',
@@ -45,6 +47,7 @@
'cgdir': 'third_party/cg/files/mac',
'renderer%': 'gl',
'swiftshaderdir': '',
+ 'support_cairo%' : 0,
},
],
['OS == "linux"',
@@ -52,12 +55,15 @@
'cgdir': 'third_party/cg/files/linux',
'renderer%': 'gl',
'swiftshaderdir': '',
+ 'support_cairo%' : 1,
},
],
],
},
'o3d_in_chrome%': '<(o3d_in_chrome)',
'renderer%': '<(renderer)',
+ 'support_cairo%': '<(support_cairo)',
+ 'force_cairo%': '<(force_cairo)',
'cgdir%': '<(cgdir)',
'gles2_backend%': '<(gles2_backend)',
'swiftshaderdir%': '<(swiftshaderdir)',
@@ -95,24 +101,31 @@
}],
],
'conditions' : [
- ['renderer == "d3d9"',
+ ['support_cairo == 1',
{
'defines': [
- 'RENDERER_D3D9',
+ 'SUPPORT_CAIRO',
],
},
],
- ['renderer == "gl"',
+ ['force_cairo == 1',
{
'defines': [
- 'RENDERER_GL',
+ 'FORCE_CAIRO',
],
},
],
- ['renderer == "cairo"',
+ ['renderer == "d3d9"',
{
'defines': [
- 'RENDERER_CAIRO',
+ 'RENDERER_D3D9',
+ ],
+ },
+ ],
+ ['renderer == "gl"',
+ {
+ 'defines': [
+ 'RENDERER_GL',
],
},
],
diff --git a/o3d/converter/cross/converter.cc b/o3d/converter/cross/converter.cc
index 63e52a1..68969f2 100644
--- a/o3d/converter/cross/converter.cc
+++ b/o3d/converter/cross/converter.cc
@@ -279,12 +279,7 @@ bool Convert(const FilePath& in_filename,
// Collect error messages.
ErrorCollector error_collector(&service_locator);
- scoped_ptr<Renderer> renderer(
-#if !defined(RENDERER_CAIRO)
- Renderer::CreateDefaultRenderer(&service_locator));
-#else
- RendererStub::CreateDefault(&service_locator));
-#endif
+ scoped_ptr<Renderer> renderer(RendererStub::CreateDefault(&service_locator));
renderer->InitCommon();
Pack::Ref pack(object_manager.CreatePack());
@@ -476,7 +471,7 @@ bool Verify(const FilePath& in_filename,
ErrorCollector error_collector(&service_locator);
scoped_ptr<Renderer> renderer(
- Renderer::CreateDefaultRenderer(&service_locator));
+ RendererStub::CreateDefault(&service_locator));
renderer->InitCommon();
Pack::Ref pack(object_manager.CreatePack());
diff --git a/o3d/converter/cross/renderer_stub.cc b/o3d/converter/cross/renderer_stub.cc
index c7c9f4c..0155068 100644
--- a/o3d/converter/cross/renderer_stub.cc
+++ b/o3d/converter/cross/renderer_stub.cc
@@ -211,13 +211,4 @@ const int* RendererStub::GetRGBAUByteNSwizzleTable() {
return swizzle_table;
}
-// TODO(fransiskusx): This violates the One Definition Rule.
-#if !defined(RENDERER_CAIRO)
-// This is a factory function for creating Renderer objects. Since
-// we're implementing a stub renderer, we only ever return a stub renderer.
-Renderer* Renderer::CreateDefaultRenderer(ServiceLocator* service_locator) {
- return RendererStub::CreateDefault(service_locator);
-}
-#endif
-
} // namespace o3d
diff --git a/o3d/core/core.gyp b/o3d/core/core.gyp
index 9e544c3..5a2c05d 100644
--- a/o3d/core/core.gyp
+++ b/o3d/core/core.gyp
@@ -470,7 +470,7 @@
],
},
],
- ['renderer == "cairo"',
+ ['support_cairo == 1',
{
'sources': [
'cross/cairo/install_check.cc',
diff --git a/o3d/core/cross/cairo/renderer_cairo.cc b/o3d/core/cross/cairo/renderer_cairo.cc
index 68ebde9..fb31512 100644
--- a/o3d/core/cross/cairo/renderer_cairo.cc
+++ b/o3d/core/cross/cairo/renderer_cairo.cc
@@ -41,10 +41,6 @@
namespace o3d {
-Renderer* Renderer::CreateDefaultRenderer(ServiceLocator* service_locator) {
- return o2d::RendererCairo::CreateDefault(service_locator);
-}
-
namespace o2d {
RendererCairo::RendererCairo(ServiceLocator* service_locator)
diff --git a/o3d/core/cross/class_manager.cc b/o3d/core/cross/class_manager.cc
index 3b36a8c..7751e96 100644
--- a/o3d/core/cross/class_manager.cc
+++ b/o3d/core/cross/class_manager.cc
@@ -66,7 +66,7 @@
#include "core/cross/transform.h"
#include "core/cross/tree_traversal.h"
#include "core/cross/viewport.h"
-#if defined(RENDERER_CAIRO)
+#if defined(SUPPORT_CAIRO)
#include "core/cross/cairo/layer.h"
#endif
@@ -183,7 +183,7 @@ ClassManager::ClassManager(ServiceLocator* service_locator)
AddTypedClass<Viewport>();
// Specific Objects for Cairo
-#if defined(RENDERER_CAIRO)
+#if defined(SUPPORT_CAIRO)
AddTypedClass<o2d::Layer>();
#endif
}
diff --git a/o3d/core/cross/client_info.h b/o3d/core/cross/client_info.h
index 396d805..6b4326c 100644
--- a/o3d/core/cross/client_info.h
+++ b/o3d/core/cross/client_info.h
@@ -77,8 +77,13 @@ class ClientInfo {
// Whether render in 2d Mode
bool render_2d() const {
-#if defined(RENDERER_CAIRO)
+#if defined(SUPPORT_CAIRO) && defined(FORCE_CAIRO)
+ // Force Cairo o2d mode for testing purposes
return true;
+#elif defined(SUPPORT_CAIRO)
+ // Some day when we have fallback from o3d to o2d,
+ // this will have to support logic returning actual o2d vs. o3d mode.
+ return false;
#else
return false;
#endif
diff --git a/o3d/core/cross/gl/renderer_gl.cc b/o3d/core/cross/gl/renderer_gl.cc
index 098f724..fa192d8 100644
--- a/o3d/core/cross/gl/renderer_gl.cc
+++ b/o3d/core/cross/gl/renderer_gl.cc
@@ -37,6 +37,9 @@
#include "core/cross/gl/renderer_gl.h"
+#ifdef SUPPORT_CAIRO
+#include "core/cross/cairo/renderer_cairo.h"
+#endif
#include "core/cross/error.h"
#include "core/cross/gl/buffer_gl.h"
#include "core/cross/gl/draw_element_gl.h"
@@ -1522,7 +1525,11 @@ const int* RendererGL::GetRGBAUByteNSwizzleTable() {
// This is a factory function for creating Renderer objects. Since
// we're implementing GL, we only ever return a GL renderer.
Renderer* Renderer::CreateDefaultRenderer(ServiceLocator* service_locator) {
+#ifdef FORCE_CAIRO
+ return o2d::RendererCairo::CreateDefault(service_locator);
+#else
return RendererGL::CreateDefault(service_locator);
+#endif
}
#ifdef OS_MACOSX
diff --git a/o3d/core/cross/renderer_platform.h b/o3d/core/cross/renderer_platform.h
index 4a4f58d..3a2bd24 100644
--- a/o3d/core/cross/renderer_platform.h
+++ b/o3d/core/cross/renderer_platform.h
@@ -67,14 +67,16 @@
#error Platform not recognized.
#endif
+#if defined(SUPPORT_CAIRO)
+#include "core/cross/cairo/renderer_cairo.h"
+#endif
+
#if defined(RENDERER_D3D9) && defined(OS_WIN)
#include "core/win/d3d9/renderer_d3d9.h"
#elif defined(RENDERER_GL)
#include "core/cross/gl/renderer_gl.h"
#elif defined(RENDERER_GLES2)
#include "core/cross/gles2/renderer_gles2.h"
-#elif defined(RENDERER_CAIRO)
-#include "core/cross/cairo/renderer_cairo.h"
#else
#error Renderer not recognized.
#endif
diff --git a/o3d/core/cross/renderer_test.cc b/o3d/core/cross/renderer_test.cc
index 9eb0942..6fa1efb 100644
--- a/o3d/core/cross/renderer_test.cc
+++ b/o3d/core/cross/renderer_test.cc
@@ -89,9 +89,11 @@ 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
@@ -102,8 +104,10 @@ 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/import/cross/collada_conditioner.cc b/o3d/import/cross/collada_conditioner.cc
index 796c199..b5fef31 100644
--- a/o3d/import/cross/collada_conditioner.cc
+++ b/o3d/import/cross/collada_conditioner.cc
@@ -542,7 +542,6 @@ bool ColladaConditioner::CompileCg(const FilePath& filename,
const String& shader_source,
const String& vs_entry,
const String& ps_entry) {
-#if !defined(RENDERER_CAIRO)
bool retval = false;
String shader_source_cg = shader_source;
shader_source_cg +=
@@ -575,8 +574,5 @@ bool ColladaConditioner::CompileCg(const FilePath& filename,
}
cgDestroyContext(context);
return retval;
-#else
- return false;
-#endif
}
} // namespace o3d
diff --git a/o3d/import/import.gyp b/o3d/import/import.gyp
index 08fb4da..c616c3b 100644
--- a/o3d/import/import.gyp
+++ b/o3d/import/import.gyp
@@ -30,6 +30,7 @@
'../../<(pngdir)/libpng.gyp:libpng',
'../../<(zlibdir)/zlib.gyp:zlib',
'../compiler/technique/technique.gyp:o3dTechnique',
+ '../build/libs.gyp:cg_libs',
],
'sources': [
'cross/collada_conditioner.cc',
@@ -48,17 +49,6 @@
'cross/zip_archive.cc',
'cross/zip_archive.h',
],
-
- 'conditions' :[
- ['renderer != "cairo"',
- {
- 'dependencies': [
- '../build/libs.gyp:cg_libs',
- ],
- },
- ],
- ],
-
'conditions' : [
['OS == "win"',
{
diff --git a/o3d/plugin/idl/idl.gyp b/o3d/plugin/idl/idl.gyp
index 453486d..c70dbad 100644
--- a/o3d/plugin/idl/idl.gyp
+++ b/o3d/plugin/idl/idl.gyp
@@ -14,7 +14,7 @@
'<!@(python get_idl_files.py)',
],
'conditions': [
- ['renderer == "cairo"',
+ ['support_cairo == 1',
{
'idl_files': [
'layer.idl',
diff --git a/o3d/tests/common/linux/testing_common.cc b/o3d/tests/common/linux/testing_common.cc
index 1fe628d..d563ce6 100644
--- a/o3d/tests/common/linux/testing_common.cc
+++ b/o3d/tests/common/linux/testing_common.cc
@@ -55,14 +55,11 @@ o3d::DisplayWindow* g_display_window = NULL;
Display *g_display = NULL;
Window g_window = 0;
-#if !defined(RENDERER_CAIRO)
static char kOffScreenRenderer[] = "O3D_D3D9_OFF_SCREEN";
-#endif
extern int test_main(int argc, char **argv);
int main(int argc, char *argv[]) {
-#if !defined(RENDERER_CAIRO)
std::string error;
if (!o3d::RendererInstallCheck(&error)) {
return false;
@@ -171,7 +168,4 @@ int main(int argc, char *argv[]) {
::XCloseDisplay(g_display);
return ret;
-#else
- return 1;
-#endif
}