summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-08 03:05:33 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-08 03:05:33 +0000
commit24db0668435d565c02b8c3c9ca2cd343b5ae45ac (patch)
tree019c317fbb74905f20109b36b15c54257f8c7586
parent63436be709e8a2fad718301c444a02dbd6107dfd (diff)
downloadchromium_src-24db0668435d565c02b8c3c9ca2cd343b5ae45ac.zip
chromium_src-24db0668435d565c02b8c3c9ca2cd343b5ae45ac.tar.gz
chromium_src-24db0668435d565c02b8c3c9ca2cd343b5ae45ac.tar.bz2
Add nonPowerOfTwoTextures to clientInfo
so that video can decide to use power of 2 if it needs to. Review URL: http://codereview.chromium.org/164210 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22860 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--o3d/core/cross/client_info.h19
-rw-r--r--o3d/core/cross/client_info_test.cc14
-rw-r--r--o3d/core/cross/gl/renderer_gl.cc4
-rw-r--r--o3d/core/cross/renderer.cc8
-rw-r--r--o3d/core/cross/renderer.h9
-rw-r--r--o3d/core/cross/renderer_test.cc4
-rw-r--r--o3d/core/win/d3d9/renderer_d3d9.cc2
-rw-r--r--o3d/plugin/idl/client.idl11
8 files changed, 64 insertions, 7 deletions
diff --git a/o3d/core/cross/client_info.h b/o3d/core/cross/client_info.h
index 2fd8869..e8b24a9 100644
--- a/o3d/core/cross/client_info.h
+++ b/o3d/core/cross/client_info.h
@@ -48,7 +48,8 @@ class ClientInfo {
: num_objects_(0),
texture_memory_used_(0),
buffer_memory_used_(0),
- software_renderer_(false) {
+ software_renderer_(false),
+ non_power_of_two_textures_(false) {
}
// The number of objects the client is currently tracking.
@@ -71,6 +72,17 @@ class ClientInfo {
return software_renderer_;
}
+ // Whether or not the underlying GPU supports non power of 2 textures.
+ // NOTE: O3D always supports non power of 2 textures from a public API
+ // point of view and massages the data underneath to make this work.
+ // The point of this flag is mostly that if you are doing any kind of
+ // dynamic texture updating, like video, then you might want to use a
+ // power of two texture so O3D doesn't have to do extra work of converting
+ // your NPOT texture into a POT texture behind the scenes.
+ bool non_power_of_two_textures() const {
+ return non_power_of_two_textures_;
+ }
+
private:
friend class ClientInfoManager;
@@ -78,6 +90,7 @@ class ClientInfo {
int texture_memory_used_;
int buffer_memory_used_;
bool software_renderer_;
+ bool non_power_of_two_textures_;
};
// A class to manage the client info so other classes can easily look it up.
@@ -105,6 +118,10 @@ class ClientInfoManager {
client_info_.software_renderer_ = used;
}
+ void SetNonPowerOfTwoTextures(bool npot) {
+ client_info_.non_power_of_two_textures_ = npot;
+ }
+
private:
ServiceImplementation<ClientInfoManager> service_;
diff --git a/o3d/core/cross/client_info_test.cc b/o3d/core/cross/client_info_test.cc
index d83aa92..c24c406 100644
--- a/o3d/core/cross/client_info_test.cc
+++ b/o3d/core/cross/client_info_test.cc
@@ -77,6 +77,7 @@ TEST_F(ClientInfoManagerTest, Basic) {
EXPECT_EQ(0, client_info_manager->client_info().buffer_memory_used());
EXPECT_EQ(0, client_info_manager->client_info().num_objects());
EXPECT_FALSE(client_info_manager->client_info().software_renderer());
+ EXPECT_FALSE(client_info_manager->client_info().non_power_of_two_textures());
delete client_info_manager;
}
@@ -149,4 +150,17 @@ TEST_F(ClientInfoManagerTest, SetSoftwareRenderer) {
delete client_info_manager;
}
+TEST_F(ClientInfoManagerTest, SetNonPowerOfTwoTextures) {
+ ClientInfoManager* client_info_manager =
+ new ClientInfoManager(service_locator());
+ ASSERT_TRUE(client_info_manager != NULL);
+
+ client_info_manager->SetNonPowerOfTwoTextures(true);
+ EXPECT_TRUE(client_info_manager->client_info().non_power_of_two_textures());
+ client_info_manager->SetNonPowerOfTwoTextures(false);
+ EXPECT_FALSE(client_info_manager->client_info().non_power_of_two_textures());
+
+ delete client_info_manager;
+}
+
} // namespace o3d
diff --git a/o3d/core/cross/gl/renderer_gl.cc b/o3d/core/cross/gl/renderer_gl.cc
index 6741453..143410b 100644
--- a/o3d/core/cross/gl/renderer_gl.cc
+++ b/o3d/core/cross/gl/renderer_gl.cc
@@ -692,14 +692,14 @@ Renderer::InitStatus RendererGL::InitCommonGL() {
return GPU_NOT_UP_TO_SPEC;
}
- supports_npot_ = GLEW_ARB_texture_non_power_of_two;
+ SetSupportsNPOT(GLEW_ARB_texture_non_power_of_two);
#ifdef OS_MACOSX
// The Radeon X1600 says it supports NPOT, but in most situations it doesn't.
if (supports_npot_ &&
!strcmp("ATI Radeon X1600 OpenGL Engine",
reinterpret_cast<const char*>(::glGetString(GL_RENDERER))))
- supports_npot_ = false;
+ SetSupportsNPOT(false);
#endif
// Check for necessary extensions
diff --git a/o3d/core/cross/renderer.cc b/o3d/core/cross/renderer.cc
index 8d292d9..24c1e4a 100644
--- a/o3d/core/cross/renderer.cc
+++ b/o3d/core/cross/renderer.cc
@@ -38,6 +38,7 @@
#include "core/cross/renderer.h"
+#include "core/cross/client_info.h"
#include "core/cross/display_window.h"
#include "core/cross/error.h"
#include "core/cross/features.h"
@@ -208,6 +209,13 @@ void Renderer::UninitCommon() {
RemoveDefaultStates();
}
+void Renderer::SetSupportsNPOT(bool supports_npot) {
+ supports_npot_ = supports_npot;
+ ClientInfoManager* client_info_manager =
+ service_locator()->GetService<ClientInfoManager>();
+ client_info_manager->SetNonPowerOfTwoTextures(supports_npot);
+}
+
void Renderer::SetLostResourcesCallback(LostResourcesCallback* callback) {
lost_resources_callback_manager_.Set(callback);
}
diff --git a/o3d/core/cross/renderer.h b/o3d/core/cross/renderer.h
index 52d2148..15717ed 100644
--- a/o3d/core/cross/renderer.h
+++ b/o3d/core/cross/renderer.h
@@ -499,6 +499,9 @@ class Renderer {
// using the CreateDefaultRenderer factory method.
explicit Renderer(ServiceLocator* service_locator);
+ // Sets whether or not the renderer supports non-power of 2 textures.
+ void SetSupportsNPOT(bool supports_npot);
+
// Adds a state handler to the state handler map
// Parameters:
// state_name: Name of the state.
@@ -562,9 +565,6 @@ class Renderer {
// Sets the client's size. Derived classes must call this on Init and Resize.
void SetClientSize(int width, int height);
- // Whether or not the underlying API supports non-power-of-two textures.
- bool supports_npot_;
-
// Whether we need to clear the entire client area next render.
bool clear_client_;
@@ -639,6 +639,9 @@ class Renderer {
int dest_x_offset_;
int dest_y_offset_;
+ // Whether or not the underlying API supports non-power-of-two textures.
+ bool supports_npot_;
+
// Adds the default states to their respective stacks.
void AddDefaultStates();
diff --git a/o3d/core/cross/renderer_test.cc b/o3d/core/cross/renderer_test.cc
index 4c4acdd..9982d12 100644
--- a/o3d/core/cross/renderer_test.cc
+++ b/o3d/core/cross/renderer_test.cc
@@ -33,6 +33,7 @@
#include "core/cross/precompile.h"
#include "tests/common/win/testing_common.h"
#include "core/cross/client.h"
+#include "core/cross/client_info.h"
#include "core/cross/renderer.h"
#include "core/cross/bitmap.h"
#include "core/cross/features.h"
@@ -54,15 +55,18 @@ class RendererTest : public testing::Test {
virtual void SetUp() {
service_locator_ = new ServiceLocator;
features_ = new Features(service_locator_);
+ client_info_manager_ = new ClientInfoManager(service_locator_);
}
virtual void TearDown() {
+ delete client_info_manager_;
delete features_;
delete service_locator_;
}
ServiceLocator* service_locator_;
Features* features_;
+ ClientInfoManager* client_info_manager_;
};
// This tests that a default Renderer can be created.
diff --git a/o3d/core/win/d3d9/renderer_d3d9.cc b/o3d/core/win/d3d9/renderer_d3d9.cc
index b4c7ac2..5779eb7 100644
--- a/o3d/core/win/d3d9/renderer_d3d9.cc
+++ b/o3d/core/win/d3d9/renderer_d3d9.cc
@@ -1004,7 +1004,7 @@ Renderer::InitStatus RendererD3D9::InitPlatformSpecific(
const unsigned int kNpotFlags =
D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_CUBEMAP_POW2;
- supports_npot_ = ((d3d_caps.TextureCaps & kNpotFlags) == 0);
+ SetSupportsNPOT((d3d_caps.TextureCaps & kNpotFlags) == 0);
SetClientSize(width, height);
have_device_ = true;
diff --git a/o3d/plugin/idl/client.idl b/o3d/plugin/idl/client.idl
index c4c1054..a635508 100644
--- a/o3d/plugin/idl/client.idl
+++ b/o3d/plugin/idl/client.idl
@@ -118,6 +118,17 @@ class ClientInfo {
Whether or not O3D is using the software renderer.
%]
[getter] bool software_renderer;
+
+ %[
+ Whether or not the GPU supports non power of two textures.
+ NOTE: O3D always allows non power of two textures.
+
+ The only reason to look at this flag is for things like video that are
+ updating the texture every frame. In that case, you might want to know
+ that you could run faster if you used a power of 2 texture instead of
+ a non power of 2 texture.
+ %]
+ [getter] bool non_power_of_two_textures;
};
%[