diff options
author | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 21:50:36 +0000 |
---|---|---|
committer | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 21:50:36 +0000 |
commit | 142b19f13984918a79842905ddfee6efed72e56d (patch) | |
tree | 7efe121e525119596cbe23fdc6b12120b43c6ae5 /cc | |
parent | 6b4c88b9d8dc0dbcca025bd768dd62dce09d362a (diff) | |
download | chromium_src-142b19f13984918a79842905ddfee6efed72e56d.zip chromium_src-142b19f13984918a79842905ddfee6efed72e56d.tar.gz chromium_src-142b19f13984918a79842905ddfee6efed72e56d.tar.bz2 |
Revert 257161 "Revert 256955 "Add shared bitmap managers for bro..."
Turns out the child process was mapping the memory twice, so fixed that.
> Revert 256955 "Add shared bitmap managers for browser and render..."
>
> Seems to be causing renderer crashes and possibly out-of-memory issues.
>
> > Add shared bitmap managers for browser and renderer processes.
> >
> > The shared bitmap managers will allow software tiles to be allocated in shared memory, so delegated rendering could be used with them.
> >
> > BUG=327220
> > R=danakj@chromium.org, jschuh@chromium.org, piman@chromium.org
> >
> > Review URL: https://codereview.chromium.org/148243013
>
> TBR=jbauman@chromium.org
>
> Review URL: https://codereview.chromium.org/197703004
TBR=jbauman@chromium.org
Review URL: https://codereview.chromium.org/200913002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257216 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/output/delegating_renderer.cc | 4 | ||||
-rw-r--r-- | cc/resources/resource_provider.cc | 3 | ||||
-rw-r--r-- | cc/resources/shared_bitmap.cc | 25 | ||||
-rw-r--r-- | cc/resources/shared_bitmap.h | 6 |
4 files changed, 35 insertions, 3 deletions
diff --git a/cc/output/delegating_renderer.cc b/cc/output/delegating_renderer.cc index 66cd53c..b189386 100644 --- a/cc/output/delegating_renderer.cc +++ b/cc/output/delegating_renderer.cc @@ -162,8 +162,8 @@ void DelegatingRenderer::SetVisible(bool 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->ContextSupport()->SetSurfaceVisible(visible); + if (context_provider) + context_provider->ContextSupport()->SetSurfaceVisible(visible); } void DelegatingRenderer::SendManagedMemoryStats(size_t bytes_visible, diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index ed1d0da..2fee3d2 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc @@ -1949,7 +1949,8 @@ void ResourceProvider::BeginSetPixels(ResourceId id) { DCHECK(resource->pixel_buffer); DCHECK_EQ(RGBA_8888, resource->format); - std::swap(resource->pixels, resource->pixel_buffer); + memcpy( + resource->pixels, resource->pixel_buffer, 4 * resource->size.GetArea()); delete[] resource->pixel_buffer; resource->pixel_buffer = NULL; } diff --git a/cc/resources/shared_bitmap.cc b/cc/resources/shared_bitmap.cc index 3a6fc35..3b94d45 100644 --- a/cc/resources/shared_bitmap.cc +++ b/cc/resources/shared_bitmap.cc @@ -4,6 +4,9 @@ #include "cc/resources/shared_bitmap.h" +#include "base/numerics/safe_math.h" +#include "base/rand_util.h" + namespace cc { SharedBitmap::SharedBitmap( @@ -14,4 +17,26 @@ SharedBitmap::SharedBitmap( SharedBitmap::~SharedBitmap() { free_callback_.Run(this); } +// static +bool SharedBitmap::GetSizeInBytes(const gfx::Size& size, + size_t* size_in_bytes) { + if (size.width() <= 0 || size.height() <= 0) + return false; + base::CheckedNumeric<int> s = size.width(); + s *= size.height(); + s *= 4; + if (!s.IsValid()) + return false; + *size_in_bytes = s.ValueOrDie(); + return true; +} + +// static +SharedBitmapId SharedBitmap::GenerateId() { + SharedBitmapId id; + // Needs cryptographically-secure random numbers. + base::RandBytes(id.name, sizeof(id.name)); + return id; +} + } // namespace cc diff --git a/cc/resources/shared_bitmap.h b/cc/resources/shared_bitmap.h index 9575068..d62ffcc 100644 --- a/cc/resources/shared_bitmap.h +++ b/cc/resources/shared_bitmap.h @@ -10,6 +10,7 @@ #include "base/memory/shared_memory.h" #include "cc/base/cc_export.h" #include "gpu/command_buffer/common/mailbox.h" +#include "ui/gfx/size.h" namespace base { class SharedMemory; } @@ -38,6 +39,11 @@ class CC_EXPORT SharedBitmap { SharedBitmapId id() { return id_; } + // Returns true if the size is valid and false otherwise. + static bool GetSizeInBytes(const gfx::Size& size, size_t* size_in_bytes); + + static SharedBitmapId GenerateId(); + private: base::SharedMemory* memory_; SharedBitmapId id_; |