diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-29 04:56:29 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-29 04:56:29 +0000 |
commit | f44d555f9942ccbb0c88e911a40aeb507ba48872 (patch) | |
tree | 81da447c3ec53b05f4a9c8facc87b07c98e66473 | |
parent | 33aeb08e822ea55a18eb12fdd2364f2fd8af0df6 (diff) | |
download | chromium_src-f44d555f9942ccbb0c88e911a40aeb507ba48872.zip chromium_src-f44d555f9942ccbb0c88e911a40aeb507ba48872.tar.gz chromium_src-f44d555f9942ccbb0c88e911a40aeb507ba48872.tar.bz2 |
Move memory allocation/stats structs to gpu:: and remove bazillion copies
This moves the memory allocation / stats structs from content to gpu:: and
eliminates many redundant copies of this information in different parts of the
stack. This also moves the stats sending and allocation callbacks to
gpu::ContextSupport / gpu::GpuControl to get rid of the bounce through
WebKit::WebGraphicsContext3D.
The new flow for cc to register for memory allocation changes and pass stats to
the manager is this:
cc:: registers for MemoryAllocationChanged callbacks and sends stats via the
gpu::ContextSupport interface. Memory allocations are represented by a
gpu::MemoryAllocation struct and memory statistics are sent in a
gpu::ManagedMemoryStats struct.
The implementation of gpu::ContextSupport (gpu::gles2::GLES2Implementation)
forwards the calls to gpu::GpuControl. content::CommandBufferProxyImpl's
implementation of these maps the calls to content IPCs that drive the memory
manager implementation.
This patch gets rid of the following things:
*) WebKit::WebGraphicsMemory(Allocation|Stats) go away. These were used only
because cc was not able to depend on the previous locations of the
allocation/stats structs in content::. Now that these structs are in gpu::, the
compositor (which is the only thing using these) can see them directly
*) WebGraphicsContext3D::sendManagedMemoryStatsCHROMIUM /
setMemoryAllocationChangedCallbackCHROMIUM go away.
*) cc:ManagedMemoryPolicy's cutoff fields are now
gpu::MemoryAllocation::PriorityCutoff enums instead of an (inconsistently named)
copy.
*) GpuMemoryAllocationForBrowser goes away and is managed directly in content.
gpu::GpuMemoryAllocationForRenderer is renamed to just gpu::MemoryAllocation
*) Many proxies and converters go away.
cc::ManagedMemoryPolicy sticks around in this patch, even though it's largely
the same as gpu::MemoryAllocation, since it's sometimes used by code that
doesn't go through the gpu memory allocation path - such as android_webview -
and it has some additional state (num_resource_limit) that's not applicable to a
general gpu::MemoryAllocation. Chris tells me this struct is due for
simplification as well, so maybe it'll make sense to fold it in in a future
patch.
Diffstat:
53 files changed, 345 insertions(+), 713 deletions(-)
BUG=181120
R=piman,ccameron
Review URL: https://codereview.chromium.org/45243002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231527 0039d316-1c4b-4281-b951-d872f2087c98
50 files changed, 294 insertions, 582 deletions
@@ -1,6 +1,7 @@ include_rules = [ "+gpu/GLES2", "+gpu/command_buffer/client/context_support.h", + "+gpu/command_buffer/common/gpu_memory_allocation.h", "+gpu/command_buffer/common/mailbox.h", "+media", "+skia/ext", diff --git a/cc/debug/test_context_support.cc b/cc/debug/test_context_support.cc index edbbd72..e5a0b93 100644 --- a/cc/debug/test_context_support.cc +++ b/cc/debug/test_context_support.cc @@ -21,6 +21,10 @@ void TestContextSupport::SignalQuery(uint32 query, sync_point_callbacks_.push_back(callback); } +void TestContextSupport::SendManagedMemoryStats( + const gpu::ManagedMemoryStats& stats) { +} + void TestContextSupport::CallAllSyncPointCallbacks() { for (size_t i = 0; i < sync_point_callbacks_.size(); ++i) { base::MessageLoop::current()->PostTask( diff --git a/cc/debug/test_context_support.h b/cc/debug/test_context_support.h index 4c092e9..067bcaf 100644 --- a/cc/debug/test_context_support.h +++ b/cc/debug/test_context_support.h @@ -21,6 +21,8 @@ class TestContextSupport : public gpu::ContextSupport { const base::Closure& callback) OVERRIDE; virtual void SignalQuery(uint32 query, const base::Closure& callback) OVERRIDE; + virtual void SendManagedMemoryStats(const gpu::ManagedMemoryStats& stats) + OVERRIDE; void CallAllSyncPointCallbacks(); diff --git a/cc/output/delegating_renderer.cc b/cc/output/delegating_renderer.cc index 7d95550..678d21a 100644 --- a/cc/output/delegating_renderer.cc +++ b/cc/output/delegating_renderer.cc @@ -22,6 +22,8 @@ #include "cc/quads/tile_draw_quad.h" #include "cc/quads/yuv_video_draw_quad.h" #include "cc/resources/resource_provider.h" +#include "gpu/command_buffer/client/context_support.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" #include "third_party/khronos/GLES2/gl2ext.h" @@ -181,12 +183,13 @@ void DelegatingRenderer::SendManagedMemoryStats(size_t bytes_visible, NOTIMPLEMENTED(); return; } - WebKit::WebGraphicsManagedMemoryStats stats; - stats.bytesVisible = bytes_visible; - stats.bytesVisibleAndNearby = bytes_visible_and_nearby; - stats.bytesAllocated = bytes_allocated; - stats.backbufferRequested = false; - context_provider->Context3d()->sendManagedMemoryStatsCHROMIUM(&stats); + gpu::ManagedMemoryStats stats; + stats.bytes_required = bytes_visible; + stats.bytes_nice_to_have = bytes_visible_and_nearby; + stats.bytes_allocated = bytes_allocated; + stats.backbuffer_requested = false; + + context_provider->ContextSupport()->SendManagedMemoryStats(stats); } void DelegatingRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) { diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index 6e8bd75..35f8684 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -38,6 +38,7 @@ #include "cc/trees/single_thread_proxy.h" #include "gpu/GLES2/gl2extchromium.h" #include "gpu/command_buffer/client/context_support.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" #include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2ext.h" @@ -278,12 +279,12 @@ void GLRenderer::SetVisible(bool visible) { void GLRenderer::SendManagedMemoryStats(size_t bytes_visible, size_t bytes_visible_and_nearby, size_t bytes_allocated) { - WebKit::WebGraphicsManagedMemoryStats stats; - stats.bytesVisible = bytes_visible; - stats.bytesVisibleAndNearby = bytes_visible_and_nearby; - stats.bytesAllocated = bytes_allocated; - stats.backbufferRequested = !is_backbuffer_discarded_; - context_->sendManagedMemoryStatsCHROMIUM(&stats); + gpu::ManagedMemoryStats stats; + stats.bytes_required = bytes_visible; + stats.bytes_nice_to_have = bytes_visible_and_nearby; + stats.bytes_allocated = bytes_allocated; + stats.backbuffer_requested = !is_backbuffer_discarded_; + context_support_->SendManagedMemoryStats(stats); } void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } diff --git a/cc/output/managed_memory_policy.cc b/cc/output/managed_memory_policy.cc index 7e83766..ade2a27 100644 --- a/cc/output/managed_memory_policy.cc +++ b/cc/output/managed_memory_policy.cc @@ -11,18 +11,29 @@ namespace cc { const size_t ManagedMemoryPolicy::kDefaultNumResourcesLimit = 10 * 1000 * 1000; +using gpu::MemoryAllocation; + ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytes_limit_when_visible) : bytes_limit_when_visible(bytes_limit_when_visible), - priority_cutoff_when_visible(CUTOFF_ALLOW_EVERYTHING), + priority_cutoff_when_visible(MemoryAllocation::CUTOFF_ALLOW_EVERYTHING), bytes_limit_when_not_visible(0), - priority_cutoff_when_not_visible(CUTOFF_ALLOW_NOTHING), + priority_cutoff_when_not_visible(MemoryAllocation::CUTOFF_ALLOW_NOTHING), + num_resources_limit(kDefaultNumResourcesLimit) {} + +ManagedMemoryPolicy::ManagedMemoryPolicy( + const gpu::MemoryAllocation& allocation) + : bytes_limit_when_visible(allocation.bytes_limit_when_visible), + priority_cutoff_when_visible(allocation.priority_cutoff_when_visible), + bytes_limit_when_not_visible(allocation.bytes_limit_when_not_visible), + priority_cutoff_when_not_visible( + allocation.priority_cutoff_when_not_visible), num_resources_limit(kDefaultNumResourcesLimit) {} ManagedMemoryPolicy::ManagedMemoryPolicy( size_t bytes_limit_when_visible, - PriorityCutoff priority_cutoff_when_visible, + MemoryAllocation::PriorityCutoff priority_cutoff_when_visible, size_t bytes_limit_when_not_visible, - PriorityCutoff priority_cutoff_when_not_visible, + MemoryAllocation::PriorityCutoff priority_cutoff_when_not_visible, size_t num_resources_limit) : bytes_limit_when_visible(bytes_limit_when_visible), priority_cutoff_when_visible(priority_cutoff_when_visible), @@ -44,15 +55,16 @@ bool ManagedMemoryPolicy::operator!=(const ManagedMemoryPolicy& other) const { } // static -int ManagedMemoryPolicy::PriorityCutoffToValue(PriorityCutoff priority_cutoff) { +int ManagedMemoryPolicy::PriorityCutoffToValue( + MemoryAllocation::PriorityCutoff priority_cutoff) { switch (priority_cutoff) { - case CUTOFF_ALLOW_NOTHING: + case MemoryAllocation::CUTOFF_ALLOW_NOTHING: return PriorityCalculator::AllowNothingCutoff(); - case CUTOFF_ALLOW_REQUIRED_ONLY: + case MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY: return PriorityCalculator::AllowVisibleOnlyCutoff(); - case CUTOFF_ALLOW_NICE_TO_HAVE: + case MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE: return PriorityCalculator::AllowVisibleAndNearbyCutoff(); - case CUTOFF_ALLOW_EVERYTHING: + case MemoryAllocation::CUTOFF_ALLOW_EVERYTHING: return PriorityCalculator::AllowEverythingCutoff(); } NOTREACHED(); @@ -62,15 +74,15 @@ int ManagedMemoryPolicy::PriorityCutoffToValue(PriorityCutoff priority_cutoff) { // static TileMemoryLimitPolicy ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( - PriorityCutoff priority_cutoff) { + gpu::MemoryAllocation::PriorityCutoff priority_cutoff) { switch (priority_cutoff) { - case CUTOFF_ALLOW_NOTHING: + case MemoryAllocation::CUTOFF_ALLOW_NOTHING: return ALLOW_NOTHING; - case CUTOFF_ALLOW_REQUIRED_ONLY: + case MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY: return ALLOW_ABSOLUTE_MINIMUM; - case CUTOFF_ALLOW_NICE_TO_HAVE: + case MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE: return ALLOW_PREPAINT_ONLY; - case CUTOFF_ALLOW_EVERYTHING: + case MemoryAllocation::CUTOFF_ALLOW_EVERYTHING: return ALLOW_ANYTHING; } NOTREACHED(); diff --git a/cc/output/managed_memory_policy.h b/cc/output/managed_memory_policy.h index 5a607a7..1a234f7 100644 --- a/cc/output/managed_memory_policy.h +++ b/cc/output/managed_memory_policy.h @@ -8,36 +8,35 @@ #include "base/basictypes.h" #include "cc/base/cc_export.h" #include "cc/resources/tile_priority.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" namespace cc { struct CC_EXPORT ManagedMemoryPolicy { - enum PriorityCutoff { - CUTOFF_ALLOW_NOTHING, - CUTOFF_ALLOW_REQUIRED_ONLY, - CUTOFF_ALLOW_NICE_TO_HAVE, - CUTOFF_ALLOW_EVERYTHING, - }; static const size_t kDefaultNumResourcesLimit; explicit ManagedMemoryPolicy(size_t bytes_limit_when_visible); - ManagedMemoryPolicy(size_t bytes_limit_when_visible, - PriorityCutoff priority_cutoff_when_visible, - size_t bytes_limit_when_not_visible, - PriorityCutoff priority_cutoff_when_not_visible, - size_t num_resources_limit); + explicit ManagedMemoryPolicy( + const gpu::MemoryAllocation& allocation); + ManagedMemoryPolicy( + size_t bytes_limit_when_visible, + gpu::MemoryAllocation::PriorityCutoff priority_cutoff_when_visible, + size_t bytes_limit_when_not_visible, + gpu::MemoryAllocation::PriorityCutoff priority_cutoff_when_not_visible, + size_t num_resources_limit); bool operator==(const ManagedMemoryPolicy&) const; bool operator!=(const ManagedMemoryPolicy&) const; size_t bytes_limit_when_visible; - PriorityCutoff priority_cutoff_when_visible; + gpu::MemoryAllocation::PriorityCutoff priority_cutoff_when_visible; size_t bytes_limit_when_not_visible; - PriorityCutoff priority_cutoff_when_not_visible; + gpu::MemoryAllocation::PriorityCutoff priority_cutoff_when_not_visible; size_t num_resources_limit; - static int PriorityCutoffToValue(PriorityCutoff priority_cutoff); + static int PriorityCutoffToValue( + gpu::MemoryAllocation::PriorityCutoff priority_cutoff); static TileMemoryLimitPolicy PriorityCutoffToTileMemoryLimitPolicy( - PriorityCutoff priority_cutoff); + gpu::MemoryAllocation::PriorityCutoff priority_cutoff); }; } // namespace cc diff --git a/cc/output/output_surface.h b/cc/output/output_surface.h index 83ee5fd..2887e80 100644 --- a/cc/output/output_surface.h +++ b/cc/output/output_surface.h @@ -196,7 +196,6 @@ class CC_EXPORT OutputSurface : public FrameRateControllerClient { private: OutputSurfaceClient* client_; - friend class OutputSurfaceCallbacks; void SetUpContext3d(); void ResetContext3d(); diff --git a/cc/output/output_surface_unittest.cc b/cc/output/output_surface_unittest.cc index 64ed874..1a1db29 100644 --- a/cc/output/output_surface_unittest.cc +++ b/cc/output/output_surface_unittest.cc @@ -429,20 +429,20 @@ TEST(OutputSurfaceTest, MemoryAllocation) { ManagedMemoryPolicy policy(0); policy.bytes_limit_when_visible = 1234; policy.priority_cutoff_when_visible = - ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; + gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY; policy.bytes_limit_when_not_visible = 4567; policy.priority_cutoff_when_not_visible = - ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; + gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING; bool discard_backbuffer_when_not_visible = false; context_provider->SetMemoryAllocation(policy, discard_backbuffer_when_not_visible); EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); - EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY, + EXPECT_EQ(gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY, client.memory_policy().priority_cutoff_when_visible); EXPECT_EQ(4567u, client.memory_policy().bytes_limit_when_not_visible); - EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING, + EXPECT_EQ(gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING, client.memory_policy().priority_cutoff_when_not_visible); EXPECT_FALSE(client.discard_backbuffer_when_not_visible()); @@ -452,14 +452,14 @@ TEST(OutputSurfaceTest, MemoryAllocation) { EXPECT_TRUE(client.discard_backbuffer_when_not_visible()); policy.priority_cutoff_when_visible = - ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING; + gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING; policy.priority_cutoff_when_not_visible = - ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE; + gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; context_provider->SetMemoryAllocation(policy, discard_backbuffer_when_not_visible); - EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, + EXPECT_EQ(gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, client.memory_policy().priority_cutoff_when_visible); - EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE, + EXPECT_EQ(gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, client.memory_policy().priority_cutoff_when_not_visible); // 0 bytes limit should be ignored. diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index b512828..7171580 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -207,9 +207,9 @@ LayerTreeHostImpl::LayerTreeHostImpl( visible_(true), cached_managed_memory_policy_( PrioritizedResourceManager::DefaultMemoryAllocationLimit(), - ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, + gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 0, - ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING, + gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING, ManagedMemoryPolicy::kDefaultNumResourcesLimit), pinch_gesture_active_(false), pinch_gesture_end_should_clear_scrolling_layer_(false), @@ -1561,9 +1561,9 @@ ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const { ManagedMemoryPolicy actual = cached_managed_memory_policy_; if (debug_state_.rasterize_only_visible_content) { actual.priority_cutoff_when_not_visible = - ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; + gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING; actual.priority_cutoff_when_visible = - ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; + gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY; } if (zero_budget_) { diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 262753c..18b273e 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -5215,8 +5215,8 @@ TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { TEST_F(LayerTreeHostImplTest, MemoryPolicy) { ManagedMemoryPolicy policy1( - 456, ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, - 123, ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE, 1000); + 456, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, + 123, gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, 1000); int visible_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue( policy1.priority_cutoff_when_visible); int not_visible_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue( diff --git a/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc b/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc index a1990b0..c432a5e 100644 --- a/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc +++ b/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc @@ -29,8 +29,8 @@ class LayerTreeHostOnDemandRasterPixelTest : public LayerTreePixelTest { virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { // Not enough memory available. Enforce on-demand rasterization. impl->SetMemoryPolicy( - ManagedMemoryPolicy(1, ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, - 1, ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING, + ManagedMemoryPolicy(1, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, + 1, gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING, 1000)); impl->SetDiscardBackBufferWhenNotVisible(true); } diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 4b1c2e3..950fd79 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -2453,9 +2453,9 @@ class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted // Because a resource was evicted, a commit will be kicked off. host_impl->SetMemoryPolicy( ManagedMemoryPolicy(100 * 100 * 4 * 2, - ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, + gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 100 * 100 * 4 * 1, - ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, + gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 1000)); host_impl->SetDiscardBackBufferWhenNotVisible(true); break; @@ -4977,9 +4977,9 @@ class LayerTreeHostTestMemoryLimits : public LayerTreeHostTest { // This will trigger a commit because the priority cutoff has changed. impl->SetMemoryPolicy(ManagedMemoryPolicy( 16u*1024u*1024u, - ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE, + gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, 0, - ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING, + gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING, 1000)); break; case 2: @@ -4987,9 +4987,9 @@ class LayerTreeHostTestMemoryLimits : public LayerTreeHostTest { // changed, and there is already enough memory for all allocations. impl->SetMemoryPolicy(ManagedMemoryPolicy( 32u*1024u*1024u, - ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE, + gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, 0, - ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING, + gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING, 1000)); break; case 3: @@ -5137,14 +5137,14 @@ class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface second_context_provider_ : first_context_provider_)); output_surface->SetMemoryPolicyToSetAtBind(make_scoped_ptr( - new cc::ManagedMemoryPolicy( + new ManagedMemoryPolicy( second_context_provider_ ? second_output_surface_memory_limit_ : first_output_surface_memory_limit_, - cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE, + gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, 0, - cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING, - cc::ManagedMemoryPolicy::kDefaultNumResourcesLimit))); + gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING, + ManagedMemoryPolicy::kDefaultNumResourcesLimit))); return output_surface.PassAs<OutputSurface>(); } diff --git a/cc/trees/layer_tree_host_unittest_damage.cc b/cc/trees/layer_tree_host_unittest_damage.cc index 83831f6..402a56a 100644 --- a/cc/trees/layer_tree_host_unittest_damage.cc +++ b/cc/trees/layer_tree_host_unittest_damage.cc @@ -58,9 +58,9 @@ class LayerTreeHostDamageTestSetVisibleDoesNotDraw // No evictions when we become not-visible. impl->SetMemoryPolicy(ManagedMemoryPolicy( 1000 * 1000 * 1000, - ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, + gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 1000 * 1000 * 1000, - ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, + gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, ManagedMemoryPolicy::kDefaultNumResourcesLimit)); PostSetVisibleToMainThread(false); diff --git a/content/browser/android/in_process/synchronous_compositor_output_surface.cc b/content/browser/android/in_process/synchronous_compositor_output_surface.cc index 59581f0..54ea181 100644 --- a/content/browser/android/in_process/synchronous_compositor_output_surface.cc +++ b/content/browser/android/in_process/synchronous_compositor_output_surface.cc @@ -14,6 +14,7 @@ #include "content/browser/android/in_process/synchronous_compositor_impl.h" #include "content/public/browser/browser_thread.h" #include "gpu/command_buffer/client/gl_in_process_context.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "third_party/skia/include/core/SkBitmapDevice.h" #include "third_party/skia/include/core/SkCanvas.h" #include "ui/gfx/rect_conversions.h" @@ -117,7 +118,7 @@ SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( // constructed on the correct thread. memory_policy_.priority_cutoff_when_visible = - cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE; + gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; } SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc index 764ae09..f1406a4 100644 --- a/content/common/gpu/client/command_buffer_proxy_impl.cc +++ b/content/common/gpu/client/command_buffer_proxy_impl.cc @@ -12,11 +12,11 @@ #include "content/common/child_process_messages.h" #include "content/common/gpu/client/gpu_channel_host.h" #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" -#include "content/common/gpu/gpu_memory_allocation.h" #include "content/common/gpu/gpu_messages.h" #include "content/common/view_messages.h" #include "gpu/command_buffer/common/cmd_buffer_common.h" #include "gpu/command_buffer/common/command_buffer_shared.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "ui/gfx/size.h" namespace content { @@ -98,8 +98,7 @@ void CommandBufferProxyImpl::OnConsoleMessage( } void CommandBufferProxyImpl::SetMemoryAllocationChangedCallback( - const base::Callback<void(const GpuMemoryAllocationForRenderer&)>& - callback) { + const MemoryAllocationChangedCallback& callback) { if (last_state_.error != gpu::error::kNoError) return; @@ -118,7 +117,7 @@ void CommandBufferProxyImpl::RemoveDeletionObserver( } void CommandBufferProxyImpl::OnSetMemoryAllocation( - const GpuMemoryAllocationForRenderer& allocation) { + const gpu::MemoryAllocation& allocation) { if (!memory_allocation_changed_callback_.is_null()) memory_allocation_changed_callback_.Run(allocation); } @@ -516,6 +515,14 @@ void CommandBufferProxyImpl::SignalQuery(uint32 query, signal_tasks_.insert(std::make_pair(signal_id, callback)); } +void CommandBufferProxyImpl::SendManagedMemoryStats( + const gpu::ManagedMemoryStats& stats) { + if (last_state_.error != gpu::error::kNoError) + return; + + Send(new GpuCommandBufferMsg_SendClientManagedMemoryStats(route_id_, + stats)); +} bool CommandBufferProxyImpl::GenerateMailboxNames( unsigned num, @@ -601,13 +608,4 @@ void CommandBufferProxyImpl::TryUpdateState() { shared_state()->Read(&last_state_); } -void CommandBufferProxyImpl::SendManagedMemoryStats( - const GpuManagedMemoryStats& stats) { - if (last_state_.error != gpu::error::kNoError) - return; - - Send(new GpuCommandBufferMsg_SendClientManagedMemoryStats(route_id_, - stats)); -} - } // namespace content diff --git a/content/common/gpu/client/command_buffer_proxy_impl.h b/content/common/gpu/client/command_buffer_proxy_impl.h index 35255a9..b018367 100644 --- a/content/common/gpu/client/command_buffer_proxy_impl.h +++ b/content/common/gpu/client/command_buffer_proxy_impl.h @@ -15,10 +15,10 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" -#include "content/common/gpu/gpu_memory_allocation.h" #include "gpu/command_buffer/common/command_buffer.h" #include "gpu/command_buffer/common/command_buffer_shared.h" #include "gpu/command_buffer/common/gpu_control.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "ipc/ipc_listener.h" #include "media/video/video_decode_accelerator.h" #include "ui/events/latency_info.h" @@ -110,17 +110,18 @@ class CommandBufferProxyImpl const base::Closure& callback) OVERRIDE; virtual void SignalQuery(uint32 query, const base::Closure& callback) OVERRIDE; - + virtual void SendManagedMemoryStats(const gpu::ManagedMemoryStats& stats) + OVERRIDE; int GetRouteID() const; bool Echo(const base::Closure& callback); bool ProduceFrontBuffer(const gpu::Mailbox& mailbox); void SetChannelErrorCallback(const base::Closure& callback); + typedef base::Callback<void(const gpu::MemoryAllocation&)> + MemoryAllocationChangedCallback; void SetMemoryAllocationChangedCallback( - const base::Callback<void(const GpuMemoryAllocationForRenderer&)>& - callback); - + const MemoryAllocationChangedCallback& callback); void AddDeletionObserver(DeletionObserver* observer); void RemoveDeletionObserver(DeletionObserver* observer); @@ -141,8 +142,6 @@ class CommandBufferProxyImpl // CommandBufferProxyImpl implementation. virtual gpu::error::Error GetLastError() OVERRIDE; - void SendManagedMemoryStats(const GpuManagedMemoryStats& stats); - GpuChannelHost* channel() const { return channel_; } private: @@ -160,7 +159,7 @@ class CommandBufferProxyImpl void OnDestroyed(gpu::error::ContextLostReason reason); void OnEchoAck(); void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message); - void OnSetMemoryAllocation(const GpuMemoryAllocationForRenderer& allocation); + void OnSetMemoryAllocation(const gpu::MemoryAllocation& allocation); void OnSignalSyncPointAck(uint32 id); void OnGenerateMailboxNamesReply(const std::vector<std::string>& names); @@ -197,8 +196,7 @@ class CommandBufferProxyImpl base::Closure channel_error_callback_; - base::Callback<void(const GpuMemoryAllocationForRenderer&)> - memory_allocation_changed_callback_; + MemoryAllocationChangedCallback memory_allocation_changed_callback_; GpuConsoleMessageCallback console_message_callback_; diff --git a/content/common/gpu/client/context_provider_command_buffer.cc b/content/common/gpu/client/context_provider_command_buffer.cc index 3a685bf..e992236 100644 --- a/content/common/gpu/client/context_provider_command_buffer.cc +++ b/content/common/gpu/client/context_provider_command_buffer.cc @@ -13,7 +13,6 @@ #include "cc/output/managed_memory_policy.h" #include "gpu/command_buffer/client/gles2_implementation.h" #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" -#include "webkit/common/gpu/managed_memory_policy_convert.h" namespace content { @@ -59,28 +58,6 @@ class ContextProviderCommandBuffer::SwapBuffersCompleteCallbackProxy ContextProviderCommandBuffer* provider_; }; -class ContextProviderCommandBuffer::MemoryAllocationCallbackProxy - : public WebKit::WebGraphicsContext3D:: - WebGraphicsMemoryAllocationChangedCallbackCHROMIUM { - public: - explicit MemoryAllocationCallbackProxy(ContextProviderCommandBuffer* provider) - : provider_(provider) { - provider_->context3d_->setMemoryAllocationChangedCallbackCHROMIUM(this); - } - - virtual ~MemoryAllocationCallbackProxy() { - provider_->context3d_->setMemoryAllocationChangedCallbackCHROMIUM(NULL); - } - - virtual void onMemoryAllocationChanged( - WebKit::WebGraphicsMemoryAllocation allocation) { - provider_->OnMemoryAllocationChanged(allocation); - } - - private: - ContextProviderCommandBuffer* provider_; -}; - scoped_refptr<ContextProviderCommandBuffer> ContextProviderCommandBuffer::Create( scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, @@ -110,7 +87,10 @@ ContextProviderCommandBuffer::~ContextProviderCommandBuffer() { base::AutoLock lock(main_thread_lock_); // Destroy references to the context3d_ before leaking it. - memory_allocation_callback_proxy_.reset(); + if (context3d_->GetCommandBufferProxy()) { + context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( + CommandBufferProxyImpl::MemoryAllocationChangedCallback()); + } swap_buffers_complete_callback_proxy_.reset(); lost_context_callback_proxy_.reset(); @@ -144,8 +124,9 @@ bool ContextProviderCommandBuffer::BindToCurrentThread() { lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); swap_buffers_complete_callback_proxy_.reset( new SwapBuffersCompleteCallbackProxy(this)); - memory_allocation_callback_proxy_.reset( - new MemoryAllocationCallbackProxy(this)); + context3d_->GetCommandBufferProxy()->SetMemoryAllocationChangedCallback( + base::Bind(&ContextProviderCommandBuffer::OnMemoryAllocationChanged, + base::Unretained(this))); return true; } @@ -212,25 +193,22 @@ void ContextProviderCommandBuffer::OnSwapBuffersComplete() { } void ContextProviderCommandBuffer::OnMemoryAllocationChanged( - const WebKit::WebGraphicsMemoryAllocation& allocation) { + const gpu::MemoryAllocation& allocation) { DCHECK(context_thread_checker_.CalledOnValidThread()); if (gr_context_) { - bool nonzero_allocation = !!allocation.gpuResourceSizeInBytes; + bool nonzero_allocation = !!allocation.bytes_limit_when_visible; gr_context_->SetMemoryLimit(nonzero_allocation); } if (memory_policy_changed_callback_.is_null()) return; - bool discard_backbuffer_when_not_visible; - cc::ManagedMemoryPolicy policy = - webkit::gpu::ManagedMemoryPolicyConvert::Convert( - allocation, - &discard_backbuffer_when_not_visible); + bool discard_backbuffer_when_not_visible = + !allocation.have_backbuffer_when_not_visible; memory_policy_changed_callback_.Run( - policy, discard_backbuffer_when_not_visible); + cc::ManagedMemoryPolicy(allocation), discard_backbuffer_when_not_visible); } bool ContextProviderCommandBuffer::InitializeCapabilities() { diff --git a/content/common/gpu/client/context_provider_command_buffer.h b/content/common/gpu/client/context_provider_command_buffer.h index 3c988d7..cec651f 100644 --- a/content/common/gpu/client/context_provider_command_buffer.h +++ b/content/common/gpu/client/context_provider_command_buffer.h @@ -59,8 +59,7 @@ class CONTENT_EXPORT ContextProviderCommandBuffer void OnLostContext(); void OnSwapBuffersComplete(); - void OnMemoryAllocationChanged( - const WebKit::WebGraphicsMemoryAllocation& allocation); + void OnMemoryAllocationChanged(const gpu::MemoryAllocation& allocation); private: bool InitializeCapabilities(); @@ -88,9 +87,6 @@ class CONTENT_EXPORT ContextProviderCommandBuffer class SwapBuffersCompleteCallbackProxy; scoped_ptr<SwapBuffersCompleteCallbackProxy> swap_buffers_complete_callback_proxy_; - - class MemoryAllocationCallbackProxy; - scoped_ptr<MemoryAllocationCallbackProxy> memory_allocation_callback_proxy_; }; } // namespace content diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc index 1742af9..8e454fd 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc @@ -24,7 +24,6 @@ #include "base/metrics/histogram.h" #include "base/synchronization/lock.h" #include "content/common/gpu/client/gpu_channel_host.h" -#include "content/common/gpu/gpu_memory_allocation.h" #include "content/public/common/content_constants.h" #include "content/public/common/content_switches.h" #include "gpu/GLES2/gl2extchromium.h" @@ -34,6 +33,7 @@ #include "gpu/command_buffer/client/gles2_trace_implementation.h" #include "gpu/command_buffer/client/transfer_buffer.h" #include "gpu/command_buffer/common/constants.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "gpu/command_buffer/common/mailbox.h" #include "third_party/skia/include/core/SkTypes.h" #include "webkit/common/gpu/gl_bindings_skia_cmd_buffer.h" @@ -610,34 +610,6 @@ void WebGraphicsContext3DCommandBufferImpl::ensureBackbufferCHROMIUM() { command_buffer_->EnsureBackbuffer(); } -void WebGraphicsContext3DCommandBufferImpl::sendManagedMemoryStatsCHROMIUM( - const WebGraphicsManagedMemoryStats* stats) -{ - CHECK(command_buffer_); - command_buffer_->SendManagedMemoryStats(GpuManagedMemoryStats( - stats->bytesVisible, - stats->bytesVisibleAndNearby, - stats->bytesAllocated, - stats->backbufferRequested)); -} - -void WebGraphicsContext3DCommandBufferImpl:: - setMemoryAllocationChangedCallbackCHROMIUM( - WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { - if (!command_buffer_) - return; - - if (callback) - command_buffer_->SetMemoryAllocationChangedCallback(base::Bind( - &WebGraphicsContext3DCommandBufferImpl::OnMemoryAllocationChanged, - weak_ptr_factory_.GetWeakPtr(), - callback)); - else - command_buffer_->SetMemoryAllocationChangedCallback( - base::Callback<void(const GpuMemoryAllocationForRenderer&)>()); -} - - void WebGraphicsContext3DCommandBufferImpl::copyTextureToParentTextureCHROMIUM( WebGLId texture, WebGLId parentTexture) { NOTIMPLEMENTED(); @@ -1271,56 +1243,6 @@ void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete() { swapbuffers_complete_callback_->onSwapBuffersComplete(); } -WebGraphicsMemoryAllocation::PriorityCutoff - WebGraphicsContext3DCommandBufferImpl::WebkitPriorityCutoff( - GpuMemoryAllocationForRenderer::PriorityCutoff priorityCutoff) { - switch (priorityCutoff) { - case GpuMemoryAllocationForRenderer::kPriorityCutoffAllowNothing: - return WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing; - case GpuMemoryAllocationForRenderer::kPriorityCutoffAllowOnlyRequired: - return WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly; - case GpuMemoryAllocationForRenderer::kPriorityCutoffAllowNiceToHave: - return WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearby; - case GpuMemoryAllocationForRenderer::kPriorityCutoffAllowEverything: - return WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything; - } - NOTREACHED(); - return WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything; -} - -void WebGraphicsContext3DCommandBufferImpl::OnMemoryAllocationChanged( - WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback, - const GpuMemoryAllocationForRenderer& allocation) { - - // Convert the gpu structure to the WebKit structure. - WebGraphicsMemoryAllocation web_allocation; - web_allocation.bytesLimitWhenVisible = - ClampUint64ToSizeT(allocation.bytes_limit_when_visible); - web_allocation.priorityCutoffWhenVisible = - WebkitPriorityCutoff(allocation.priority_cutoff_when_visible); - web_allocation.bytesLimitWhenNotVisible = - ClampUint64ToSizeT(allocation.bytes_limit_when_not_visible); - web_allocation.priorityCutoffWhenNotVisible = - WebkitPriorityCutoff(allocation.priority_cutoff_when_not_visible); - web_allocation.haveBackbufferWhenNotVisible = - allocation.have_backbuffer_when_not_visible; - - // Populate deprecated WebKit fields. These may be removed when references to - // them in WebKit are removed. - web_allocation.gpuResourceSizeInBytes = - ClampUint64ToSizeT(allocation.bytes_limit_when_visible); - web_allocation.suggestHaveBackbuffer = - allocation.have_backbuffer_when_not_visible; - - if (callback) - callback->onMemoryAllocationChanged(web_allocation); - - // We may have allocated transfer buffers in order to free GL resources in a - // backgrounded tab. Re-free the transfer buffers. - if (!visible_) - real_gl_->FreeEverything(); -} - void WebGraphicsContext3DCommandBufferImpl::setErrorMessageCallback( WebGraphicsContext3D::WebGraphicsErrorMessageCallback* cb) { error_message_callback_ = cb; diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h index cb24444..799c1f1 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h @@ -45,12 +45,9 @@ using WebKit::WGC3Dfloat; using WebKit::WGC3Dclampf; using WebKit::WGC3Dintptr; using WebKit::WGC3Dsizeiptr; -using WebKit::WebGraphicsManagedMemoryStats; -using WebKit::WebGraphicsMemoryAllocation; namespace content { class GpuChannelHost; -struct GpuMemoryAllocationForRenderer; const size_t kDefaultCommandBufferSize = 1024 * 1024; const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024; @@ -525,12 +522,6 @@ class WebGraphicsContext3DCommandBufferImpl virtual void discardBackbufferCHROMIUM(); virtual void ensureBackbufferCHROMIUM(); - virtual void setMemoryAllocationChangedCallbackCHROMIUM( - WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback); - - virtual void sendManagedMemoryStatsCHROMIUM( - const WebGraphicsManagedMemoryStats* stats); - virtual void copyTextureToParentTextureCHROMIUM( WebGLId texture, WebGLId parentTexture); @@ -723,15 +714,6 @@ class WebGraphicsContext3DCommandBufferImpl // main thread. bool ShouldUseSwapClient(); - // MemoryAllocationChanged callback. - void OnMemoryAllocationChanged( - WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback, - const GpuMemoryAllocationForRenderer& allocation); - - // Convert the gpu cutoff enum to the WebKit enum. - static WebGraphicsMemoryAllocation::PriorityCutoff WebkitPriorityCutoff( - GpuMemoryAllocationForRenderer::PriorityCutoff priorityCutoff); - bool initialize_failed_; bool visible_; diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index 9030ffe..b3ff05a 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -837,7 +837,7 @@ void GpuCommandBufferStub::OnSignalQuery(uint32 query_id, uint32 id) { void GpuCommandBufferStub::OnReceivedClientManagedMemoryStats( - const GpuManagedMemoryStats& stats) { + const gpu::ManagedMemoryStats& stats) { TRACE_EVENT0( "gpu", "GpuCommandBufferStub::OnReceivedClientManagedMemoryStats"); @@ -932,28 +932,25 @@ gpu::gles2::MemoryTracker* GpuCommandBufferStub::GetMemoryTracker() const { } void GpuCommandBufferStub::SetMemoryAllocation( - const GpuMemoryAllocation& allocation) { + const gpu::MemoryAllocation& allocation) { if (!last_memory_allocation_valid_ || - !allocation.renderer_allocation.Equals( - last_memory_allocation_.renderer_allocation)) { + !allocation.Equals(last_memory_allocation_)) { Send(new GpuCommandBufferMsg_SetMemoryAllocation( - route_id_, allocation.renderer_allocation)); - } - - if (!last_memory_allocation_valid_ || - !allocation.browser_allocation.Equals( - last_memory_allocation_.browser_allocation)) { - // This can be called outside of OnMessageReceived, so the context needs - // to be made current before calling methods on the surface. - if (surface_.get() && MakeCurrent()) - surface_->SetFrontbufferAllocation( - allocation.browser_allocation.suggest_have_frontbuffer); + route_id_, allocation)); } last_memory_allocation_valid_ = true; last_memory_allocation_ = allocation; } +void GpuCommandBufferStub::SuggestHaveFrontBuffer( + bool suggest_have_frontbuffer) { + // This can be called outside of OnMessageReceived, so the context needs + // to be made current before calling methods on the surface. + if (surface_.get() && MakeCurrent()) + surface_->SetFrontbufferAllocation(suggest_have_frontbuffer); +} + bool GpuCommandBufferStub::CheckContextLost() { DCHECK(command_buffer_); gpu::CommandBuffer::State state = command_buffer_->GetState(); diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index a5258f2..bf1914a 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -13,10 +13,10 @@ #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "content/common/content_export.h" -#include "content/common/gpu/gpu_memory_allocation.h" #include "content/common/gpu/gpu_memory_manager.h" #include "content/common/gpu/gpu_memory_manager_client.h" #include "gpu/command_buffer/common/constants.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "gpu/command_buffer/service/command_buffer_service.h" #include "gpu/command_buffer/service/context_group.h" #include "gpu/command_buffer/service/gpu_scheduler.h" @@ -93,7 +93,8 @@ class GpuCommandBufferStub virtual gfx::Size GetSurfaceSize() const OVERRIDE; virtual gpu::gles2::MemoryTracker* GetMemoryTracker() const OVERRIDE; virtual void SetMemoryAllocation( - const GpuMemoryAllocation& allocation) OVERRIDE; + const gpu::MemoryAllocation& allocation) OVERRIDE; + virtual void SuggestHaveFrontBuffer(bool suggest_have_frontbuffer) OVERRIDE; virtual bool GetTotalGpuMemory(uint64* bytes) OVERRIDE; // Whether this command buffer can currently handle IPC messages. @@ -180,7 +181,7 @@ class GpuCommandBufferStub void OnSignalSyncPointAck(uint32 id); void OnSignalQuery(uint32 query, uint32 id); - void OnReceivedClientManagedMemoryStats(const GpuManagedMemoryStats& stats); + void OnReceivedClientManagedMemoryStats(const gpu::ManagedMemoryStats& stats); void OnSetClientHasMemoryAllocationChangedCallback(bool has_callback); void OnRegisterGpuMemoryBuffer(int32 id, @@ -238,7 +239,7 @@ class GpuCommandBufferStub // The last memory allocation received from the GpuMemoryManager (used to // elide redundant work). bool last_memory_allocation_valid_; - GpuMemoryAllocation last_memory_allocation_; + gpu::MemoryAllocation last_memory_allocation_; GpuWatchdog* watchdog_; diff --git a/content/common/gpu/gpu_memory_manager.cc b/content/common/gpu/gpu_memory_manager.cc index cb6b6c6..df9b24b 100644 --- a/content/common/gpu/gpu_memory_manager.cc +++ b/content/common/gpu/gpu_memory_manager.cc @@ -13,13 +13,16 @@ #include "base/process/process_handle.h" #include "base/strings/string_number_conversions.h" #include "content/common/gpu/gpu_channel_manager.h" -#include "content/common/gpu/gpu_memory_allocation.h" #include "content/common/gpu/gpu_memory_manager_client.h" #include "content/common/gpu/gpu_memory_tracking.h" #include "content/common/gpu/gpu_memory_uma_stats.h" #include "content/common/gpu/gpu_messages.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "gpu/command_buffer/service/gpu_switches.h" +using gpu::ManagedMemoryStats; +using gpu::MemoryAllocation; + namespace content { namespace { @@ -337,7 +340,7 @@ void GpuMemoryManager::SetClientStateVisible( void GpuMemoryManager::SetClientStateManagedMemoryStats( GpuMemoryManagerClientState* client_state, - const GpuManagedMemoryStats& stats) + const ManagedMemoryStats& stats) { TrackValueChanged(client_state->managed_memory_stats_.bytes_allocated, stats.bytes_allocated, @@ -474,7 +477,7 @@ uint64 GpuMemoryManager::ComputeClientAllocationWhenVisible( uint64 bytes_above_required_cap, uint64 bytes_above_minimum_cap, uint64 bytes_overall_cap) { - GpuManagedMemoryStats* stats = &client_state->managed_memory_stats_; + ManagedMemoryStats* stats = &client_state->managed_memory_stats_; if (!client_state->managed_memory_stats_received_) return GetDefaultClientAllocation(); @@ -769,30 +772,28 @@ void GpuMemoryManager::AssignSurfacesAllocations() { 3 * client_state->managed_memory_stats_.bytes_nice_to_have / 4; // Populate and send the allocation to the client - GpuMemoryAllocation allocation; - - allocation.browser_allocation.suggest_have_frontbuffer = - !client_state->hibernated_; + MemoryAllocation allocation; - allocation.renderer_allocation.bytes_limit_when_visible = + allocation.bytes_limit_when_visible = client_state->bytes_allocation_when_visible_; // Use a more conservative memory allocation policy on Linux and Mac // because the platform is unstable when under memory pressure. // http://crbug.com/145600 (Linux) // http://crbug.com/141377 (Mac) - allocation.renderer_allocation.priority_cutoff_when_visible = + allocation.priority_cutoff_when_visible = #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) - GpuMemoryAllocationForRenderer::kPriorityCutoffAllowNiceToHave; + MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; #else - GpuMemoryAllocationForRenderer::kPriorityCutoffAllowEverything; + MemoryAllocation::CUTOFF_ALLOW_EVERYTHING; #endif - allocation.renderer_allocation.bytes_limit_when_not_visible = + allocation.bytes_limit_when_not_visible = client_state->bytes_allocation_when_nonvisible_; - allocation.renderer_allocation.priority_cutoff_when_not_visible = - GpuMemoryAllocationForRenderer::kPriorityCutoffAllowOnlyRequired; + allocation.priority_cutoff_when_not_visible = + MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY; client_state->client_->SetMemoryAllocation(allocation); + client_state->client_->SuggestHaveFrontBuffer(!client_state->hibernated_); } } @@ -801,13 +802,13 @@ void GpuMemoryManager::AssignNonSurfacesAllocations() { it != clients_nonsurface_.end(); ++it) { GpuMemoryManagerClientState* client_state = *it; - GpuMemoryAllocation allocation; + MemoryAllocation allocation; if (!client_state->hibernated_) { - allocation.renderer_allocation.bytes_limit_when_visible = + allocation.bytes_limit_when_visible = GetMinimumClientAllocation(); - allocation.renderer_allocation.priority_cutoff_when_visible = - GpuMemoryAllocationForRenderer::kPriorityCutoffAllowEverything; + allocation.priority_cutoff_when_visible = + MemoryAllocation::CUTOFF_ALLOW_EVERYTHING; } client_state->client_->SetMemoryAllocation(allocation); diff --git a/content/common/gpu/gpu_memory_manager.h b/content/common/gpu/gpu_memory_manager.h index 9b2de82..3c9a223 100644 --- a/content/common/gpu/gpu_memory_manager.h +++ b/content/common/gpu/gpu_memory_manager.h @@ -14,8 +14,8 @@ #include "base/gtest_prod_util.h" #include "base/memory/weak_ptr.h" #include "content/common/content_export.h" -#include "content/common/gpu/gpu_memory_allocation.h" #include "content/public/common/gpu_memory_stats.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "gpu/command_buffer/service/memory_tracking.h" namespace content { @@ -182,7 +182,7 @@ class CONTENT_EXPORT GpuMemoryManager : GpuMemoryManagerClientState* client_state, bool visible); void SetClientStateManagedMemoryStats( GpuMemoryManagerClientState* client_state, - const GpuManagedMemoryStats& stats); + const gpu::ManagedMemoryStats& stats); void OnDestroyClientState(GpuMemoryManagerClientState* client); // Add or remove a client from its clients list (visible, nonvisible, or diff --git a/content/common/gpu/gpu_memory_manager_client.cc b/content/common/gpu/gpu_memory_manager_client.cc index 26fc95c..0ef3017 100644 --- a/content/common/gpu/gpu_memory_manager_client.cc +++ b/content/common/gpu/gpu_memory_manager_client.cc @@ -40,7 +40,7 @@ void GpuMemoryManagerClientState::SetVisible(bool visible) { } void GpuMemoryManagerClientState::SetManagedMemoryStats( - const GpuManagedMemoryStats& stats) { + const gpu::ManagedMemoryStats& stats) { memory_manager_->SetClientStateManagedMemoryStats(this, stats); } diff --git a/content/common/gpu/gpu_memory_manager_client.h b/content/common/gpu/gpu_memory_manager_client.h index 1579fb8..453e7a1 100644 --- a/content/common/gpu/gpu_memory_manager_client.h +++ b/content/common/gpu/gpu_memory_manager_client.h @@ -9,7 +9,7 @@ #include "base/basictypes.h" #include "content/common/content_export.h" -#include "content/common/gpu/gpu_memory_allocation.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "gpu/command_buffer/service/memory_tracking.h" #include "ui/gfx/size.h" @@ -32,7 +32,9 @@ class CONTENT_EXPORT GpuMemoryManagerClient { // Sets buffer usage depending on Memory Allocation virtual void SetMemoryAllocation( - const GpuMemoryAllocation& allocation) = 0; + const gpu::MemoryAllocation& allocation) = 0; + + virtual void SuggestHaveFrontBuffer(bool suggest_have_frontbuffer) = 0; // Returns in bytes the total amount of GPU memory for the GPU which this // context is currently rendering on. Returns false if no extension exists @@ -46,7 +48,7 @@ class CONTENT_EXPORT GpuMemoryManagerClientState { public: ~GpuMemoryManagerClientState(); void SetVisible(bool visible); - void SetManagedMemoryStats(const GpuManagedMemoryStats& stats); + void SetManagedMemoryStats(const gpu::ManagedMemoryStats& stats); private: friend class GpuMemoryManager; @@ -80,7 +82,7 @@ class CONTENT_EXPORT GpuMemoryManagerClientState { bool list_iterator_valid_; // Statistics about memory usage. - GpuManagedMemoryStats managed_memory_stats_; + gpu::ManagedMemoryStats managed_memory_stats_; bool managed_memory_stats_received_; // When managed_memory_stats_.bytes_nicetohave leaves the range diff --git a/content/common/gpu/gpu_memory_manager_unittest.cc b/content/common/gpu/gpu_memory_manager_unittest.cc index e008a477..ded1a28 100644 --- a/content/common/gpu/gpu_memory_manager_unittest.cc +++ b/content/common/gpu/gpu_memory_manager_unittest.cc @@ -2,14 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/common/gpu/gpu_memory_allocation.h" #include "content/common/gpu/gpu_memory_manager.h" #include "content/common/gpu/gpu_memory_manager_client.h" #include "content/common/gpu/gpu_memory_tracking.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "ui/gfx/size_conversions.h" #include "testing/gtest/include/gtest/gtest.h" +using gpu::MemoryAllocation; +using gpu::ManagedMemoryStats; + #if defined(COMPILER_GCC) namespace BASE_HASH_NAMESPACE { template<> @@ -43,7 +46,7 @@ namespace content { class ClientAssignmentCollector { public: struct ClientMemoryStat { - GpuMemoryAllocation allocation; + MemoryAllocation allocation; }; typedef base::hash_map<GpuMemoryManagerClient*, ClientMemoryStat> ClientMemoryStatMap; @@ -55,7 +58,7 @@ class ClientAssignmentCollector { client_memory_stats_for_last_manage_.clear(); } static void AddClientStat(GpuMemoryManagerClient* client, - const GpuMemoryAllocation& allocation) { + const MemoryAllocation& allocation) { DCHECK(!client_memory_stats_for_last_manage_.count(client)); client_memory_stats_for_last_manage_[client].allocation = allocation; } @@ -70,7 +73,8 @@ ClientAssignmentCollector::ClientMemoryStatMap class FakeClient : public GpuMemoryManagerClient { public: GpuMemoryManager* memmgr_; - GpuMemoryAllocation allocation_; + bool suggest_have_frontbuffer_; + MemoryAllocation allocation_; uint64 total_gpu_memory_; gfx::Size surface_size_; GpuMemoryManagerClient* share_group_; @@ -81,6 +85,7 @@ class FakeClient : public GpuMemoryManagerClient { // This will create a client with no surface FakeClient(GpuMemoryManager* memmgr, GpuMemoryManagerClient* share_group) : memmgr_(memmgr), + suggest_have_frontbuffer_(false), total_gpu_memory_(0), share_group_(share_group), memory_tracker_(NULL) { @@ -95,6 +100,7 @@ class FakeClient : public GpuMemoryManagerClient { // This will create a client with a surface FakeClient(GpuMemoryManager* memmgr, int32 surface_id, bool visible) : memmgr_(memmgr), + suggest_have_frontbuffer_(false), total_gpu_memory_(0), share_group_(NULL), memory_tracker_(NULL) { @@ -111,11 +117,15 @@ class FakeClient : public GpuMemoryManagerClient { memory_tracker_ = NULL; } - virtual void SetMemoryAllocation(const GpuMemoryAllocation& alloc) OVERRIDE { + virtual void SetMemoryAllocation(const MemoryAllocation& alloc) OVERRIDE { allocation_ = alloc; ClientAssignmentCollector::AddClientStat(this, alloc); } + virtual void SuggestHaveFrontBuffer(bool suggest_have_frontbuffer) OVERRIDE { + suggest_have_frontbuffer_ = suggest_have_frontbuffer; + } + virtual bool GetTotalGpuMemory(uint64* bytes) OVERRIDE { if (total_gpu_memory_) { *bytes = total_gpu_memory_; @@ -140,16 +150,16 @@ class FakeClient : public GpuMemoryManagerClient { client_state_->SetVisible(visible); } - void SetManagedMemoryStats(const GpuManagedMemoryStats& stats) { + void SetManagedMemoryStats(const ManagedMemoryStats& stats) { client_state_->SetManagedMemoryStats(stats); } uint64 BytesWhenVisible() const { - return allocation_.renderer_allocation.bytes_limit_when_visible; + return allocation_.bytes_limit_when_visible; } uint64 BytesWhenNotVisible() const { - return allocation_.renderer_allocation.bytes_limit_when_not_visible; + return allocation_.bytes_limit_when_not_visible; } }; @@ -172,39 +182,33 @@ class GpuMemoryManagerTest : public testing::Test { } bool IsAllocationForegroundForSurfaceYes( - const GpuMemoryAllocation& alloc) { - return alloc.browser_allocation.suggest_have_frontbuffer && - !alloc.renderer_allocation.have_backbuffer_when_not_visible; + const MemoryAllocation& alloc) { + return !alloc.have_backbuffer_when_not_visible; } bool IsAllocationBackgroundForSurfaceYes( - const GpuMemoryAllocation& alloc) { - return alloc.browser_allocation.suggest_have_frontbuffer && - !alloc.renderer_allocation.have_backbuffer_when_not_visible; + const MemoryAllocation& alloc) { + return !alloc.have_backbuffer_when_not_visible; } bool IsAllocationHibernatedForSurfaceYes( - const GpuMemoryAllocation& alloc) { - return !alloc.browser_allocation.suggest_have_frontbuffer && - !alloc.renderer_allocation.have_backbuffer_when_not_visible; + const MemoryAllocation& alloc) { + return !alloc.have_backbuffer_when_not_visible; } bool IsAllocationForegroundForSurfaceNo( - const GpuMemoryAllocation& alloc) { - return !alloc.browser_allocation.suggest_have_frontbuffer && - !alloc.renderer_allocation.have_backbuffer_when_not_visible && - alloc.renderer_allocation.bytes_limit_when_visible == + const MemoryAllocation& alloc) { + return !alloc.have_backbuffer_when_not_visible && + alloc.bytes_limit_when_visible == GetMinimumClientAllocation(); } bool IsAllocationBackgroundForSurfaceNo( - const GpuMemoryAllocation& alloc) { - return !alloc.browser_allocation.suggest_have_frontbuffer && - !alloc.renderer_allocation.have_backbuffer_when_not_visible && - alloc.renderer_allocation.bytes_limit_when_visible == + const MemoryAllocation& alloc) { + return !alloc.have_backbuffer_when_not_visible && + alloc.bytes_limit_when_visible == GetMinimumClientAllocation(); } bool IsAllocationHibernatedForSurfaceNo( - const GpuMemoryAllocation& alloc) { - return !alloc.browser_allocation.suggest_have_frontbuffer && - !alloc.renderer_allocation.have_backbuffer_when_not_visible && - alloc.renderer_allocation.bytes_limit_when_visible == 0; + const MemoryAllocation& alloc) { + return !alloc.have_backbuffer_when_not_visible && + alloc.bytes_limit_when_visible == 0; } void Manage() { @@ -239,7 +243,7 @@ class GpuMemoryManagerTest : public testing::Test { uint64 required, uint64 nicetohave) { client->SetManagedMemoryStats( - GpuManagedMemoryStats(required, nicetohave, 0, false)); + ManagedMemoryStats(required, nicetohave, 0, false)); } GpuMemoryManager memmgr_; @@ -474,51 +478,6 @@ TEST_F(GpuMemoryManagerTest, TestUpdateAvailableGpuMemory) { EXPECT_EQ(GetAvailableGpuMemory(), CalcAvailableClamped(bytes_expected)); } - -// Test GpuMemoryAllocation comparison operators: Iterate over all possible -// combinations of gpu_resource_size_in_bytes, suggest_have_backbuffer, and -// suggest_have_frontbuffer, and make sure allocations with equal values test -// equal and non equal values test not equal. -TEST_F(GpuMemoryManagerTest, GpuMemoryAllocationCompareTests) { - std::vector<int> gpu_resource_size_in_bytes_values; - gpu_resource_size_in_bytes_values.push_back(0); - gpu_resource_size_in_bytes_values.push_back(1); - gpu_resource_size_in_bytes_values.push_back(12345678); - - std::vector<GpuMemoryAllocation::BufferAllocation> - suggested_buffer_allocation_values; - suggested_buffer_allocation_values.push_back( - GpuMemoryAllocation::kHasFrontbuffer); - suggested_buffer_allocation_values.push_back( - GpuMemoryAllocation::kHasFrontbuffer); - suggested_buffer_allocation_values.push_back( - GpuMemoryAllocation::kHasNoFrontbuffer); - suggested_buffer_allocation_values.push_back( - GpuMemoryAllocation::kHasNoFrontbuffer); - - for (size_t i = 0; i != gpu_resource_size_in_bytes_values.size(); ++i) { - for (size_t j = 0; j != suggested_buffer_allocation_values.size(); ++j) { - uint64 sz = gpu_resource_size_in_bytes_values[i]; - GpuMemoryAllocation::BufferAllocation buffer_allocation = - suggested_buffer_allocation_values[j]; - GpuMemoryAllocation allocation(sz, buffer_allocation); - - EXPECT_TRUE(allocation.Equals( - GpuMemoryAllocation(sz, buffer_allocation))); - EXPECT_FALSE(allocation.Equals( - GpuMemoryAllocation(sz+1, buffer_allocation))); - - for (size_t k = 0; k != suggested_buffer_allocation_values.size(); ++k) { - GpuMemoryAllocation::BufferAllocation buffer_allocation_other = - suggested_buffer_allocation_values[k]; - if (buffer_allocation == buffer_allocation_other) continue; - EXPECT_FALSE(allocation.Equals( - GpuMemoryAllocation(sz, buffer_allocation_other))); - } - } - } -} - // Test GpuMemoryManager Stub Memory Stats functionality: // Creates various surface/non-surface stubs and switches stub visibility and // tests to see that stats data structure values are correct. @@ -533,7 +492,7 @@ TEST_F(GpuMemoryManagerTest, StubMemoryStatsForLastManageTests) { Manage(); stats = ClientAssignmentCollector::GetClientStatsForLastManage(); uint64 stub1allocation1 = - stats[&stub1].allocation.renderer_allocation.bytes_limit_when_visible; + stats[&stub1].allocation.bytes_limit_when_visible; EXPECT_EQ(stats.size(), 1ul); EXPECT_GT(stub1allocation1, 0ul); @@ -543,10 +502,10 @@ TEST_F(GpuMemoryManagerTest, StubMemoryStatsForLastManageTests) { stats = ClientAssignmentCollector::GetClientStatsForLastManage(); EXPECT_EQ(stats.count(&stub1), 1ul); uint64 stub1allocation2 = - stats[&stub1].allocation.renderer_allocation.bytes_limit_when_visible; + stats[&stub1].allocation.bytes_limit_when_visible; EXPECT_EQ(stats.count(&stub2), 1ul); uint64 stub2allocation2 = - stats[&stub2].allocation.renderer_allocation.bytes_limit_when_visible; + stats[&stub2].allocation.bytes_limit_when_visible; EXPECT_EQ(stats.size(), 2ul); EXPECT_GT(stub1allocation2, 0ul); @@ -558,11 +517,11 @@ TEST_F(GpuMemoryManagerTest, StubMemoryStatsForLastManageTests) { Manage(); stats = ClientAssignmentCollector::GetClientStatsForLastManage(); uint64 stub1allocation3 = - stats[&stub1].allocation.renderer_allocation.bytes_limit_when_visible; + stats[&stub1].allocation.bytes_limit_when_visible; uint64 stub2allocation3 = - stats[&stub2].allocation.renderer_allocation.bytes_limit_when_visible; + stats[&stub2].allocation.bytes_limit_when_visible; uint64 stub3allocation3 = - stats[&stub3].allocation.renderer_allocation.bytes_limit_when_visible; + stats[&stub3].allocation.bytes_limit_when_visible; EXPECT_EQ(stats.size(), 3ul); EXPECT_GT(stub1allocation3, 0ul); @@ -576,11 +535,11 @@ TEST_F(GpuMemoryManagerTest, StubMemoryStatsForLastManageTests) { Manage(); stats = ClientAssignmentCollector::GetClientStatsForLastManage(); uint64 stub1allocation4 = - stats[&stub1].allocation.renderer_allocation.bytes_limit_when_visible; + stats[&stub1].allocation.bytes_limit_when_visible; uint64 stub2allocation4 = - stats[&stub2].allocation.renderer_allocation.bytes_limit_when_visible; + stats[&stub2].allocation.bytes_limit_when_visible; uint64 stub3allocation4 = - stats[&stub3].allocation.renderer_allocation.bytes_limit_when_visible; + stats[&stub3].allocation.bytes_limit_when_visible; EXPECT_EQ(stats.size(), 3ul); EXPECT_GT(stub1allocation4, 0ul); @@ -598,8 +557,8 @@ TEST_F(GpuMemoryManagerTest, TestManagedUsageTracking) { EXPECT_EQ(0ul, memmgr_.bytes_allocated_managed_nonvisible_); // Set memory allocations and verify the results are reflected. - stub1.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 5, false)); - stub2.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 7, false)); + stub1.SetManagedMemoryStats(ManagedMemoryStats(0, 0, 5, false)); + stub2.SetManagedMemoryStats(ManagedMemoryStats(0, 0, 7, false)); EXPECT_EQ(5ul, memmgr_.bytes_allocated_managed_visible_); EXPECT_EQ(7ul, memmgr_.bytes_allocated_managed_nonvisible_); @@ -612,7 +571,7 @@ TEST_F(GpuMemoryManagerTest, TestManagedUsageTracking) { stub1.client_state_.reset(memmgr_.CreateClientState(&stub1, true, true)); EXPECT_EQ(0ul, memmgr_.bytes_allocated_managed_visible_); EXPECT_EQ(7ul, memmgr_.bytes_allocated_managed_nonvisible_); - stub1.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 5, false)); + stub1.SetManagedMemoryStats(ManagedMemoryStats(0, 0, 5, false)); EXPECT_EQ(5ul, memmgr_.bytes_allocated_managed_visible_); EXPECT_EQ(7ul, memmgr_.bytes_allocated_managed_nonvisible_); @@ -625,7 +584,7 @@ TEST_F(GpuMemoryManagerTest, TestManagedUsageTracking) { stub2.client_state_.reset(memmgr_.CreateClientState(&stub2, true, false)); EXPECT_EQ(5ul, memmgr_.bytes_allocated_managed_visible_); EXPECT_EQ(0ul, memmgr_.bytes_allocated_managed_nonvisible_); - stub2.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 7, false)); + stub2.SetManagedMemoryStats(ManagedMemoryStats(0, 0, 7, false)); EXPECT_EQ(5ul, memmgr_.bytes_allocated_managed_visible_); EXPECT_EQ(7ul, memmgr_.bytes_allocated_managed_nonvisible_); @@ -633,8 +592,8 @@ TEST_F(GpuMemoryManagerTest, TestManagedUsageTracking) { { FakeClient stub3(&memmgr_, GenerateUniqueSurfaceId(), true), stub4(&memmgr_, GenerateUniqueSurfaceId(), false); - stub3.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 1, false)); - stub4.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 2, false)); + stub3.SetManagedMemoryStats(ManagedMemoryStats(0, 0, 1, false)); + stub4.SetManagedMemoryStats(ManagedMemoryStats(0, 0, 2, false)); EXPECT_EQ(6ul, memmgr_.bytes_allocated_managed_visible_); EXPECT_EQ(9ul, memmgr_.bytes_allocated_managed_nonvisible_); } @@ -654,14 +613,14 @@ TEST_F(GpuMemoryManagerTest, TestManagedUsageTracking) { EXPECT_EQ(5ul, memmgr_.bytes_allocated_managed_nonvisible_); // Increase allocation amounts. - stub1.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 6, false)); - stub2.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 8, false)); + stub1.SetManagedMemoryStats(ManagedMemoryStats(0, 0, 6, false)); + stub2.SetManagedMemoryStats(ManagedMemoryStats(0, 0, 8, false)); EXPECT_EQ(8ul, memmgr_.bytes_allocated_managed_visible_); EXPECT_EQ(6ul, memmgr_.bytes_allocated_managed_nonvisible_); // Decrease allocation amounts. - stub1.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 4, false)); - stub2.SetManagedMemoryStats(GpuManagedMemoryStats(0, 0, 6, false)); + stub1.SetManagedMemoryStats(ManagedMemoryStats(0, 0, 4, false)); + stub2.SetManagedMemoryStats(ManagedMemoryStats(0, 0, 6, false)); EXPECT_EQ(6ul, memmgr_.bytes_allocated_managed_visible_); EXPECT_EQ(4ul, memmgr_.bytes_allocated_managed_nonvisible_); } diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h index 50763c3..22f2a79 100644 --- a/content/common/gpu/gpu_messages.h +++ b/content/common/gpu/gpu_messages.h @@ -10,7 +10,6 @@ #include "base/memory/shared_memory.h" #include "content/common/content_export.h" -#include "content/common/gpu/gpu_memory_allocation.h" #include "content/common/gpu/gpu_memory_uma_stats.h" #include "content/common/gpu/gpu_process_launch_causes.h" #include "content/common/gpu/gpu_rendering_stats.h" @@ -18,6 +17,7 @@ #include "content/public/common/gpu_memory_stats.h" #include "gpu/command_buffer/common/command_buffer.h" #include "gpu/command_buffer/common/constants.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "gpu/command_buffer/common/mailbox.h" #include "gpu/config/gpu_info.h" #include "gpu/ipc/gpu_command_buffer_traits.h" @@ -183,16 +183,16 @@ IPC_STRUCT_TRAITS_BEGIN(content::GPUMemoryUmaStats) IPC_STRUCT_TRAITS_MEMBER(bytes_limit) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(content::GpuMemoryAllocationForRenderer) +IPC_STRUCT_TRAITS_BEGIN(gpu::MemoryAllocation) IPC_STRUCT_TRAITS_MEMBER(bytes_limit_when_visible) IPC_STRUCT_TRAITS_MEMBER(priority_cutoff_when_visible) IPC_STRUCT_TRAITS_MEMBER(bytes_limit_when_not_visible) IPC_STRUCT_TRAITS_MEMBER(priority_cutoff_when_not_visible) IPC_STRUCT_TRAITS_MEMBER(have_backbuffer_when_not_visible) IPC_STRUCT_TRAITS_END() -IPC_ENUM_TRAITS(content::GpuMemoryAllocationForRenderer::PriorityCutoff) +IPC_ENUM_TRAITS(gpu::MemoryAllocation::PriorityCutoff) -IPC_STRUCT_TRAITS_BEGIN(content::GpuManagedMemoryStats) +IPC_STRUCT_TRAITS_BEGIN(gpu::ManagedMemoryStats) IPC_STRUCT_TRAITS_MEMBER(bytes_required) IPC_STRUCT_TRAITS_MEMBER(bytes_nice_to_have) IPC_STRUCT_TRAITS_MEMBER(bytes_allocated) @@ -596,13 +596,12 @@ IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_EnsureBackbuffer) // Sent to proxy when the gpu memory manager changes its memory allocation. IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SetMemoryAllocation, - content::GpuMemoryAllocationForRenderer /* allocation */) + gpu::MemoryAllocation /* allocation */) // Sent to stub from the proxy with statistics on managed memory usage and // requirements. -IPC_MESSAGE_ROUTED1( - GpuCommandBufferMsg_SendClientManagedMemoryStats, - content::GpuManagedMemoryStats /* stats */) +IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SendClientManagedMemoryStats, + gpu::ManagedMemoryStats /* stats */) // Sent to stub when proxy is assigned a memory allocation changed callback. IPC_MESSAGE_ROUTED1( diff --git a/content/content_common.gypi b/content/content_common.gypi index 0f20c4b..a021c94 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -205,7 +205,6 @@ 'common/gpu/gpu_command_buffer_stub.cc', 'common/gpu/gpu_command_buffer_stub.h', 'common/gpu/gpu_config.h', - 'common/gpu/gpu_memory_allocation.h', 'common/gpu/gpu_memory_manager.cc', 'common/gpu/gpu_memory_manager.h', 'common/gpu/gpu_memory_manager_client.cc', diff --git a/content/renderer/gpu/compositor_output_surface.cc b/content/renderer/gpu/compositor_output_surface.cc index 69074c2..cca73a7 100644 --- a/content/renderer/gpu/compositor_output_surface.cc +++ b/content/renderer/gpu/compositor_output_surface.cc @@ -103,9 +103,9 @@ bool CompositorOutputSurface::BindToClient( // Without a GPU context, the memory policy otherwise wouldn't be set. client->SetMemoryPolicy(cc::ManagedMemoryPolicy( 64 * 1024 * 1024, - cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE, + gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, 0, - cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING, + gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING, cc::ManagedMemoryPolicy::kDefaultNumResourcesLimit)); } diff --git a/gpu/command_buffer/client/client_test_helper.h b/gpu/command_buffer/client/client_test_helper.h index 71bd004..ba90e00 100644 --- a/gpu/command_buffer/client/client_test_helper.h +++ b/gpu/command_buffer/client/client_test_helper.h @@ -12,6 +12,7 @@ #include "gpu/command_buffer/common/command_buffer.h" #include "gpu/command_buffer/common/compiler_specific.h" #include "gpu/command_buffer/common/gpu_control.h" +#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -100,6 +101,8 @@ class MockClientGpuControl : public GpuControl { const base::Closure& callback)); MOCK_METHOD2(SignalQuery, void(uint32 query, const base::Closure& callback)); + MOCK_METHOD1(SendManagedMemoryStats, + void(const ManagedMemoryStats& stats)); private: DISALLOW_COPY_AND_ASSIGN(MockClientGpuControl); diff --git a/gpu/command_buffer/client/context_support.h b/gpu/command_buffer/client/context_support.h index eb50585..a620cd3 100644 --- a/gpu/command_buffer/client/context_support.h +++ b/gpu/command_buffer/client/context_support.h @@ -8,6 +8,7 @@ #include "base/callback.h" namespace gpu { +struct ManagedMemoryStats; class ContextSupport { public: @@ -19,6 +20,8 @@ class ContextSupport { // passed the glEndQueryEXT() point. virtual void SignalQuery(uint32 query, const base::Closure& callback) = 0; + virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) = 0; + protected: ContextSupport() {} virtual ~ContextSupport() {} diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 6ef8c9f..78eccf5 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -335,6 +335,12 @@ void GLES2Implementation::SignalQuery(uint32 query, weak_ptr_factory_.GetWeakPtr(), callback)); } + +void GLES2Implementation::SendManagedMemoryStats( + const ManagedMemoryStats& stats) { + gpu_control_->SendManagedMemoryStats(stats); +} + void GLES2Implementation::WaitForCmd() { TRACE_EVENT0("gpu", "GLES2::WaitForCmd"); helper_->CommandBufferHelper::Finish(); diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index 40eb50a..af791e5 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -231,6 +231,8 @@ class GLES2_IMPL_EXPORT GLES2Implementation const base::Closure& callback) OVERRIDE; virtual void SignalQuery(uint32 query, const base::Closure& callback) OVERRIDE; + virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) + OVERRIDE; void SetErrorMessageCallback(ErrorMessageCallback* callback) { error_message_callback_ = callback; diff --git a/gpu/command_buffer/common/gpu_control.h b/gpu/command_buffer/common/gpu_control.h index 9c2879a..4fdab4b 100644 --- a/gpu/command_buffer/common/gpu_control.h +++ b/gpu/command_buffer/common/gpu_control.h @@ -17,6 +17,7 @@ class GpuMemoryBuffer; } namespace gpu { +struct ManagedMemoryStats; // Common interface for GpuControl implementations. class GPU_EXPORT GpuControl { @@ -54,6 +55,8 @@ class GPU_EXPORT GpuControl { // passed the glEndQueryEXT() point. virtual void SignalQuery(uint32 query, const base::Closure& callback) = 0; + virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) = 0; + private: DISALLOW_COPY_AND_ASSIGN(GpuControl); }; diff --git a/content/common/gpu/gpu_memory_allocation.h b/gpu/command_buffer/common/gpu_memory_allocation.h index a2a9b9a..3057592 100644 --- a/content/common/gpu/gpu_memory_allocation.h +++ b/gpu/command_buffer/common/gpu_memory_allocation.h @@ -1,32 +1,30 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2013 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. -#ifndef CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_ -#define CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_ +#ifndef GPU_COMMAND_BUFFER_COMMON_GPU_MEMORY_ALLOCATION_H_ +#define GPU_COMMAND_BUFFER_COMMON_GPU_MEMORY_ALLOCATION_H_ #include "base/basictypes.h" -namespace content { +namespace gpu { // These are per context memory allocation limits set by the GpuMemoryManager // and assigned to the browser and renderer context. // They will change over time, given memory availability, and browser state. - -// Memory Allocation which will be assigned to the renderer context. -struct GpuMemoryAllocationForRenderer { +struct MemoryAllocation { enum PriorityCutoff { // Allow no allocations. - kPriorityCutoffAllowNothing, + CUTOFF_ALLOW_NOTHING, // Allow only allocations that are strictly required for correct rendering. // For compositors, this is what is visible. - kPriorityCutoffAllowOnlyRequired, + CUTOFF_ALLOW_REQUIRED_ONLY, // Allow allocations that are not strictly needed for correct rendering, but // are nice to have for performance. For compositors, this includes textures // that are a few screens away from being visible. - kPriorityCutoffAllowNiceToHave, + CUTOFF_ALLOW_NICE_TO_HAVE, // Allow all allocations. - kPriorityCutoffAllowEverything, + CUTOFF_ALLOW_EVERYTHING, }; // Limits when this renderer is visible. @@ -38,23 +36,23 @@ struct GpuMemoryAllocationForRenderer { PriorityCutoff priority_cutoff_when_not_visible; bool have_backbuffer_when_not_visible; - GpuMemoryAllocationForRenderer() + MemoryAllocation() : bytes_limit_when_visible(0), - priority_cutoff_when_visible(kPriorityCutoffAllowNothing), + priority_cutoff_when_visible(CUTOFF_ALLOW_NOTHING), bytes_limit_when_not_visible(0), - priority_cutoff_when_not_visible(kPriorityCutoffAllowNothing), + priority_cutoff_when_not_visible(CUTOFF_ALLOW_NOTHING), have_backbuffer_when_not_visible(false) { } - GpuMemoryAllocationForRenderer(uint64 bytes_limit_when_visible) + MemoryAllocation(uint64 bytes_limit_when_visible) : bytes_limit_when_visible(bytes_limit_when_visible), - priority_cutoff_when_visible(kPriorityCutoffAllowEverything), + priority_cutoff_when_visible(CUTOFF_ALLOW_EVERYTHING), bytes_limit_when_not_visible(0), - priority_cutoff_when_not_visible(kPriorityCutoffAllowNothing), + priority_cutoff_when_not_visible(CUTOFF_ALLOW_NOTHING), have_backbuffer_when_not_visible(false) { } - bool Equals(const GpuMemoryAllocationForRenderer& other) const { + bool Equals(const MemoryAllocation& other) const { return bytes_limit_when_visible == other.bytes_limit_when_visible && priority_cutoff_when_visible == other.priority_cutoff_when_visible && @@ -66,52 +64,9 @@ struct GpuMemoryAllocationForRenderer { } }; -// Memory Allocation which will be assigned to the browser. -struct GpuMemoryAllocationForBrowser { - bool suggest_have_frontbuffer; - - GpuMemoryAllocationForBrowser() - : suggest_have_frontbuffer(false) { - } - - GpuMemoryAllocationForBrowser(bool suggest_have_frontbuffer) - : suggest_have_frontbuffer(suggest_have_frontbuffer) { - } - - bool Equals(const GpuMemoryAllocationForBrowser& other) const { - return suggest_have_frontbuffer == other.suggest_have_frontbuffer; - } -}; - -// Combination of the above two Memory Allocations which will be created by the -// GpuMemoryManager. -struct GpuMemoryAllocation { - GpuMemoryAllocationForRenderer renderer_allocation; - GpuMemoryAllocationForBrowser browser_allocation; - - enum BufferAllocation { - kHasNoFrontbuffer = 0, - kHasFrontbuffer = 1, - }; - - GpuMemoryAllocation() { - } - - GpuMemoryAllocation(uint64 gpu_resource_size_in_bytes, - BufferAllocation buffer_allocation) - : renderer_allocation(gpu_resource_size_in_bytes), - browser_allocation(buffer_allocation == kHasFrontbuffer) { - } - - bool Equals(const GpuMemoryAllocation& other) const { - return renderer_allocation.Equals(other.renderer_allocation) && - browser_allocation.Equals(other.browser_allocation); - } -}; - // Memory Allocation request which is sent by a client, to help GpuMemoryManager // more ideally split memory allocations across clients. -struct GpuManagedMemoryStats { +struct ManagedMemoryStats { // Bytes required for correct rendering. uint64 bytes_required; @@ -126,14 +81,14 @@ struct GpuManagedMemoryStats { // of the buffer is known by the GPU process). bool backbuffer_requested; - GpuManagedMemoryStats() + ManagedMemoryStats() : bytes_required(0), bytes_nice_to_have(0), bytes_allocated(0), backbuffer_requested(false) { } - GpuManagedMemoryStats(uint64 bytes_required, + ManagedMemoryStats(uint64 bytes_required, uint64 bytes_nice_to_have, uint64 bytes_allocated, bool backbuffer_requested) @@ -143,7 +98,7 @@ struct GpuManagedMemoryStats { backbuffer_requested(backbuffer_requested) { } - bool Equals(const GpuManagedMemoryStats& other) const { + bool Equals(const ManagedMemoryStats& other) const { return bytes_required == other.bytes_required && bytes_nice_to_have == other.bytes_nice_to_have && bytes_allocated == other.bytes_allocated && @@ -153,4 +108,4 @@ struct GpuManagedMemoryStats { } // namespace content -#endif // CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_ +#endif // GPU_COMMAND_BUFFER_COMMON_GPU_MEMORY_ALLOCATION_H_ diff --git a/gpu/command_buffer/service/gpu_control_service.cc b/gpu/command_buffer/service/gpu_control_service.cc index c6a8b8d..8306ab0 100644 --- a/gpu/command_buffer/service/gpu_control_service.cc +++ b/gpu/command_buffer/service/gpu_control_service.cc @@ -88,6 +88,11 @@ void GpuControlService::SignalQuery(uint32 query_id, query->AddCallback(callback); } +void GpuControlService::SendManagedMemoryStats( + const ManagedMemoryStats& stats) { + NOTREACHED(); +} + bool GpuControlService::RegisterGpuMemoryBuffer( int32 id, gfx::GpuMemoryBufferHandle buffer, diff --git a/gpu/command_buffer/service/gpu_control_service.h b/gpu/command_buffer/service/gpu_control_service.h index 32016ba..b9e7474 100644 --- a/gpu/command_buffer/service/gpu_control_service.h +++ b/gpu/command_buffer/service/gpu_control_service.h @@ -44,6 +44,8 @@ class GPU_EXPORT GpuControlService : public GpuControl { const base::Closure& callback) OVERRIDE; virtual void SignalQuery(uint32 query, const base::Closure& callback) OVERRIDE; + virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) + OVERRIDE; // Register an existing gpu memory buffer and get an ID that can be used // to identify it in the command buffer. diff --git a/gpu/command_buffer/service/in_process_command_buffer.cc b/gpu/command_buffer/service/in_process_command_buffer.cc index 1d48a98..ca24a0d 100644 --- a/gpu/command_buffer/service/in_process_command_buffer.cc +++ b/gpu/command_buffer/service/in_process_command_buffer.cc @@ -730,6 +730,10 @@ void InProcessCommandBuffer::SignalQuery(unsigned query, WrapCallback(callback))); } +void InProcessCommandBuffer::SendManagedMemoryStats( + const gpu::ManagedMemoryStats& stats) { +} + gpu::error::Error InProcessCommandBuffer::GetLastError() { CheckSequencedThread(); return last_state_.error; diff --git a/gpu/command_buffer/service/in_process_command_buffer.h b/gpu/command_buffer/service/in_process_command_buffer.h index 3fd0982..ee39df6 100644 --- a/gpu/command_buffer/service/in_process_command_buffer.h +++ b/gpu/command_buffer/service/in_process_command_buffer.h @@ -122,6 +122,8 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, const base::Closure& callback) OVERRIDE; virtual void SignalQuery(uint32 query, const base::Closure& callback) OVERRIDE; + virtual void SendManagedMemoryStats(const gpu::ManagedMemoryStats& stats) + OVERRIDE; // The serializer interface to the GPU service (i.e. thread). class SchedulerClient { diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.cc b/ppapi/proxy/ppapi_command_buffer_proxy.cc index 9ea9d69..063cafb 100644 --- a/ppapi/proxy/ppapi_command_buffer_proxy.cc +++ b/ppapi/proxy/ppapi_command_buffer_proxy.cc @@ -213,6 +213,11 @@ void PpapiCommandBufferProxy::SignalQuery(uint32 query, NOTREACHED(); } +void PpapiCommandBufferProxy::SendManagedMemoryStats( + const gpu::ManagedMemoryStats& stats) { + NOTREACHED(); +} + bool PpapiCommandBufferProxy::SupportsGpuMemoryBuffer() { return false; } diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.h b/ppapi/proxy/ppapi_command_buffer_proxy.h index 430054d..bca5190 100644 --- a/ppapi/proxy/ppapi_command_buffer_proxy.h +++ b/ppapi/proxy/ppapi_command_buffer_proxy.h @@ -61,6 +61,8 @@ class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy const base::Closure& callback) OVERRIDE; virtual void SignalQuery(uint32 query, const base::Closure& callback) OVERRIDE; + virtual void SendManagedMemoryStats(const gpu::ManagedMemoryStats& stats) + OVERRIDE; private: bool Send(IPC::Message* msg); diff --git a/webkit/common/gpu/context_provider_in_process.cc b/webkit/common/gpu/context_provider_in_process.cc index 272baed..bbadcb9 100644 --- a/webkit/common/gpu/context_provider_in_process.cc +++ b/webkit/common/gpu/context_provider_in_process.cc @@ -13,7 +13,6 @@ #include "cc/output/managed_memory_policy.h" #include "gpu/command_buffer/client/gles2_implementation.h" #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" -#include "webkit/common/gpu/managed_memory_policy_convert.h" namespace webkit { namespace gpu { @@ -59,28 +58,6 @@ class ContextProviderInProcess::SwapBuffersCompleteCallbackProxy ContextProviderInProcess* provider_; }; -class ContextProviderInProcess::MemoryAllocationCallbackProxy - : public WebKit::WebGraphicsContext3D:: - WebGraphicsMemoryAllocationChangedCallbackCHROMIUM { - public: - explicit MemoryAllocationCallbackProxy(ContextProviderInProcess* provider) - : provider_(provider) { - provider_->context3d_->setMemoryAllocationChangedCallbackCHROMIUM(this); - } - - virtual ~MemoryAllocationCallbackProxy() { - provider_->context3d_->setMemoryAllocationChangedCallbackCHROMIUM(NULL); - } - - virtual void onMemoryAllocationChanged( - WebKit::WebGraphicsMemoryAllocation allocation) { - provider_->OnMemoryAllocationChanged(allocation); - } - - private: - ContextProviderInProcess* provider_; -}; - // static scoped_refptr<ContextProviderInProcess> ContextProviderInProcess::Create( scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, @@ -140,8 +117,6 @@ bool ContextProviderInProcess::BindToCurrentThread() { lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); swap_buffers_complete_callback_proxy_.reset( new SwapBuffersCompleteCallbackProxy(this)); - memory_allocation_callback_proxy_.reset( - new MemoryAllocationCallbackProxy(this)); return true; } @@ -226,27 +201,6 @@ void ContextProviderInProcess::OnSwapBuffersComplete() { swap_buffers_complete_callback_.Run(); } -void ContextProviderInProcess::OnMemoryAllocationChanged( - const WebKit::WebGraphicsMemoryAllocation& allocation) { - DCHECK(context_thread_checker_.CalledOnValidThread()); - - if (gr_context_) { - bool nonzero_allocation = !!allocation.gpuResourceSizeInBytes; - gr_context_->SetMemoryLimit(nonzero_allocation); - } - - if (memory_policy_changed_callback_.is_null()) - return; - - bool discard_backbuffer_when_not_visible; - cc::ManagedMemoryPolicy policy = - ManagedMemoryPolicyConvert::Convert(allocation, - &discard_backbuffer_when_not_visible); - - memory_policy_changed_callback_.Run( - policy, discard_backbuffer_when_not_visible); -} - bool ContextProviderInProcess::DestroyedOnMainThread() { DCHECK(main_thread_checker_.CalledOnValidThread()); @@ -272,10 +226,7 @@ void ContextProviderInProcess::SetSwapBuffersCompleteCallback( void ContextProviderInProcess::SetMemoryPolicyChangedCallback( const MemoryPolicyChangedCallback& memory_policy_changed_callback) { - DCHECK(context_thread_checker_.CalledOnValidThread()); - DCHECK(memory_policy_changed_callback_.is_null() || - memory_policy_changed_callback.is_null()); - memory_policy_changed_callback_ = memory_policy_changed_callback; + // There's no memory manager for the in-process implementation. } } // namespace gpu diff --git a/webkit/common/gpu/context_provider_in_process.h b/webkit/common/gpu/context_provider_in_process.h index 288e6a9..36c2bcd 100644 --- a/webkit/common/gpu/context_provider_in_process.h +++ b/webkit/common/gpu/context_provider_in_process.h @@ -13,10 +13,7 @@ #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" #include "webkit/common/gpu/webkit_gpu_export.h" -namespace WebKit { -class WebGraphicsContext3D; -struct WebGraphicsMemoryAllocation; -} +namespace WebKit { class WebGraphicsContext3D; } namespace webkit { namespace gpu { @@ -57,8 +54,6 @@ class WEBKIT_GPU_EXPORT ContextProviderInProcess void OnLostContext(); void OnSwapBuffersComplete(); - void OnMemoryAllocationChanged( - const WebKit::WebGraphicsMemoryAllocation& allocation); private: base::ThreadChecker main_thread_checker_; @@ -70,7 +65,6 @@ class WEBKIT_GPU_EXPORT ContextProviderInProcess LostContextCallback lost_context_callback_; SwapBuffersCompleteCallback swap_buffers_complete_callback_; - MemoryPolicyChangedCallback memory_policy_changed_callback_; base::Lock destroyed_lock_; bool destroyed_; @@ -83,8 +77,7 @@ class WEBKIT_GPU_EXPORT ContextProviderInProcess scoped_ptr<SwapBuffersCompleteCallbackProxy> swap_buffers_complete_callback_proxy_; - class MemoryAllocationCallbackProxy; - scoped_ptr<MemoryAllocationCallbackProxy> memory_allocation_callback_proxy_; + DISALLOW_COPY_AND_ASSIGN(ContextProviderInProcess); }; } // namespace gpu diff --git a/webkit/common/gpu/managed_memory_policy_convert.cc b/webkit/common/gpu/managed_memory_policy_convert.cc deleted file mode 100644 index 548e2ae..0000000 --- a/webkit/common/gpu/managed_memory_policy_convert.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2013 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 "webkit/common/gpu/managed_memory_policy_convert.h" - -namespace webkit { -namespace gpu { - -static cc::ManagedMemoryPolicy::PriorityCutoff ConvertPriorityCutoff( - WebKit::WebGraphicsMemoryAllocation::PriorityCutoff priority_cutoff) { - // This is simple a 1:1 map, the names differ only because the WebKit names - // should be to match the cc names. - switch (priority_cutoff) { - case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing: - return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; - case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly: - return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; - case WebKit::WebGraphicsMemoryAllocation:: - PriorityCutoffAllowVisibleAndNearby: - return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE; - case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything: - return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING; - } - NOTREACHED(); - return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; -} - -// static -cc::ManagedMemoryPolicy ManagedMemoryPolicyConvert::Convert( - const WebKit::WebGraphicsMemoryAllocation& allocation, - bool* discard_backbuffer_when_not_visible) { - *discard_backbuffer_when_not_visible = !allocation.suggestHaveBackbuffer; - return cc::ManagedMemoryPolicy( - allocation.bytesLimitWhenVisible, - ConvertPriorityCutoff(allocation.priorityCutoffWhenVisible), - allocation.bytesLimitWhenNotVisible, - ConvertPriorityCutoff(allocation.priorityCutoffWhenNotVisible), - cc::ManagedMemoryPolicy::kDefaultNumResourcesLimit); -} - -} // namespace gpu -} // namespace webkit diff --git a/webkit/common/gpu/managed_memory_policy_convert.h b/webkit/common/gpu/managed_memory_policy_convert.h deleted file mode 100644 index 0309683..0000000 --- a/webkit/common/gpu/managed_memory_policy_convert.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2013 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. - -#ifndef WEBKIT_COMMON_GPU_MANAGED_MEMORY_POLICY_CONVERT_H_ -#define WEBKIT_COMMON_GPU_MANAGED_MEMORY_POLICY_CONVERT_H_ - -#include "cc/output/managed_memory_policy.h" -#include "third_party/WebKit/public/platform/WebGraphicsMemoryAllocation.h" -#include "webkit/common/gpu/webkit_gpu_export.h" - -namespace webkit { -namespace gpu { - -class WEBKIT_GPU_EXPORT ManagedMemoryPolicyConvert { - public: - static cc::ManagedMemoryPolicy Convert( - const WebKit::WebGraphicsMemoryAllocation& allocation, - bool* discard_backbuffer_when_not_visible); -}; - -} // namespace gpu -} // namespace webkit - -#endif // WEBKIT_COMMON_GPU_MANAGED_MEMORY_POLICY_CONVERT_H_ diff --git a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc index 6413641..e287183 100644 --- a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc +++ b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc @@ -398,11 +398,6 @@ void WebGraphicsContext3DInProcessCommandBufferImpl::setVisibilityCHROMIUM( bool visible) { } -void WebGraphicsContext3DInProcessCommandBufferImpl:: - setMemoryAllocationChangedCallbackCHROMIUM( - WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { -} - void WebGraphicsContext3DInProcessCommandBufferImpl::discardFramebufferEXT( WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments) { gl_->DiscardFramebufferEXT(target, numAttachments, attachments); diff --git a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h index e136254..1631819 100644 --- a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h +++ b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h @@ -440,9 +440,6 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl virtual void setVisibilityCHROMIUM(bool visible); - virtual void setMemoryAllocationChangedCallbackCHROMIUM( - WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback); - virtual void discardFramebufferEXT(WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments); diff --git a/webkit/common/gpu/webkit_gpu.gyp b/webkit/common/gpu/webkit_gpu.gyp index 86f7e43..522b9cf 100644 --- a/webkit/common/gpu/webkit_gpu.gyp +++ b/webkit/common/gpu/webkit_gpu.gyp @@ -36,8 +36,6 @@ 'gl_bindings_skia_cmd_buffer.h', 'grcontext_for_webgraphicscontext3d.cc', 'grcontext_for_webgraphicscontext3d.h', - 'managed_memory_policy_convert.cc', - 'managed_memory_policy_convert.h', 'test_context_provider_factory.cc', 'test_context_provider_factory.h', 'webgraphicscontext3d_in_process_command_buffer_impl.cc', |