| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/surfaces/surface_factory.h" | 5 #include "cc/surfaces/surface_factory.h" |
| 6 | 6 |
| 7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
| 8 #include "cc/output/copy_output_request.h" | 8 #include "cc/output/copy_output_request.h" |
| 9 #include "cc/surfaces/surface.h" | 9 #include "cc/surfaces/surface.h" |
| 10 #include "cc/surfaces/surface_manager.h" | 10 #include "cc/surfaces/surface_manager.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 void SurfaceFactory::Create(SurfaceId surface_id, const gfx::Size& size) { | 22 void SurfaceFactory::Create(SurfaceId surface_id, const gfx::Size& size) { |
| 23 scoped_ptr<Surface> surface(new Surface(surface_id, size, this)); | 23 scoped_ptr<Surface> surface(new Surface(surface_id, size, this)); |
| 24 manager_->RegisterSurface(surface.get()); | 24 manager_->RegisterSurface(surface.get()); |
| 25 DCHECK(!surface_map_.count(surface_id)); | 25 DCHECK(!surface_map_.count(surface_id)); |
| 26 surface_map_.add(surface_id, surface.Pass()); | 26 surface_map_.add(surface_id, surface.Pass()); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void SurfaceFactory::Destroy(SurfaceId surface_id) { | 29 void SurfaceFactory::Destroy(SurfaceId surface_id) { |
| 30 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); | 30 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); |
| 31 DCHECK(it != surface_map_.end()); | 31 DCHECK(it != surface_map_.end()); |
| 32 DCHECK(it->second->factory() == this); | 32 DCHECK(it->second->factory().get() == this); |
| 33 manager_->DeregisterSurface(surface_id); | 33 manager_->DeregisterSurface(surface_id); |
| 34 surface_map_.erase(it); | 34 surface_map_.erase(it); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void SurfaceFactory::DestroyOnSequence( |
| 38 SurfaceId surface_id, |
| 39 const std::set<SurfaceSequence>& dependency_set) { |
| 40 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); |
| 41 DCHECK(it != surface_map_.end()); |
| 42 DCHECK(it->second->factory().get() == this); |
| 43 manager_->DestroyOnSequence(surface_map_.take_and_erase(it), dependency_set); |
| 44 } |
| 45 |
| 37 void SurfaceFactory::SubmitFrame(SurfaceId surface_id, | 46 void SurfaceFactory::SubmitFrame(SurfaceId surface_id, |
| 38 scoped_ptr<CompositorFrame> frame, | 47 scoped_ptr<CompositorFrame> frame, |
| 39 const base::Closure& callback) { | 48 const base::Closure& callback) { |
| 40 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); | 49 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); |
| 41 DCHECK(it != surface_map_.end()); | 50 DCHECK(it != surface_map_.end()); |
| 42 DCHECK(it->second->factory() == this); | 51 DCHECK(it->second->factory().get() == this); |
| 43 it->second->QueueFrame(frame.Pass(), callback); | 52 it->second->QueueFrame(frame.Pass(), callback); |
| 44 manager_->SurfaceModified(surface_id); | 53 manager_->SurfaceModified(surface_id); |
| 45 } | 54 } |
| 46 | 55 |
| 47 void SurfaceFactory::RequestCopyOfSurface( | 56 void SurfaceFactory::RequestCopyOfSurface( |
| 48 SurfaceId surface_id, | 57 SurfaceId surface_id, |
| 49 scoped_ptr<CopyOutputRequest> copy_request) { | 58 scoped_ptr<CopyOutputRequest> copy_request) { |
| 50 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); | 59 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); |
| 51 if (it == surface_map_.end()) { | 60 if (it == surface_map_.end()) { |
| 52 copy_request->SendEmptyResult(); | 61 copy_request->SendEmptyResult(); |
| 53 return; | 62 return; |
| 54 } | 63 } |
| 55 DCHECK(it->second->factory() == this); | 64 DCHECK(it->second->factory().get() == this); |
| 56 it->second->RequestCopyOfOutput(copy_request.Pass()); | 65 it->second->RequestCopyOfOutput(copy_request.Pass()); |
| 57 manager_->SurfaceModified(surface_id); | 66 manager_->SurfaceModified(surface_id); |
| 58 } | 67 } |
| 59 | 68 |
| 60 void SurfaceFactory::ReceiveFromChild( | 69 void SurfaceFactory::ReceiveFromChild( |
| 61 const TransferableResourceArray& resources) { | 70 const TransferableResourceArray& resources) { |
| 62 holder_.ReceiveFromChild(resources); | 71 holder_.ReceiveFromChild(resources); |
| 63 } | 72 } |
| 64 | 73 |
| 65 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { | 74 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { |
| 66 holder_.RefResources(resources); | 75 holder_.RefResources(resources); |
| 67 } | 76 } |
| 68 | 77 |
| 69 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { | 78 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { |
| 70 holder_.UnrefResources(resources); | 79 holder_.UnrefResources(resources); |
| 71 } | 80 } |
| 72 | 81 |
| 73 } // namespace cc | 82 } // namespace cc |
| OLD | NEW |