}
SurfaceFactory::~SurfaceFactory() {
+ if (!surface_map_.empty()) {
+ LOG(ERROR) << "SurfaceFactory has " << surface_map_.size()
+ << " entries in map on destruction.";
+ }
+ DestroyAll();
+}
+
+void SurfaceFactory::DestroyAll() {
+ for (auto it = surface_map_.begin(); it != surface_map_.end(); ++it)
+ manager_->Destroy(surface_map_.take(it));
+ surface_map_.clear();
}
void SurfaceFactory::Create(SurfaceId surface_id, const gfx::Size& size) {
void SurfaceFactory::Destroy(SurfaceId surface_id) {
OwningSurfaceMap::iterator it = surface_map_.find(surface_id);
DCHECK(it != surface_map_.end());
- DCHECK(it->second->factory() == this);
- manager_->DeregisterSurface(surface_id);
- surface_map_.erase(it);
+ DCHECK(it->second->factory().get() == this);
+ manager_->Destroy(surface_map_.take_and_erase(it));
}
void SurfaceFactory::SubmitFrame(SurfaceId surface_id,
const base::Closure& callback) {
OwningSurfaceMap::iterator it = surface_map_.find(surface_id);
DCHECK(it != surface_map_.end());
- DCHECK(it->second->factory() == this);
+ DCHECK(it->second->factory().get() == this);
it->second->QueueFrame(frame.Pass(), callback);
manager_->SurfaceModified(surface_id);
}
copy_request->SendEmptyResult();
return;
}
- DCHECK(it->second->factory() == this);
+ DCHECK(it->second->factory().get() == this);
it->second->RequestCopyOfOutput(copy_request.Pass());
manager_->SurfaceModified(surface_id);
}