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

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

Issue 793693003: Tile Compression (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 "gpu/command_buffer/service/async_pixel_transfer_manager_sync.h" 5 #include "gpu/command_buffer/service/async_pixel_transfer_manager_sync.h"
6 6
7 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h" 7 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h"
8 8
9 namespace gpu { 9 namespace gpu {
10 10
11 // Class which handles async pixel transfers synchronously. 11 // Class which handles async pixel transfers synchronously.
12 class AsyncPixelTransferDelegateSync : public AsyncPixelTransferDelegate { 12 class AsyncPixelTransferDelegateSync : public AsyncPixelTransferDelegate {
13 public: 13 public:
14 explicit AsyncPixelTransferDelegateSync( 14 explicit AsyncPixelTransferDelegateSync(
15 AsyncPixelTransferManagerSync::SharedState* shared_state); 15 AsyncPixelTransferManagerSync::SharedState* shared_state);
16 ~AsyncPixelTransferDelegateSync() override; 16 ~AsyncPixelTransferDelegateSync() override;
17 17
18 // Implement AsyncPixelTransferDelegate: 18 // Implement AsyncPixelTransferDelegate:
19 void AsyncTexImage2D(const AsyncTexImage2DParams& tex_params, 19 void AsyncTexImage2D(const AsyncTexImage2DParams& tex_params,
20 const AsyncMemoryParams& mem_params, 20 const AsyncMemoryParams& mem_params,
21 const base::Closure& bind_callback) override; 21 const base::Closure& bind_callback) override;
22 void AsyncTexSubImage2D(const AsyncTexSubImage2DParams& tex_params, 22 void AsyncTexSubImage2D(const AsyncTexSubImage2DParams& tex_params,
23 const AsyncMemoryParams& mem_params) override; 23 const AsyncMemoryParams& mem_params) override;
24 void AsyncCompressedTexImage2D(
25 const AsyncCompressedTexImage2DParams& tex_params,
26 const AsyncMemoryParams& mem_params,
27 const base::Closure& bind_callback) override;
28 void AsyncCompressedTexSubImage2D(
29 const AsyncCompressedTexSubImage2DParams& tex_params,
30 const AsyncMemoryParams& mem_params) override;
24 bool TransferIsInProgress() override; 31 bool TransferIsInProgress() override;
25 void WaitForTransferCompletion() override; 32 void WaitForTransferCompletion() override;
26 33
27 private: 34 private:
28 // Safe to hold a raw pointer because SharedState is owned by the Manager 35 // Safe to hold a raw pointer because SharedState is owned by the Manager
29 // which owns the Delegate. 36 // which owns the Delegate.
30 AsyncPixelTransferManagerSync::SharedState* shared_state_; 37 AsyncPixelTransferManagerSync::SharedState* shared_state_;
31 38
32 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateSync); 39 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateSync);
33 }; 40 };
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 tex_params.width, 83 tex_params.width,
77 tex_params.height, 84 tex_params.height,
78 tex_params.format, 85 tex_params.format,
79 tex_params.type, 86 tex_params.type,
80 data); 87 data);
81 shared_state_->texture_upload_count++; 88 shared_state_->texture_upload_count++;
82 shared_state_->total_texture_upload_time += 89 shared_state_->total_texture_upload_time +=
83 base::TimeTicks::HighResNow() - begin_time; 90 base::TimeTicks::HighResNow() - begin_time;
84 } 91 }
85 92
93 void AsyncPixelTransferDelegateSync::AsyncCompressedTexImage2D(
94 const AsyncCompressedTexImage2DParams& tex_params,
95 const AsyncMemoryParams& mem_params,
96 const base::Closure& bind_callback) {
97 // Save the define params to return later during deferred
98 // binding of the transfer texture.
99 void* data = mem_params.GetDataAddress();
100 base::TimeTicks begin_time(base::TimeTicks::HighResNow());
101 glCompressedTexImage2D(tex_params.target, tex_params.level,
102 tex_params.internal_format, tex_params.width,
103 tex_params.height, tex_params.border,
104 tex_params.image_size, data);
105 shared_state_->texture_upload_count++;
106 shared_state_->total_texture_upload_time +=
107 base::TimeTicks::HighResNow() - begin_time;
108 // The texture is already fully bound so just call it now.
109 bind_callback.Run();
110 }
111
112 void AsyncPixelTransferDelegateSync::AsyncCompressedTexSubImage2D(
113 const AsyncCompressedTexSubImage2DParams& tex_params,
114 const AsyncMemoryParams& mem_params) {
115 void* data = mem_params.GetDataAddress();
116 base::TimeTicks begin_time(base::TimeTicks::HighResNow());
117 glCompressedTexSubImage2D(tex_params.target, tex_params.level,
118 tex_params.xoffset, tex_params.yoffset,
119 tex_params.width, tex_params.height,
120 tex_params.format, tex_params.image_size, data);
121 shared_state_->texture_upload_count++;
122 shared_state_->total_texture_upload_time +=
123 base::TimeTicks::HighResNow() - begin_time;
124 }
125
86 bool AsyncPixelTransferDelegateSync::TransferIsInProgress() { 126 bool AsyncPixelTransferDelegateSync::TransferIsInProgress() {
87 // Already done. 127 // Already done.
88 return false; 128 return false;
89 } 129 }
90 130
91 void AsyncPixelTransferDelegateSync::WaitForTransferCompletion() { 131 void AsyncPixelTransferDelegateSync::WaitForTransferCompletion() {
92 // Already done. 132 // Already done.
93 } 133 }
94 134
95 AsyncPixelTransferManagerSync::SharedState::SharedState() 135 AsyncPixelTransferManagerSync::SharedState::SharedState()
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void AsyncPixelTransferManagerSync::WaitAllAsyncTexImage2D() { 169 void AsyncPixelTransferManagerSync::WaitAllAsyncTexImage2D() {
130 } 170 }
131 171
132 AsyncPixelTransferDelegate* 172 AsyncPixelTransferDelegate*
133 AsyncPixelTransferManagerSync::CreatePixelTransferDelegateImpl( 173 AsyncPixelTransferManagerSync::CreatePixelTransferDelegateImpl(
134 gles2::TextureRef* ref, 174 gles2::TextureRef* ref,
135 const AsyncTexImage2DParams& define_params) { 175 const AsyncTexImage2DParams& define_params) {
136 return new AsyncPixelTransferDelegateSync(&shared_state_); 176 return new AsyncPixelTransferDelegateSync(&shared_state_);
137 } 177 }
138 178
179 AsyncPixelTransferDelegate*
180 AsyncPixelTransferManagerSync::CreatePixelTransferDelegateImpl(
181 gles2::TextureRef* ref,
182 const AsyncCompressedTexImage2DParams& define_params) {
183 return new AsyncPixelTransferDelegateSync(&shared_state_);
184 }
185
139 } // namespace gpu 186 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/async_pixel_transfer_manager_sync.h ('k') | gpu/command_buffer/service/feature_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698