Skip to content

Commit

Permalink
Always make context current in ViewManager's BitmapUploader, be laxer…
Browse files Browse the repository at this point in the history
… in SurfaceResourceHolder

When in the component build multiple threads (apps) will use the same
view manager client lib and could fight over the current GL context, so
always make our context current in BitmapUploader.

When shutting down abrubtly (i.e. when losing a connection to an app),
the client will not necessarily properly unref all resources it uses.
DCHECKing here isn't helpful, so just skip over resources that are not
fully unreffed.

R=ben@chromium.org

Review URL: https://codereview.chromium.org/569173007

Cr-Commit-Position: refs/heads/master@{#294943}
  • Loading branch information
jamesr authored and Commit bot committed Sep 16, 2014
1 parent 1ad1d98 commit 2504061
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cc/surfaces/surface_resource_holder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ void SurfaceResourceHolder::UnrefResources(
++it) {
ResourceProvider::ResourceId id = it->id;
ResourceIdCountMap::iterator count_it = resource_id_use_count_map_.find(id);
DCHECK(count_it != resource_id_use_count_map_.end());
if (count_it == resource_id_use_count_map_.end())
continue;
ResourceRefs& ref = count_it->second;
ref.refs_holding_resource_alive -= it->count;
if (ref.refs_holding_resource_alive == 0) {
Expand Down
4 changes: 4 additions & 0 deletions mojo/services/public/cpp/view_manager/lib/bitmap_uploader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void BitmapUploader::Upload() {
pass->quads.resize(0u);
pass->shared_quad_states.push_back(CreateDefaultSQS(size_));

MojoGLES2MakeCurrent(gles2_context_);
if (!bitmap_.isNull()) {
gfx::Size bitmap_size(bitmap_.width(), bitmap_.height());
GLuint texture_id = BindTextureForSize(bitmap_size);
Expand Down Expand Up @@ -185,6 +186,9 @@ void BitmapUploader::Upload() {
}

void BitmapUploader::ReturnResources(Array<ReturnedResourcePtr> resources) {
if (!resources.size())
return;
MojoGLES2MakeCurrent(gles2_context_);
// TODO(jamesr): Recycle.
for (size_t i = 0; i < resources.size(); ++i) {
ReturnedResourcePtr resource = resources[i].Pass();
Expand Down

0 comments on commit 2504061

Please sign in to comment.