| 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 "base/trace_event/trace_event.h" |
| 7 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
| 8 #include "cc/output/copy_output_request.h" | 9 #include "cc/output/copy_output_request.h" |
| 9 #include "cc/surfaces/surface.h" | 10 #include "cc/surfaces/surface.h" |
| 10 #include "cc/surfaces/surface_manager.h" | 11 #include "cc/surfaces/surface_manager.h" |
| 11 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
| 12 | 13 |
| 13 namespace cc { | 14 namespace cc { |
| 14 SurfaceFactory::SurfaceFactory(SurfaceManager* manager, | 15 SurfaceFactory::SurfaceFactory(SurfaceManager* manager, |
| 15 SurfaceFactoryClient* client) | 16 SurfaceFactoryClient* client) |
| 16 : manager_(manager), | 17 : manager_(manager), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 43 void SurfaceFactory::Destroy(SurfaceId surface_id) { | 44 void SurfaceFactory::Destroy(SurfaceId surface_id) { |
| 44 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); | 45 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); |
| 45 DCHECK(it != surface_map_.end()); | 46 DCHECK(it != surface_map_.end()); |
| 46 DCHECK(it->second->factory().get() == this); | 47 DCHECK(it->second->factory().get() == this); |
| 47 manager_->Destroy(surface_map_.take_and_erase(it)); | 48 manager_->Destroy(surface_map_.take_and_erase(it)); |
| 48 } | 49 } |
| 49 | 50 |
| 50 void SurfaceFactory::SubmitFrame(SurfaceId surface_id, | 51 void SurfaceFactory::SubmitFrame(SurfaceId surface_id, |
| 51 scoped_ptr<CompositorFrame> frame, | 52 scoped_ptr<CompositorFrame> frame, |
| 52 const DrawCallback& callback) { | 53 const DrawCallback& callback) { |
| 54 TRACE_EVENT0("cc", "SurfaceFactory::SubmitFrame"); |
| 53 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); | 55 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); |
| 54 DCHECK(it != surface_map_.end()); | 56 DCHECK(it != surface_map_.end()); |
| 55 DCHECK(it->second->factory().get() == this); | 57 DCHECK(it->second->factory().get() == this); |
| 56 it->second->QueueFrame(frame.Pass(), callback); | 58 it->second->QueueFrame(frame.Pass(), callback); |
| 57 if (!manager_->SurfaceModified(surface_id)) | 59 if (!manager_->SurfaceModified(surface_id)) { |
| 60 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD); |
| 58 it->second->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED); | 61 it->second->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED); |
| 62 } |
| 59 } | 63 } |
| 60 | 64 |
| 61 void SurfaceFactory::RequestCopyOfSurface( | 65 void SurfaceFactory::RequestCopyOfSurface( |
| 62 SurfaceId surface_id, | 66 SurfaceId surface_id, |
| 63 scoped_ptr<CopyOutputRequest> copy_request) { | 67 scoped_ptr<CopyOutputRequest> copy_request) { |
| 64 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); | 68 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); |
| 65 if (it == surface_map_.end()) { | 69 if (it == surface_map_.end()) { |
| 66 copy_request->SendEmptyResult(); | 70 copy_request->SendEmptyResult(); |
| 67 return; | 71 return; |
| 68 } | 72 } |
| 69 DCHECK(it->second->factory().get() == this); | 73 DCHECK(it->second->factory().get() == this); |
| 70 it->second->RequestCopyOfOutput(copy_request.Pass()); | 74 it->second->RequestCopyOfOutput(copy_request.Pass()); |
| 71 manager_->SurfaceModified(surface_id); | 75 manager_->SurfaceModified(surface_id); |
| 72 } | 76 } |
| 73 | 77 |
| 74 void SurfaceFactory::ReceiveFromChild( | 78 void SurfaceFactory::ReceiveFromChild( |
| 75 const TransferableResourceArray& resources) { | 79 const TransferableResourceArray& resources) { |
| 76 holder_.ReceiveFromChild(resources); | 80 holder_.ReceiveFromChild(resources); |
| 77 } | 81 } |
| 78 | 82 |
| 79 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { | 83 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { |
| 80 holder_.RefResources(resources); | 84 holder_.RefResources(resources); |
| 81 } | 85 } |
| 82 | 86 |
| 83 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { | 87 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { |
| 84 holder_.UnrefResources(resources); | 88 holder_.UnrefResources(resources); |
| 85 } | 89 } |
| 86 | 90 |
| 87 } // namespace cc | 91 } // namespace cc |
| OLD | NEW |