Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / gpu / command_buffer / service / async_pixel_transfer_delegate.h
blobb41bcd52444db1a234ce9dd82b968d145388bd29
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
3 // found in the LICENSE file.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_DELEGATE_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_DELEGATE_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/synchronization/lock.h"
13 #include "base/time/time.h"
14 #include "gpu/command_buffer/common/buffer.h"
15 #include "gpu/gpu_export.h"
16 #include "ui/gl/gl_bindings.h"
18 namespace base {
19 class SharedMemory;
22 namespace gpu {
24 struct AsyncTexImage2DParams {
25 GLenum target;
26 GLint level;
27 GLenum internal_format;
28 GLsizei width;
29 GLsizei height;
30 GLint border;
31 GLenum format;
32 GLenum type;
35 struct AsyncTexSubImage2DParams {
36 GLenum target;
37 GLint level;
38 GLint xoffset;
39 GLint yoffset;
40 GLsizei width;
41 GLsizei height;
42 GLenum format;
43 GLenum type;
46 class AsyncMemoryParams {
47 public:
48 AsyncMemoryParams(scoped_refptr<Buffer> buffer,
49 uint32 data_offset,
50 uint32 data_size);
51 ~AsyncMemoryParams();
53 scoped_refptr<Buffer> buffer() const { return buffer_; }
54 uint32 data_size() const { return data_size_; }
55 uint32 data_offset() const { return data_offset_; }
56 void* GetDataAddress() const {
57 return buffer_->GetDataAddress(data_offset_, data_size_);
60 private:
61 scoped_refptr<Buffer> buffer_;
62 uint32 data_offset_;
63 uint32 data_size_;
66 class AsyncPixelTransferUploadStats
67 : public base::RefCountedThreadSafe<AsyncPixelTransferUploadStats> {
68 public:
69 AsyncPixelTransferUploadStats();
71 void AddUpload(base::TimeDelta transfer_time);
72 int GetStats(base::TimeDelta* total_texture_upload_time);
74 private:
75 friend class base::RefCountedThreadSafe<AsyncPixelTransferUploadStats>;
77 ~AsyncPixelTransferUploadStats();
79 int texture_upload_count_;
80 base::TimeDelta total_texture_upload_time_;
81 base::Lock lock_;
83 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferUploadStats);
86 class GPU_EXPORT AsyncPixelTransferDelegate {
87 public:
88 virtual ~AsyncPixelTransferDelegate();
90 // The callback occurs on the caller thread, once the texture is
91 // safe/ready to be used.
92 virtual void AsyncTexImage2D(
93 const AsyncTexImage2DParams& tex_params,
94 const AsyncMemoryParams& mem_params,
95 const base::Closure& bind_callback) = 0;
97 virtual void AsyncTexSubImage2D(
98 const AsyncTexSubImage2DParams& tex_params,
99 const AsyncMemoryParams& mem_params) = 0;
101 // Returns true if there is a transfer in progress.
102 virtual bool TransferIsInProgress() = 0;
104 // Block until the specified transfer completes.
105 virtual void WaitForTransferCompletion() = 0;
107 protected:
108 AsyncPixelTransferDelegate();
110 private:
111 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegate);
114 } // namespace gpu
116 #endif // GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_DELEGATE_H_