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

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

Issue 2610723002: Unify SurfaceInfo (Closed)
Patch Set: Cleanup offscreen canvas Created 3 years, 11 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/display.cc ('k') | cc/surfaces/surface_factory_unittest.cc » ('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"
11 #include "cc/output/compositor_frame.h" 11 #include "cc/output/compositor_frame.h"
12 #include "cc/output/copy_output_request.h" 12 #include "cc/output/copy_output_request.h"
13 #include "cc/surfaces/surface.h" 13 #include "cc/surfaces/surface.h"
14 #include "cc/surfaces/surface_factory_client.h" 14 #include "cc/surfaces/surface_factory_client.h"
15 #include "cc/surfaces/surface_info.h"
15 #include "cc/surfaces/surface_manager.h" 16 #include "cc/surfaces/surface_manager.h"
16 #include "ui/gfx/geometry/size.h" 17 #include "ui/gfx/geometry/size.h"
17 18
18 namespace cc { 19 namespace cc {
19 SurfaceFactory::SurfaceFactory(const FrameSinkId& frame_sink_id, 20 SurfaceFactory::SurfaceFactory(const FrameSinkId& frame_sink_id,
20 SurfaceManager* manager, 21 SurfaceManager* manager,
21 SurfaceFactoryClient* client) 22 SurfaceFactoryClient* client)
22 : frame_sink_id_(frame_sink_id), 23 : frame_sink_id_(frame_sink_id),
23 manager_(manager), 24 manager_(manager),
24 client_(client), 25 client_(client),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 (!current_surface_ || 61 (!current_surface_ ||
61 local_frame_id != current_surface_->surface_id().local_frame_id()); 62 local_frame_id != current_surface_->surface_id().local_frame_id());
62 if (!create_new_surface) { 63 if (!create_new_surface) {
63 surface = std::move(current_surface_); 64 surface = std::move(current_surface_);
64 } else { 65 } else {
65 surface = Create(local_frame_id); 66 surface = Create(local_frame_id);
66 gfx::Size frame_size; 67 gfx::Size frame_size;
67 // CompositorFrames may not be populated with a RenderPass in unit tests. 68 // CompositorFrames may not be populated with a RenderPass in unit tests.
68 if (!frame.render_pass_list.empty()) 69 if (!frame.render_pass_list.empty())
69 frame_size = frame.render_pass_list[0]->output_rect.size(); 70 frame_size = frame.render_pass_list[0]->output_rect.size();
70 manager_->SurfaceCreated(surface->surface_id(), frame_size, 71 manager_->SurfaceCreated(SurfaceInfo(
71 frame.metadata.device_scale_factor); 72 surface->surface_id(), frame.metadata.device_scale_factor, frame_size));
72 } 73 }
73 surface->QueueFrame(std::move(frame), callback); 74 surface->QueueFrame(std::move(frame), callback);
74 if (!manager_->SurfaceModified(SurfaceId(frame_sink_id_, local_frame_id))) { 75 if (!manager_->SurfaceModified(SurfaceId(frame_sink_id_, local_frame_id))) {
75 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD); 76 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD);
76 surface->RunDrawCallbacks(); 77 surface->RunDrawCallbacks();
77 } 78 }
78 if (current_surface_ && create_new_surface) { 79 if (current_surface_ && create_new_surface) {
79 surface->SetPreviousFrameSurface(current_surface_.get()); 80 surface->SetPreviousFrameSurface(current_surface_.get());
80 Destroy(std::move(current_surface_)); 81 Destroy(std::move(current_surface_));
81 } 82 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 manager_->RegisterSurface(surface.get()); 126 manager_->RegisterSurface(surface.get());
126 return surface; 127 return surface;
127 } 128 }
128 129
129 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { 130 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) {
130 if (manager_) 131 if (manager_)
131 manager_->Destroy(std::move(surface)); 132 manager_->Destroy(std::move(surface));
132 } 133 }
133 134
134 } // namespace cc 135 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/display.cc ('k') | cc/surfaces/surface_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698