Don't add an aura tooltip to bubble close buttons on Windows.
[chromium-blink-merge.git] / gpu / command_buffer / service / async_pixel_transfer_manager_sync.cc
blob589598bca8f4757ef4aa4c3e6aeb79612e97d2ee
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.
5 #include "gpu/command_buffer/service/async_pixel_transfer_manager_sync.h"
7 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h"
9 namespace gpu {
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;
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;
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_;
32 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateSync);
35 AsyncPixelTransferDelegateSync::AsyncPixelTransferDelegateSync(
36 AsyncPixelTransferManagerSync::SharedState* shared_state)
37 : shared_state_(shared_state) {}
39 AsyncPixelTransferDelegateSync::~AsyncPixelTransferDelegateSync() {}
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();
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;
86 bool AsyncPixelTransferDelegateSync::TransferIsInProgress() {
87 // Already done.
88 return false;
91 void AsyncPixelTransferDelegateSync::WaitForTransferCompletion() {
92 // Already done.
95 AsyncPixelTransferManagerSync::SharedState::SharedState()
96 : texture_upload_count(0) {}
98 AsyncPixelTransferManagerSync::SharedState::~SharedState() {}
100 AsyncPixelTransferManagerSync::AsyncPixelTransferManagerSync() {}
102 AsyncPixelTransferManagerSync::~AsyncPixelTransferManagerSync() {}
104 void AsyncPixelTransferManagerSync::BindCompletedAsyncTransfers() {
105 // Everything is already bound.
108 void AsyncPixelTransferManagerSync::AsyncNotifyCompletion(
109 const AsyncMemoryParams& mem_params,
110 AsyncPixelTransferCompletionObserver* observer) {
111 observer->DidComplete(mem_params);
114 uint32 AsyncPixelTransferManagerSync::GetTextureUploadCount() {
115 return shared_state_.texture_upload_count;
118 base::TimeDelta AsyncPixelTransferManagerSync::GetTotalTextureUploadTime() {
119 return shared_state_.total_texture_upload_time;
122 void AsyncPixelTransferManagerSync::ProcessMorePendingTransfers() {
125 bool AsyncPixelTransferManagerSync::NeedsProcessMorePendingTransfers() {
126 return false;
129 void AsyncPixelTransferManagerSync::WaitAllAsyncTexImage2D() {
132 AsyncPixelTransferDelegate*
133 AsyncPixelTransferManagerSync::CreatePixelTransferDelegateImpl(
134 gles2::TextureRef* ref,
135 const AsyncTexImage2DParams& define_params) {
136 return new AsyncPixelTransferDelegateSync(&shared_state_);
139 } // namespace gpu