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

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

Issue 2443003004: cc: Make OutputSurface::BindToClient pure virtual and not return bool (Closed)
Patch Set: bindtoclient-pure-virtual: rebase Created 4 years, 1 month 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/output/output_surface_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 (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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "base/trace_event/trace_event.h" 13 #include "base/trace_event/trace_event.h"
14 #include "cc/output/output_surface_client.h" 14 #include "cc/output/output_surface_client.h"
15 #include "cc/output/output_surface_frame.h" 15 #include "cc/output/output_surface_frame.h"
16 #include "gpu/GLES2/gl2extchromium.h" 16 #include "gpu/GLES2/gl2extchromium.h"
17 #include "gpu/command_buffer/client/context_support.h" 17 #include "gpu/command_buffer/client/context_support.h"
18 #include "gpu/command_buffer/client/gles2_interface.h" 18 #include "gpu/command_buffer/client/gles2_interface.h"
19 19
20 namespace cc { 20 namespace cc {
21 21
22 OutputSurface::OutputSurface(scoped_refptr<ContextProvider> context_provider) 22 OutputSurface::OutputSurface(scoped_refptr<ContextProvider> context_provider)
23 : context_provider_(std::move(context_provider)) { 23 : context_provider_(std::move(context_provider)) {
24 DCHECK(context_provider_); 24 DCHECK(context_provider_);
25 thread_checker_.DetachFromThread();
26 } 25 }
27 26
28 OutputSurface::OutputSurface( 27 OutputSurface::OutputSurface(
29 std::unique_ptr<SoftwareOutputDevice> software_device) 28 std::unique_ptr<SoftwareOutputDevice> software_device)
30 : software_device_(std::move(software_device)) { 29 : software_device_(std::move(software_device)) {
31 DCHECK(software_device_); 30 DCHECK(software_device_);
32 thread_checker_.DetachFromThread();
33 } 31 }
34 32
35 OutputSurface::OutputSurface( 33 OutputSurface::OutputSurface(
36 scoped_refptr<VulkanContextProvider> vulkan_context_provider) 34 scoped_refptr<VulkanContextProvider> vulkan_context_provider)
37 : vulkan_context_provider_(std::move(vulkan_context_provider)) { 35 : vulkan_context_provider_(std::move(vulkan_context_provider)) {
38 DCHECK(vulkan_context_provider_); 36 DCHECK(vulkan_context_provider_);
39 thread_checker_.DetachFromThread();
40 } 37 }
41 38
42 OutputSurface::~OutputSurface() { 39 OutputSurface::~OutputSurface() = default;
43 // Is destroyed on the thread it is bound to.
44 DCHECK(thread_checker_.CalledOnValidThread());
45
46 if (!client_)
47 return;
48
49 if (context_provider_) {
50 context_provider_->SetLostContextCallback(
51 ContextProvider::LostContextCallback());
52 }
53 }
54
55 bool OutputSurface::BindToClient(OutputSurfaceClient* client) {
56 DCHECK(thread_checker_.CalledOnValidThread());
57 DCHECK(client);
58 DCHECK(!client_);
59 client_ = client;
60
61 if (context_provider_) {
62 if (!context_provider_->BindToCurrentThread())
63 return false;
64 context_provider_->SetLostContextCallback(base::Bind(
65 &OutputSurface::DidLoseOutputSurface, base::Unretained(this)));
66 }
67 return true;
68 }
69
70 void OutputSurface::DidLoseOutputSurface() {
71 TRACE_EVENT0("cc", "OutputSurface::DidLoseOutputSurface");
72 client_->DidLoseOutputSurface();
73 }
74 40
75 } // namespace cc 41 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/output_surface.h ('k') | cc/output/output_surface_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698