diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-06 12:15:10 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-06 12:15:10 +0000 |
commit | aa8be181b085366e165c8fdcbf0f951f094d2b45 (patch) | |
tree | 4a97e75ab8d68a26e48749e3c1394e6f397c26f5 | |
parent | 94741f033be369b57e0d1d879add0b8da0dff8ba (diff) | |
download | chromium_src-aa8be181b085366e165c8fdcbf0f951f094d2b45.zip chromium_src-aa8be181b085366e165c8fdcbf0f951f094d2b45.tar.gz chromium_src-aa8be181b085366e165c8fdcbf0f951f094d2b45.tar.bz2 |
Remove always-on compositor capabilities
All context implementations the compositor uses support the following
capabilities:
- discard_backbuffer
- set_visibility
- map_sub
- shallow_flush
so there's no point in passing these values or, even worse, branching
on them.
R=piman
Review URL: https://codereview.chromium.org/94113004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239171 0039d316-1c4b-4281-b951-d872f2087c98
21 files changed, 27 insertions, 109 deletions
diff --git a/cc/output/context_provider.cc b/cc/output/context_provider.cc index e8e5c9d..454d96b 100644 --- a/cc/output/context_provider.cc +++ b/cc/output/context_provider.cc @@ -9,15 +9,11 @@ namespace cc { ContextProvider::Capabilities::Capabilities() - : discard_backbuffer(false), - egl_image_external(false), + : egl_image_external(false), fast_npot_mo8_textures(false), iosurface(false), map_image(false), - map_sub(false), post_sub_buffer(false), - set_visibility(false), - shallow_flush(false), swapbuffers_complete_callback(false), texture_format_bgra8888(false), texture_format_etc1(false), @@ -29,15 +25,11 @@ ContextProvider::Capabilities::Capabilities() ContextProvider::Capabilities::Capabilities( const gpu::Capabilities& gpu_capabilities) - : discard_backbuffer(false), - egl_image_external(gpu_capabilities.egl_image_external), + : egl_image_external(gpu_capabilities.egl_image_external), fast_npot_mo8_textures(gpu_capabilities.fast_npot_mo8_textures), iosurface(gpu_capabilities.iosurface), map_image(gpu_capabilities.map_image), - map_sub(false), post_sub_buffer(gpu_capabilities.post_sub_buffer), - set_visibility(false), - shallow_flush(false), swapbuffers_complete_callback(false), texture_format_bgra8888(gpu_capabilities.texture_format_bgra8888), texture_format_etc1(gpu_capabilities.texture_format_etc1), diff --git a/cc/output/context_provider.h b/cc/output/context_provider.h index 8649421..09b1835 100644 --- a/cc/output/context_provider.h +++ b/cc/output/context_provider.h @@ -34,15 +34,11 @@ class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> { virtual class GrContext* GrContext() = 0; struct Capabilities { - bool discard_backbuffer : 1; bool egl_image_external : 1; bool fast_npot_mo8_textures : 1; bool iosurface : 1; bool map_image : 1; - bool map_sub : 1; bool post_sub_buffer : 1; - bool set_visibility : 1; - bool shallow_flush : 1; bool swapbuffers_complete_callback : 1; bool texture_format_bgra8888 : 1; bool texture_format_etc1 : 1; diff --git a/cc/output/delegating_renderer.cc b/cc/output/delegating_renderer.cc index 918491d..001b7fd 100644 --- a/cc/output/delegating_renderer.cc +++ b/cc/output/delegating_renderer.cc @@ -78,7 +78,6 @@ bool DelegatingRenderer::Initialize() { DCHECK(!caps.iosurface || caps.texture_rectangle); - capabilities_.using_set_visibility = caps.set_visibility; capabilities_.using_egl_image = caps.egl_image_external; capabilities_.using_map_image = settings_->use_map_image && caps.map_image; @@ -162,13 +161,11 @@ void DelegatingRenderer::SetVisible(bool visible) { if (context_provider) context_provider->Context3d()->flush(); } - if (capabilities_.using_set_visibility) { - // We loop visibility to the GPU process, since that's what manages memory. - // That will allow it to feed us with memory allocations that we can act - // upon. - DCHECK(context_provider); - context_provider->Context3d()->setVisibilityCHROMIUM(visible); - } + // We loop visibility to the GPU process, since that's what manages memory. + // That will allow it to feed us with memory allocations that we can act + // upon. + DCHECK(context_provider); + context_provider->Context3d()->setVisibilityCHROMIUM(visible); } void DelegatingRenderer::SendManagedMemoryStats(size_t bytes_visible, diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index 3bf0d5b..16bdd31 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -202,8 +202,6 @@ bool GLRenderer::Initialize() { capabilities_.using_partial_swap = settings_->partial_swap_enabled && context_caps.post_sub_buffer; - capabilities_.using_set_visibility = context_caps.set_visibility; - DCHECK(!context_caps.iosurface || context_caps.texture_rectangle); capabilities_.using_egl_image = context_caps.egl_image_external; @@ -283,8 +281,7 @@ void GLRenderer::SetVisible(bool visible) { // TODO(jamesr): Replace setVisibilityCHROMIUM() with an extension to // explicitly manage front/backbuffers // crbug.com/116049 - if (capabilities_.using_set_visibility) - context_->setVisibilityCHROMIUM(visible); + context_->setVisibilityCHROMIUM(visible); } void GLRenderer::SendManagedMemoryStats(size_t bytes_visible, diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc index 6288c5d..773768e 100644 --- a/cc/output/gl_renderer_unittest.cc +++ b/cc/output/gl_renderer_unittest.cc @@ -132,10 +132,7 @@ TEST_F(GLRendererShaderPixelTest, AllShadersCompile) { TestShaders(); } class FrameCountingContext : public TestWebGraphicsContext3D { public: FrameCountingContext() - : frame_(0) { - test_capabilities_.set_visibility = true; - test_capabilities_.discard_backbuffer = true; - } + : frame_(0) {} // WebGraphicsContext3D methods. @@ -738,10 +735,7 @@ class VisibilityChangeIsLastCallTrackingContext : public TestWebGraphicsContext3D { public: VisibilityChangeIsLastCallTrackingContext() - : last_call_was_set_visibility_(false) { - test_capabilities_.set_visibility = true; - test_capabilities_.discard_backbuffer = true; - } + : last_call_was_set_visibility_(false) {} // WebGraphicsContext3D methods. virtual void setVisibilityCHROMIUM(bool visible) { @@ -1599,7 +1593,6 @@ TEST_F(GLRendererShaderTest, DrawSolidColorShader) { class OutputSurfaceMockContext : public TestWebGraphicsContext3D { public: OutputSurfaceMockContext() { - test_capabilities_.discard_backbuffer = true; test_capabilities_.post_sub_buffer = true; } diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc index 749527e..7c56eea 100644 --- a/cc/output/output_surface.cc +++ b/cc/output/output_surface.cc @@ -44,7 +44,6 @@ namespace cc { OutputSurface::OutputSurface(scoped_refptr<ContextProvider> context_provider) : context_provider_(context_provider), - has_gl_discard_backbuffer_(false), has_swap_buffers_complete_callback_(false), device_scale_factor_(-1), max_frames_pending_(0), @@ -60,7 +59,6 @@ OutputSurface::OutputSurface(scoped_refptr<ContextProvider> context_provider) OutputSurface::OutputSurface( scoped_ptr<cc::SoftwareOutputDevice> software_device) : software_device_(software_device.Pass()), - has_gl_discard_backbuffer_(false), has_swap_buffers_complete_callback_(false), device_scale_factor_(-1), max_frames_pending_(0), @@ -78,7 +76,6 @@ OutputSurface::OutputSurface( scoped_ptr<cc::SoftwareOutputDevice> software_device) : context_provider_(context_provider), software_device_(software_device.Pass()), - has_gl_discard_backbuffer_(false), has_swap_buffers_complete_callback_(false), device_scale_factor_(-1), max_frames_pending_(0), @@ -320,7 +317,6 @@ void OutputSurface::SetUpContext3d() { const ContextProvider::Capabilities& caps = context_provider_->ContextCapabilities(); - has_gl_discard_backbuffer_ = caps.discard_backbuffer; has_swap_buffers_complete_callback_ = caps.swapbuffers_complete_callback; context_provider_->SetLostContextCallback( @@ -356,14 +352,14 @@ void OutputSurface::ResetContext3d() { } void OutputSurface::EnsureBackbuffer() { - if (context_provider_ && has_gl_discard_backbuffer_) + if (context_provider_) context_provider_->Context3d()->ensureBackbufferCHROMIUM(); if (software_device_) software_device_->EnsureBackbuffer(); } void OutputSurface::DiscardBackbuffer() { - if (context_provider_ && has_gl_discard_backbuffer_) + if (context_provider_) context_provider_->Context3d()->discardBackbufferCHROMIUM(); if (software_device_) software_device_->DiscardBackbuffer(); diff --git a/cc/output/output_surface.h b/cc/output/output_surface.h index efe0ea2..d724465 100644 --- a/cc/output/output_surface.h +++ b/cc/output/output_surface.h @@ -154,7 +154,6 @@ class CC_EXPORT OutputSurface : public FrameRateControllerClient { struct cc::OutputSurface::Capabilities capabilities_; scoped_refptr<ContextProvider> context_provider_; scoped_ptr<cc::SoftwareOutputDevice> software_device_; - bool has_gl_discard_backbuffer_; bool has_swap_buffers_complete_callback_; gfx::Size surface_size_; float device_scale_factor_; diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc index 3cc4e29..421e541 100644 --- a/cc/output/software_renderer.cc +++ b/cc/output/software_renderer.cc @@ -86,7 +86,6 @@ SoftwareRenderer::SoftwareRenderer(RendererClient* client, capabilities_.best_texture_format = resource_provider_->best_texture_format(); } - capabilities_.using_set_visibility = true; // The updater can access bitmaps while the SoftwareRenderer is using them. capabilities_.allow_partial_texture_updates = true; capabilities_.using_partial_swap = true; diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index f5d365f..a725b4f 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc @@ -712,7 +712,7 @@ void ResourceProvider::Finish() { bool ResourceProvider::ShallowFlushIfSupported() { DCHECK(thread_checker_.CalledOnValidThread()); WebGraphicsContext3D* context3d = Context3d(); - if (!context3d || !use_shallow_flush_) + if (!context3d) return false; context3d->shallowFlushCHROMIUM(); @@ -899,7 +899,6 @@ ResourceProvider::ResourceProvider(OutputSurface* output_surface, default_resource_type_(InvalidType), use_texture_storage_ext_(false), use_texture_usage_hint_(false), - use_shallow_flush_(false), use_compressed_texture_etc1_(false), max_texture_size_(0), best_texture_format_(RGBA_8888), @@ -938,15 +937,12 @@ bool ResourceProvider::InitializeGL() { const ContextProvider::Capabilities& caps = output_surface_->context_provider()->ContextCapabilities(); - bool use_map_sub = caps.map_sub; bool use_bgra = caps.texture_format_bgra8888; use_texture_storage_ext_ = caps.texture_storage; - use_shallow_flush_ = caps.shallow_flush; use_texture_usage_hint_ = caps.texture_usage; use_compressed_texture_etc1_ = caps.texture_format_etc1; - texture_uploader_ = - TextureUploader::Create(context3d, use_map_sub, use_shallow_flush_); + texture_uploader_ = TextureUploader::Create(context3d); max_texture_size_ = 0; // Context expects cleared value. GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_)); diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h index 53a3747..21207c0 100644 --- a/cc/resources/resource_provider.h +++ b/cc/resources/resource_provider.h @@ -488,7 +488,6 @@ class CC_EXPORT ResourceProvider { ResourceType default_resource_type_; bool use_texture_storage_ext_; bool use_texture_usage_hint_; - bool use_shallow_flush_; bool use_compressed_texture_etc1_; scoped_ptr<TextureUploader> texture_uploader_; int max_texture_size_; diff --git a/cc/resources/resource_update_controller_unittest.cc b/cc/resources/resource_update_controller_unittest.cc index c824d21..a28f251 100644 --- a/cc/resources/resource_update_controller_unittest.cc +++ b/cc/resources/resource_update_controller_unittest.cc @@ -35,9 +35,7 @@ class ResourceUpdateControllerTest; class WebGraphicsContext3DForUploadTest : public TestWebGraphicsContext3D { public: explicit WebGraphicsContext3DForUploadTest(ResourceUpdateControllerTest* test) - : test_(test) { - test_capabilities_.shallow_flush = true; - } + : test_(test) {} virtual void flush() OVERRIDE; virtual void shallowFlushCHROMIUM() OVERRIDE; diff --git a/cc/scheduler/texture_uploader.cc b/cc/scheduler/texture_uploader.cc index 54d3515..ff941b2 100644 --- a/cc/scheduler/texture_uploader.cc +++ b/cc/scheduler/texture_uploader.cc @@ -74,14 +74,10 @@ unsigned TextureUploader::Query::Value() { return value_; } -TextureUploader::TextureUploader(blink::WebGraphicsContext3D* context, - bool use_map_tex_sub_image, - bool use_shallow_flush) +TextureUploader::TextureUploader(blink::WebGraphicsContext3D* context) : context_(context), num_blocking_texture_uploads_(0), - use_map_tex_sub_image_(use_map_tex_sub_image), sub_image_size_(0), - use_shallow_flush_(use_shallow_flush), num_texture_uploads_since_last_flush_(0) { for (size_t i = kUploadHistorySizeInitial; i > 0; i--) textures_per_second_history_.insert(kDefaultEstimatedTexturesPerSecond); @@ -148,13 +144,8 @@ void TextureUploader::Upload(const uint8* image, DCHECK(is_full_upload); UploadWithTexImageETC1(image, size); } else { - if (use_map_tex_sub_image_) { - UploadWithMapTexSubImage( - image, image_rect, source_rect, dest_offset, format); - } else { - UploadWithTexSubImage( - image, image_rect, source_rect, dest_offset, format); - } + UploadWithMapTexSubImage( + image, image_rect, source_rect, dest_offset, format); } if (is_full_upload) @@ -169,8 +160,7 @@ void TextureUploader::Flush() { if (!num_texture_uploads_since_last_flush_) return; - if (use_shallow_flush_) - context_->shallowFlushCHROMIUM(); + context_->shallowFlushCHROMIUM(); num_texture_uploads_since_last_flush_ = 0; } diff --git a/cc/scheduler/texture_uploader.h b/cc/scheduler/texture_uploader.h index 66e60c1..77c4449 100644 --- a/cc/scheduler/texture_uploader.h +++ b/cc/scheduler/texture_uploader.h @@ -25,12 +25,9 @@ namespace cc { class CC_EXPORT TextureUploader { public: - static scoped_ptr<TextureUploader> Create( - blink::WebGraphicsContext3D* context, - bool use_map_tex_sub_image, - bool use_shallow_flush) { - return make_scoped_ptr( - new TextureUploader(context, use_map_tex_sub_image, use_shallow_flush)); + static scoped_ptr<TextureUploader> + Create(blink::WebGraphicsContext3D* context) { + return make_scoped_ptr(new TextureUploader(context)); } ~TextureUploader(); @@ -85,9 +82,7 @@ class CC_EXPORT TextureUploader { DISALLOW_COPY_AND_ASSIGN(Query); }; - TextureUploader(blink::WebGraphicsContext3D* context, - bool use_map_tex_sub_image, - bool use_shallow_flush); + explicit TextureUploader(blink::WebGraphicsContext3D* context); void BeginQuery(); void EndQuery(); @@ -111,11 +106,9 @@ class CC_EXPORT TextureUploader { std::multiset<double> textures_per_second_history_; size_t num_blocking_texture_uploads_; - bool use_map_tex_sub_image_; size_t sub_image_size_; scoped_ptr<uint8[]> sub_image_; - bool use_shallow_flush_; size_t num_texture_uploads_since_last_flush_; DISALLOW_COPY_AND_ASSIGN(TextureUploader); diff --git a/cc/scheduler/texture_uploader_unittest.cc b/cc/scheduler/texture_uploader_unittest.cc index 5d5bf1f..b7fb084 100644 --- a/cc/scheduler/texture_uploader_unittest.cc +++ b/cc/scheduler/texture_uploader_unittest.cc @@ -166,7 +166,7 @@ TEST(TextureUploaderTest, NumBlockingUploads) { scoped_ptr<TestWebGraphicsContext3DTextureUpload> fake_context( new TestWebGraphicsContext3DTextureUpload); scoped_ptr<TextureUploader> uploader = - TextureUploader::Create(fake_context.get(), false, false); + TextureUploader::Create(fake_context.get()); fake_context->SetResultAvailable(0); EXPECT_EQ(0u, uploader->NumBlockingUploads()); @@ -188,7 +188,7 @@ TEST(TextureUploaderTest, MarkPendingUploadsAsNonBlocking) { scoped_ptr<TestWebGraphicsContext3DTextureUpload> fake_context( new TestWebGraphicsContext3DTextureUpload); scoped_ptr<TextureUploader> uploader = - TextureUploader::Create(fake_context.get(), false, false); + TextureUploader::Create(fake_context.get()); fake_context->SetResultAvailable(0); EXPECT_EQ(0u, uploader->NumBlockingUploads()); @@ -212,7 +212,7 @@ TEST(TextureUploaderTest, UploadContentsTest) { scoped_ptr<TestWebGraphicsContext3DTextureUpload> fake_context( new TestWebGraphicsContext3DTextureUpload); scoped_ptr<TextureUploader> uploader = - TextureUploader::Create(fake_context.get(), false, false); + TextureUploader::Create(fake_context.get()); uint8 buffer[256 * 256 * 4]; // Upload a tightly packed 256x256 RGBA texture. diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index fc9209e..081d96b 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -50,7 +50,6 @@ namespace cc { RendererCapabilities::RendererCapabilities() : best_texture_format(RGBA_8888), using_partial_swap(false), - using_set_visibility(false), using_egl_image(false), allow_partial_texture_updates(false), using_offscreen_context3d(false), diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 53ec30e..b1fb0c6 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -67,7 +67,6 @@ struct CC_EXPORT RendererCapabilities { ResourceFormat best_texture_format; bool using_partial_swap; - bool using_set_visibility; bool using_egl_image; bool allow_partial_texture_updates; bool using_offscreen_context3d; diff --git a/content/common/gpu/client/context_provider_command_buffer.cc b/content/common/gpu/client/context_provider_command_buffer.cc index 5ee350e..1e14b2e 100644 --- a/content/common/gpu/client/context_provider_command_buffer.cc +++ b/content/common/gpu/client/context_provider_command_buffer.cc @@ -215,17 +215,7 @@ void ContextProviderCommandBuffer::OnMemoryAllocationChanged( } void ContextProviderCommandBuffer::InitializeCapabilities() { - // The command buffer provides the following capabilities always. - // TODO(jamesr): This information is duplicated with - // gpu::gles2::FeatureInfo::AddFeatures(). Capabilities caps(context3d_->GetImplementation()->capabilities()); - caps.discard_backbuffer = true; - caps.set_visibility = true; - - // TODO(jamesr): These are also added in - // gpu::gles2::GLES2Implementation::GetStringHelper() on the client side. - caps.map_sub = true; - caps.shallow_flush = true; // The swapbuffers complete callback is always supported by multi-process // command buffer implementations. diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 1e97f19..6f6798f 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -2129,8 +2129,6 @@ const GLubyte* GLES2Implementation::GetStringHelper(GLenum name) { case GL_EXTENSIONS: str += std::string(str.empty() ? "" : " ") + "GL_CHROMIUM_flipy " - "GL_CHROMIUM_map_sub " - "GL_CHROMIUM_shallow_flush " "GL_EXT_unpack_subimage"; if (capabilities_.map_image) { // The first space character is intentional. diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc index f2d4dbc..5bc0c71 100644 --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc @@ -2479,8 +2479,6 @@ TEST_F(GLES2ImplementationTest, GetString) { const char* expected_str = "foobar " "GL_CHROMIUM_flipy " - "GL_CHROMIUM_map_sub " - "GL_CHROMIUM_shallow_flush " "GL_EXT_unpack_subimage"; const char kBad = 0x12; struct Cmds { diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc index 57db99b..c9f0733 100644 --- a/gpu/command_buffer/service/feature_info.cc +++ b/gpu/command_buffer/service/feature_info.cc @@ -237,14 +237,12 @@ void FeatureInfo::InitializeFeatures() { AddExtensionString("GL_CHROMIUM_command_buffer_query"); AddExtensionString("GL_CHROMIUM_command_buffer_latency_query"); AddExtensionString("GL_CHROMIUM_copy_texture"); - AddExtensionString("GL_CHROMIUM_discard_backbuffer"); AddExtensionString("GL_CHROMIUM_get_error_query"); AddExtensionString("GL_CHROMIUM_lose_context"); AddExtensionString("GL_CHROMIUM_pixel_transfer_buffer_object"); AddExtensionString("GL_CHROMIUM_rate_limit_offscreen_context"); AddExtensionString("GL_CHROMIUM_resize"); AddExtensionString("GL_CHROMIUM_resource_safe"); - AddExtensionString("GL_CHROMIUM_set_visibility"); AddExtensionString("GL_CHROMIUM_strict_attribs"); AddExtensionString("GL_CHROMIUM_stream_texture"); AddExtensionString("GL_CHROMIUM_texture_mailbox"); diff --git a/webkit/common/gpu/context_provider_in_process.cc b/webkit/common/gpu/context_provider_in_process.cc index c9098a7..fcca0e7 100644 --- a/webkit/common/gpu/context_provider_in_process.cc +++ b/webkit/common/gpu/context_provider_in_process.cc @@ -123,16 +123,7 @@ bool ContextProviderInProcess::BindToCurrentThread() { } void ContextProviderInProcess::InitializeCapabilities() { - Capabilities caps(context3d_->GetImplementation()->capabilities()); - - // We always use a WebGraphicsContext3DInProcessCommandBufferImpl which - // provides the following capabilities: - caps.discard_backbuffer = true; - caps.map_sub = true; - caps.set_visibility = true; - caps.shallow_flush = true; - - capabilities_ = caps; + capabilities_ = Capabilities(context3d_->GetImplementation()->capabilities()); } cc::ContextProvider::Capabilities |