Commit 2504061c authored by jamesr's avatar jamesr Committed by Commit bot

Always make context current in ViewManager's BitmapUploader, be laxer 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}
parent 1ad1d983
......@@ -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) {
......
......@@ -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);
......@@ -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();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment