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

Side by Side Diff: cc/test/test_context_support.cc

Issue 2252163003: Update Context Client Visibility to use Scoped Pattern (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 4 years, 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/test/test_context_support.h" 5 #include "cc/test/test_context_support.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/memory/ptr_util.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "gpu/command_buffer/client/scoped_visibility_impl.h"
14 16
15 namespace cc { 17 namespace cc {
16 18
17 TestContextSupport::TestContextSupport() 19 TestContextSupport::TestContextSupport()
18 : out_of_order_callbacks_(false), weak_ptr_factory_(this) {} 20 : out_of_order_callbacks_(false),
21 visible_clients_(0),
22 weak_ptr_factory_(this) {}
19 23
20 TestContextSupport::~TestContextSupport() {} 24 TestContextSupport::~TestContextSupport() {}
21 25
22 void TestContextSupport::SignalSyncToken(const gpu::SyncToken& sync_token, 26 void TestContextSupport::SignalSyncToken(const gpu::SyncToken& sync_token,
23 const base::Closure& callback) { 27 const base::Closure& callback) {
24 sync_point_callbacks_.push_back(callback); 28 sync_point_callbacks_.push_back(callback);
25 base::ThreadTaskRunnerHandle::Get()->PostTask( 29 base::ThreadTaskRunnerHandle::Get()->PostTask(
26 FROM_HERE, base::Bind(&TestContextSupport::CallAllSyncPointCallbacks, 30 FROM_HERE, base::Bind(&TestContextSupport::CallAllSyncPointCallbacks,
27 weak_ptr_factory_.GetWeakPtr())); 31 weak_ptr_factory_.GetWeakPtr()));
28 } 32 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 88 }
85 89
86 uint64_t TestContextSupport::ShareGroupTracingGUID() const { 90 uint64_t TestContextSupport::ShareGroupTracingGUID() const {
87 NOTIMPLEMENTED(); 91 NOTIMPLEMENTED();
88 return 0; 92 return 0;
89 } 93 }
90 94
91 void TestContextSupport::SetErrorMessageCallback( 95 void TestContextSupport::SetErrorMessageCallback(
92 const base::Callback<void(const char*, int32_t)>& callback) {} 96 const base::Callback<void(const char*, int32_t)>& callback) {}
93 97
94 void TestContextSupport::SetClientVisible(int client_id, bool is_visible) { 98 std::unique_ptr<gpu::ContextSupport::ScopedVisibility>
95 if (is_visible) { 99 TestContextSupport::ClientBecameVisible() {
96 visible_clients_.insert(client_id); 100 ++visible_clients_;
97 } else { 101 return std::unique_ptr<gpu::ScopedVisibilityImpl>(
danakj 2016/08/18 21:39:44 I think you can just write your own impl here, I d
ericrk 2016/08/19 17:23:19 makes sense, moved to cc file
98 auto found = visible_clients_.find(client_id); 102 new gpu::ScopedVisibilityImpl(this));
99 if (found != visible_clients_.end()) 103 }
100 visible_clients_.erase(found); 104
101 } 105 void TestContextSupport::ClientBecameNotVisible(
106 std::unique_ptr<ScopedVisibility> visibility) {
107 DCHECK_GT(visible_clients_, 0u);
108 --visible_clients_;
109 static_cast<gpu::ScopedVisibilityImpl*>(visibility.get())->Release(this);
102 } 110 }
103 111
104 bool TestContextSupport::AnyClientsVisible() const { 112 bool TestContextSupport::AnyClientsVisible() const {
105 return !visible_clients_.empty(); 113 return visible_clients_ > 0;
106 } 114 }
107 115
108 } // namespace cc 116 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698