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

Side by Side Diff: cc/output/output_surface.cc

Issue 1356463002: Revert of cc: Implement shared worker contexts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/output/output_surface.h ('k') | cc/raster/tile_task_worker_pool_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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/output/output_surface.h" 5 #include "cc/output/output_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 14 matching lines...) Expand all
25 const scoped_refptr<ContextProvider>& context_provider, 25 const scoped_refptr<ContextProvider>& context_provider,
26 const scoped_refptr<ContextProvider>& worker_context_provider, 26 const scoped_refptr<ContextProvider>& worker_context_provider,
27 scoped_ptr<SoftwareOutputDevice> software_device) 27 scoped_ptr<SoftwareOutputDevice> software_device)
28 : client_(NULL), 28 : client_(NULL),
29 context_provider_(context_provider), 29 context_provider_(context_provider),
30 worker_context_provider_(worker_context_provider), 30 worker_context_provider_(worker_context_provider),
31 software_device_(software_device.Pass()), 31 software_device_(software_device.Pass()),
32 device_scale_factor_(-1), 32 device_scale_factor_(-1),
33 external_stencil_test_enabled_(false), 33 external_stencil_test_enabled_(false),
34 weak_ptr_factory_(this) { 34 weak_ptr_factory_(this) {
35 client_thread_checker_.DetachFromThread();
36 } 35 }
37 36
38 OutputSurface::OutputSurface( 37 OutputSurface::OutputSurface(
39 const scoped_refptr<ContextProvider>& context_provider) 38 const scoped_refptr<ContextProvider>& context_provider)
40 : OutputSurface(context_provider, nullptr, nullptr) { 39 : OutputSurface(context_provider, nullptr, nullptr) {
41 } 40 }
42 41
43 OutputSurface::OutputSurface( 42 OutputSurface::OutputSurface(
44 const scoped_refptr<ContextProvider>& context_provider, 43 const scoped_refptr<ContextProvider>& context_provider,
45 const scoped_refptr<ContextProvider>& worker_context_provider) 44 const scoped_refptr<ContextProvider>& worker_context_provider)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 bool resourceless_software_draw) { 94 bool resourceless_software_draw) {
96 client_->SetExternalDrawConstraints(transform, 95 client_->SetExternalDrawConstraints(transform,
97 viewport, 96 viewport,
98 clip, 97 clip,
99 viewport_rect_for_tile_priority, 98 viewport_rect_for_tile_priority,
100 transform_for_tile_priority, 99 transform_for_tile_priority,
101 resourceless_software_draw); 100 resourceless_software_draw);
102 } 101 }
103 102
104 OutputSurface::~OutputSurface() { 103 OutputSurface::~OutputSurface() {
105 if (client_) 104 if (context_provider_.get()) {
106 DetachFromClient(); 105 context_provider_->SetLostContextCallback(
106 ContextProvider::LostContextCallback());
107 context_provider_->SetMemoryPolicyChangedCallback(
108 ContextProvider::MemoryPolicyChangedCallback());
109 }
107 } 110 }
108 111
109 bool OutputSurface::HasExternalStencilTest() const { 112 bool OutputSurface::HasExternalStencilTest() const {
110 return external_stencil_test_enabled_; 113 return external_stencil_test_enabled_;
111 } 114 }
112 115
113 bool OutputSurface::BindToClient(OutputSurfaceClient* client) { 116 bool OutputSurface::BindToClient(OutputSurfaceClient* client) {
114 DCHECK(client_thread_checker_.CalledOnValidThread());
115 DCHECK(client); 117 DCHECK(client);
116 DCHECK(!client_);
117 client_ = client; 118 client_ = client;
118 bool success = true; 119 bool success = true;
119 120
120 if (context_provider_.get()) { 121 if (context_provider_.get()) {
121 success = context_provider_->BindToCurrentThread(); 122 success = context_provider_->BindToCurrentThread();
122 if (success) { 123 if (success) {
123 context_provider_->SetLostContextCallback(base::Bind( 124 context_provider_->SetLostContextCallback(base::Bind(
124 &OutputSurface::DidLoseOutputSurface, base::Unretained(this))); 125 &OutputSurface::DidLoseOutputSurface, base::Unretained(this)));
125 context_provider_->SetMemoryPolicyChangedCallback( 126 context_provider_->SetMemoryPolicyChangedCallback(
126 base::Bind(&OutputSurface::SetMemoryPolicy, base::Unretained(this))); 127 base::Bind(&OutputSurface::SetMemoryPolicy, base::Unretained(this)));
127 } 128 }
128 } 129 }
129 130
131 if (success && worker_context_provider_.get()) {
132 success = worker_context_provider_->BindToCurrentThread();
133 if (success)
134 worker_context_provider_->SetupLock();
135 }
136
130 if (!success) 137 if (!success)
131 client_ = NULL; 138 client_ = NULL;
132 139
133 return success; 140 return success;
134 } 141 }
135 142
136 void OutputSurface::DetachFromClient() {
137 DCHECK(client_thread_checker_.CalledOnValidThread());
138 DCHECK(client_);
139 if (context_provider_.get()) {
140 context_provider_->SetLostContextCallback(
141 ContextProvider::LostContextCallback());
142 context_provider_->SetMemoryPolicyChangedCallback(
143 ContextProvider::MemoryPolicyChangedCallback());
144 }
145 context_provider_ = nullptr;
146 client_ = nullptr;
147 weak_ptr_factory_.InvalidateWeakPtrs();
148 }
149
150 void OutputSurface::EnsureBackbuffer() { 143 void OutputSurface::EnsureBackbuffer() {
151 if (software_device_) 144 if (software_device_)
152 software_device_->EnsureBackbuffer(); 145 software_device_->EnsureBackbuffer();
153 } 146 }
154 147
155 void OutputSurface::DiscardBackbuffer() { 148 void OutputSurface::DiscardBackbuffer() {
156 if (context_provider_.get()) 149 if (context_provider_.get())
157 context_provider_->ContextGL()->DiscardBackbufferCHROMIUM(); 150 context_provider_->ContextGL()->DiscardBackbufferCHROMIUM();
158 if (software_device_) 151 if (software_device_)
159 software_device_->DiscardBackbuffer(); 152 software_device_->DiscardBackbuffer();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 aggressively_free_resources); 218 aggressively_free_resources);
226 } 219 }
227 } 220 }
228 } 221 }
229 222
230 bool OutputSurface::SurfaceIsSuspendForRecycle() const { 223 bool OutputSurface::SurfaceIsSuspendForRecycle() const {
231 return false; 224 return false;
232 } 225 }
233 226
234 } // namespace cc 227 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/output_surface.h ('k') | cc/raster/tile_task_worker_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698