Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: cc/surfaces/surface_factory.cc

Issue 2661543002: Rename LocalFrameId to LocalSurfaceId (Closed)
Patch Set: c Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_factory_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 void SurfaceFactory::Reset() { 46 void SurfaceFactory::Reset() {
47 EvictSurface(); 47 EvictSurface();
48 // Disown Surfaces that are still alive so that they don't try to unref 48 // Disown Surfaces that are still alive so that they don't try to unref
49 // resources that we're not tracking any more. 49 // resources that we're not tracking any more.
50 weak_factory_.InvalidateWeakPtrs(); 50 weak_factory_.InvalidateWeakPtrs();
51 holder_.Reset(); 51 holder_.Reset();
52 } 52 }
53 53
54 void SurfaceFactory::SubmitCompositorFrame(const LocalFrameId& local_frame_id, 54 void SurfaceFactory::SubmitCompositorFrame(
55 CompositorFrame frame, 55 const LocalSurfaceId& local_surface_id,
56 const DrawCallback& callback) { 56 CompositorFrame frame,
57 const DrawCallback& callback) {
57 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame"); 58 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame");
58 DCHECK(local_frame_id.is_valid()); 59 DCHECK(local_surface_id.is_valid());
59 std::unique_ptr<Surface> surface; 60 std::unique_ptr<Surface> surface;
60 bool create_new_surface = 61 bool create_new_surface =
61 (!current_surface_ || 62 (!current_surface_ ||
62 local_frame_id != current_surface_->surface_id().local_frame_id()); 63 local_surface_id != current_surface_->surface_id().local_surface_id());
63 if (!create_new_surface) { 64 if (!create_new_surface) {
64 surface = std::move(current_surface_); 65 surface = std::move(current_surface_);
65 } else { 66 } else {
66 surface = Create(local_frame_id); 67 surface = Create(local_surface_id);
67 gfx::Size frame_size; 68 gfx::Size frame_size;
68 // CompositorFrames may not be populated with a RenderPass in unit tests. 69 // CompositorFrames may not be populated with a RenderPass in unit tests.
69 if (!frame.render_pass_list.empty()) 70 if (!frame.render_pass_list.empty())
70 frame_size = frame.render_pass_list.back()->output_rect.size(); 71 frame_size = frame.render_pass_list.back()->output_rect.size();
71 manager_->SurfaceCreated(SurfaceInfo( 72 manager_->SurfaceCreated(SurfaceInfo(
72 surface->surface_id(), frame.metadata.device_scale_factor, frame_size)); 73 surface->surface_id(), frame.metadata.device_scale_factor, frame_size));
73 } 74 }
74 surface->QueueFrame(std::move(frame), callback); 75 surface->QueueFrame(std::move(frame), callback);
75 if (!manager_->SurfaceModified(SurfaceId(frame_sink_id_, local_frame_id))) { 76 if (!manager_->SurfaceModified(SurfaceId(frame_sink_id_, local_surface_id))) {
76 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD); 77 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD);
77 surface->RunDrawCallbacks(); 78 surface->RunDrawCallbacks();
78 } 79 }
79 if (current_surface_ && create_new_surface) { 80 if (current_surface_ && create_new_surface) {
80 surface->SetPreviousFrameSurface(current_surface_.get()); 81 surface->SetPreviousFrameSurface(current_surface_.get());
81 Destroy(std::move(current_surface_)); 82 Destroy(std::move(current_surface_));
82 } 83 }
83 current_surface_ = std::move(surface); 84 current_surface_ = std::move(surface);
84 } 85 }
85 86
86 void SurfaceFactory::RequestCopyOfSurface( 87 void SurfaceFactory::RequestCopyOfSurface(
87 std::unique_ptr<CopyOutputRequest> copy_request) { 88 std::unique_ptr<CopyOutputRequest> copy_request) {
88 if (!current_surface_) { 89 if (!current_surface_) {
89 copy_request->SendEmptyResult(); 90 copy_request->SendEmptyResult();
90 return; 91 return;
91 } 92 }
92 DCHECK(current_surface_->factory().get() == this); 93 DCHECK(current_surface_->factory().get() == this);
93 current_surface_->RequestCopyOfOutput(std::move(copy_request)); 94 current_surface_->RequestCopyOfOutput(std::move(copy_request));
94 manager_->SurfaceModified(current_surface_->surface_id()); 95 manager_->SurfaceModified(current_surface_->surface_id());
95 } 96 }
96 97
97 void SurfaceFactory::ClearSurface() { 98 void SurfaceFactory::ClearSurface() {
98 if (!current_surface_) 99 if (!current_surface_)
99 return; 100 return;
100 current_surface_->EvictFrame(); 101 current_surface_->EvictFrame();
101 manager_->SurfaceModified(current_surface_->surface_id()); 102 manager_->SurfaceModified(current_surface_->surface_id());
102 } 103 }
103 104
104 void SurfaceFactory::WillDrawSurface(const LocalFrameId& id, 105 void SurfaceFactory::WillDrawSurface(const LocalSurfaceId& id,
105 const gfx::Rect& damage_rect) { 106 const gfx::Rect& damage_rect) {
106 client_->WillDrawSurface(id, damage_rect); 107 client_->WillDrawSurface(id, damage_rect);
107 } 108 }
108 109
109 void SurfaceFactory::ReceiveFromChild( 110 void SurfaceFactory::ReceiveFromChild(
110 const TransferableResourceArray& resources) { 111 const TransferableResourceArray& resources) {
111 holder_.ReceiveFromChild(resources); 112 holder_.ReceiveFromChild(resources);
112 } 113 }
113 114
114 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { 115 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) {
115 holder_.RefResources(resources); 116 holder_.RefResources(resources);
116 } 117 }
117 118
118 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { 119 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) {
119 holder_.UnrefResources(resources); 120 holder_.UnrefResources(resources);
120 } 121 }
121 122
122 std::unique_ptr<Surface> SurfaceFactory::Create( 123 std::unique_ptr<Surface> SurfaceFactory::Create(
123 const LocalFrameId& local_frame_id) { 124 const LocalSurfaceId& local_surface_id) {
124 auto surface = base::MakeUnique<Surface>( 125 auto surface = base::MakeUnique<Surface>(
125 SurfaceId(frame_sink_id_, local_frame_id), weak_factory_.GetWeakPtr()); 126 SurfaceId(frame_sink_id_, local_surface_id), weak_factory_.GetWeakPtr());
126 manager_->RegisterSurface(surface.get()); 127 manager_->RegisterSurface(surface.get());
127 return surface; 128 return surface;
128 } 129 }
129 130
130 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { 131 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) {
131 if (manager_) 132 if (manager_)
132 manager_->Destroy(std::move(surface)); 133 manager_->Destroy(std::move(surface));
133 } 134 }
134 135
135 } // namespace cc 136 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_factory_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698