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

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

Issue 1186393004: gpu: Remove async texture uploads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "gpu/command_buffer/service/async_pixel_transfer_manager_sync.h"
6
7 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h"
8
9 namespace gpu {
10
11 // Class which handles async pixel transfers synchronously.
12 class AsyncPixelTransferDelegateSync : public AsyncPixelTransferDelegate {
13 public:
14 explicit AsyncPixelTransferDelegateSync(
15 AsyncPixelTransferManagerSync::SharedState* shared_state);
16 ~AsyncPixelTransferDelegateSync() override;
17
18 // Implement AsyncPixelTransferDelegate:
19 void AsyncTexImage2D(const AsyncTexImage2DParams& tex_params,
20 const AsyncMemoryParams& mem_params,
21 const base::Closure& bind_callback) override;
22 void AsyncTexSubImage2D(const AsyncTexSubImage2DParams& tex_params,
23 const AsyncMemoryParams& mem_params) override;
24 bool TransferIsInProgress() override;
25 void WaitForTransferCompletion() override;
26
27 private:
28 // Safe to hold a raw pointer because SharedState is owned by the Manager
29 // which owns the Delegate.
30 AsyncPixelTransferManagerSync::SharedState* shared_state_;
31
32 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateSync);
33 };
34
35 AsyncPixelTransferDelegateSync::AsyncPixelTransferDelegateSync(
36 AsyncPixelTransferManagerSync::SharedState* shared_state)
37 : shared_state_(shared_state) {}
38
39 AsyncPixelTransferDelegateSync::~AsyncPixelTransferDelegateSync() {}
40
41 void AsyncPixelTransferDelegateSync::AsyncTexImage2D(
42 const AsyncTexImage2DParams& tex_params,
43 const AsyncMemoryParams& mem_params,
44 const base::Closure& bind_callback) {
45 // Save the define params to return later during deferred
46 // binding of the transfer texture.
47 void* data = mem_params.GetDataAddress();
48 base::TimeTicks begin_time(base::TimeTicks::Now());
49 glTexImage2D(
50 tex_params.target,
51 tex_params.level,
52 tex_params.internal_format,
53 tex_params.width,
54 tex_params.height,
55 tex_params.border,
56 tex_params.format,
57 tex_params.type,
58 data);
59 shared_state_->texture_upload_count++;
60 shared_state_->total_texture_upload_time +=
61 base::TimeTicks::Now() - begin_time;
62 // The texture is already fully bound so just call it now.
63 bind_callback.Run();
64 }
65
66 void AsyncPixelTransferDelegateSync::AsyncTexSubImage2D(
67 const AsyncTexSubImage2DParams& tex_params,
68 const AsyncMemoryParams& mem_params) {
69 void* data = mem_params.GetDataAddress();
70 base::TimeTicks begin_time(base::TimeTicks::Now());
71 glTexSubImage2D(
72 tex_params.target,
73 tex_params.level,
74 tex_params.xoffset,
75 tex_params.yoffset,
76 tex_params.width,
77 tex_params.height,
78 tex_params.format,
79 tex_params.type,
80 data);
81 shared_state_->texture_upload_count++;
82 shared_state_->total_texture_upload_time +=
83 base::TimeTicks::Now() - begin_time;
84 }
85
86 bool AsyncPixelTransferDelegateSync::TransferIsInProgress() {
87 // Already done.
88 return false;
89 }
90
91 void AsyncPixelTransferDelegateSync::WaitForTransferCompletion() {
92 // Already done.
93 }
94
95 AsyncPixelTransferManagerSync::SharedState::SharedState()
96 : texture_upload_count(0) {}
97
98 AsyncPixelTransferManagerSync::SharedState::~SharedState() {}
99
100 AsyncPixelTransferManagerSync::AsyncPixelTransferManagerSync() {}
101
102 AsyncPixelTransferManagerSync::~AsyncPixelTransferManagerSync() {}
103
104 void AsyncPixelTransferManagerSync::BindCompletedAsyncTransfers() {
105 // Everything is already bound.
106 }
107
108 void AsyncPixelTransferManagerSync::AsyncNotifyCompletion(
109 const AsyncMemoryParams& mem_params,
110 AsyncPixelTransferCompletionObserver* observer) {
111 observer->DidComplete(mem_params);
112 }
113
114 uint32 AsyncPixelTransferManagerSync::GetTextureUploadCount() {
115 return shared_state_.texture_upload_count;
116 }
117
118 base::TimeDelta AsyncPixelTransferManagerSync::GetTotalTextureUploadTime() {
119 return shared_state_.total_texture_upload_time;
120 }
121
122 void AsyncPixelTransferManagerSync::ProcessMorePendingTransfers() {
123 }
124
125 bool AsyncPixelTransferManagerSync::NeedsProcessMorePendingTransfers() {
126 return false;
127 }
128
129 void AsyncPixelTransferManagerSync::WaitAllAsyncTexImage2D() {
130 }
131
132 AsyncPixelTransferDelegate*
133 AsyncPixelTransferManagerSync::CreatePixelTransferDelegateImpl(
134 gles2::TextureRef* ref,
135 const AsyncTexImage2DParams& define_params) {
136 return new AsyncPixelTransferDelegateSync(&shared_state_);
137 }
138
139 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698