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

Side by Side Diff: gpu/command_buffer/service/async_pixel_transfer_manager_idle.cc

Issue 16325018: GPU: Factory produces APTManagers instead of APTDelegates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
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 "gpu/command_buffer/service/async_pixel_transfer_delegate_idle.h" 5 #include "gpu/command_buffer/service/async_pixel_transfer_manager_idle.h"
6
7 #include <list>
6 8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
9 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
10 #include "gpu/command_buffer/service/safe_shared_memory_pool.h" 12 #include "gpu/command_buffer/service/safe_shared_memory_pool.h"
11 #include "ui/gl/scoped_binders.h" 13 #include "ui/gl/scoped_binders.h"
12 14
13 namespace gpu { 15 namespace gpu {
14 16
15 namespace { 17 namespace {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 private: 56 private:
55 virtual ~AsyncPixelTransferStateImpl() {} 57 virtual ~AsyncPixelTransferStateImpl() {}
56 58
57 uint64 id_; 59 uint64 id_;
58 GLuint texture_id_; 60 GLuint texture_id_;
59 bool transfer_in_progress_; 61 bool transfer_in_progress_;
60 }; 62 };
61 63
62 } // namespace 64 } // namespace
63 65
66 // Class which handles async pixel transfers in a platform
67 // independent way.
68 class AsyncPixelTransferDelegateIdle : public AsyncPixelTransferDelegate,
69 public base::SupportsWeakPtr<AsyncPixelTransferDelegateIdle> {
70 public:
71 AsyncPixelTransferDelegateIdle();
72 virtual ~AsyncPixelTransferDelegateIdle();
73
74 // implement AsyncPixelTransferDelegate:
75 virtual AsyncPixelTransferState* CreatePixelTransferState(
76 GLuint texture_id,
77 const AsyncTexImage2DParams& define_params) OVERRIDE;
78 virtual void BindCompletedAsyncTransfers() OVERRIDE;
79 virtual void AsyncNotifyCompletion(
80 const AsyncMemoryParams& mem_params,
81 const CompletionCallback& callback) OVERRIDE;
82 virtual void AsyncTexImage2D(
83 AsyncPixelTransferState* transfer_state,
84 const AsyncTexImage2DParams& tex_params,
85 const AsyncMemoryParams& mem_params,
86 const base::Closure& bind_callback) OVERRIDE;
87 virtual void AsyncTexSubImage2D(
88 AsyncPixelTransferState* transfer_state,
89 const AsyncTexSubImage2DParams& tex_params,
90 const AsyncMemoryParams& mem_params) OVERRIDE;
91 virtual void WaitForTransferCompletion(
92 AsyncPixelTransferState* transfer_state) OVERRIDE;
93 virtual uint32 GetTextureUploadCount() OVERRIDE;
94 virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
95 virtual void ProcessMorePendingTransfers() OVERRIDE;
96 virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
97
98 private:
99 struct Task {
100 Task(uint64 transfer_id, const base::Closure& task);
101 ~Task();
102
103 // This is non-zero if pixel transfer task.
104 uint64 transfer_id;
105
106 base::Closure task;
107 };
108
109 void ProcessNotificationTasks();
110
111 void PerformNotifyCompletion(
112 AsyncMemoryParams mem_params,
113 ScopedSafeSharedMemory* safe_shared_memory,
114 const CompletionCallback& callback);
115 void PerformAsyncTexImage2D(
116 AsyncTexImage2DParams tex_params,
117 AsyncMemoryParams mem_params,
118 const base::Closure& bind_callback,
119 ScopedSafeSharedMemory* safe_shared_memory,
120 GLuint texture_id);
121 void PerformAsyncTexSubImage2D(
122 AsyncTexSubImage2DParams tex_params,
123 AsyncMemoryParams mem_params,
124 ScopedSafeSharedMemory* safe_shared_memory,
125 GLuint texture_id);
126
127 int texture_upload_count_;
128 base::TimeDelta total_texture_upload_time_;
129
130 std::list<Task> tasks_;
131
132 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateIdle);
133 };
134
64 AsyncPixelTransferDelegateIdle::Task::Task( 135 AsyncPixelTransferDelegateIdle::Task::Task(
65 uint64 transfer_id, const base::Closure& task) 136 uint64 transfer_id, const base::Closure& task)
66 : transfer_id(transfer_id), 137 : transfer_id(transfer_id),
67 task(task) { 138 task(task) {
68 } 139 }
69 140
70 AsyncPixelTransferDelegateIdle::Task::~Task() {} 141 AsyncPixelTransferDelegateIdle::Task::~Task() {}
71 142
72 AsyncPixelTransferDelegateIdle::AsyncPixelTransferDelegateIdle() 143 AsyncPixelTransferDelegateIdle::AsyncPixelTransferDelegateIdle()
73 : texture_upload_count_(0) { 144 : texture_upload_count_(0) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 tex_params.height, 360 tex_params.height,
290 tex_params.format, 361 tex_params.format,
291 tex_params.type, 362 tex_params.type,
292 data); 363 data);
293 } 364 }
294 365
295 texture_upload_count_++; 366 texture_upload_count_++;
296 total_texture_upload_time_ += base::TimeTicks::HighResNow() - begin_time; 367 total_texture_upload_time_ += base::TimeTicks::HighResNow() - begin_time;
297 } 368 }
298 369
370 AsyncPixelTransferManagerIdle::AsyncPixelTransferManagerIdle()
371 : delegate_(new AsyncPixelTransferDelegateIdle()) {}
372
373 AsyncPixelTransferManagerIdle::~AsyncPixelTransferManagerIdle() {}
374
375 AsyncPixelTransferDelegate*
376 AsyncPixelTransferManagerIdle::GetAsyncPixelTransferDelegate() {
377 return delegate_.get();
378 }
379
299 } // namespace gpu 380 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698