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

Side by Side Diff: gpu/command_buffer/service/async_pixel_transfer_delegate.h

Issue 16175005: GPU: Replace AsyncPixelTransferState with AsyncPixelTransferDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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
« no previous file with comments | « no previous file | gpu/command_buffer/service/async_pixel_transfer_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_DELEGATE_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_DELEGATE_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_DELEGATE_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_DELEGATE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
14 #include "base/time.h" 13 #include "base/time.h"
15 #include "gpu/gpu_export.h" 14 #include "gpu/gpu_export.h"
16 #include "ui/gl/gl_bindings.h" 15 #include "ui/gl/gl_bindings.h"
17 16
18 namespace base { 17 namespace base {
19 class SharedMemory; 18 class SharedMemory;
20 } 19 }
21 20
22 namespace gpu { 21 namespace gpu {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 64
66 ~AsyncPixelTransferUploadStats(); 65 ~AsyncPixelTransferUploadStats();
67 66
68 int texture_upload_count_; 67 int texture_upload_count_;
69 base::TimeDelta total_texture_upload_time_; 68 base::TimeDelta total_texture_upload_time_;
70 base::Lock lock_; 69 base::Lock lock_;
71 70
72 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferUploadStats); 71 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferUploadStats);
73 }; 72 };
74 73
75 // AsyncPixelTransferState holds the resources required to do async
76 // transfers on one texture. It should stay alive for the lifetime
77 // of the texture to allow multiple transfers.
78 class GPU_EXPORT AsyncPixelTransferState
79 : public base::RefCounted<AsyncPixelTransferState>,
80 public base::SupportsWeakPtr<AsyncPixelTransferState> {
81 public:
82 // Returns true if there is a transfer in progress.
83 virtual bool TransferIsInProgress() = 0;
84
85 protected:
86 AsyncPixelTransferState();
87 virtual ~AsyncPixelTransferState();
88
89 private:
90 friend class base::RefCounted<AsyncPixelTransferState>;
91
92 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferState);
93 };
94
95 class GPU_EXPORT AsyncPixelTransferDelegate { 74 class GPU_EXPORT AsyncPixelTransferDelegate {
96 public: 75 public:
97 virtual ~AsyncPixelTransferDelegate(); 76 virtual ~AsyncPixelTransferDelegate();
98 77
99 virtual AsyncPixelTransferState* CreatePixelTransferState(
100 GLuint texture_id,
101 const AsyncTexImage2DParams& define_params) = 0;
102
103 // The callback occurs on the caller thread, once the texture is 78 // The callback occurs on the caller thread, once the texture is
104 // safe/ready to be used. 79 // safe/ready to be used.
105 virtual void AsyncTexImage2D( 80 virtual void AsyncTexImage2D(
106 AsyncPixelTransferState* state,
107 const AsyncTexImage2DParams& tex_params, 81 const AsyncTexImage2DParams& tex_params,
108 const AsyncMemoryParams& mem_params, 82 const AsyncMemoryParams& mem_params,
109 const base::Closure& bind_callback) = 0; 83 const base::Closure& bind_callback) = 0;
110 84
111 virtual void AsyncTexSubImage2D( 85 virtual void AsyncTexSubImage2D(
112 AsyncPixelTransferState* state,
113 const AsyncTexSubImage2DParams& tex_params, 86 const AsyncTexSubImage2DParams& tex_params,
114 const AsyncMemoryParams& mem_params) = 0; 87 const AsyncMemoryParams& mem_params) = 0;
115 88
89 // Returns true if there is a transfer in progress.
90 virtual bool TransferIsInProgress() = 0;
91
116 // Block until the specified transfer completes. 92 // Block until the specified transfer completes.
117 virtual void WaitForTransferCompletion( 93 virtual void WaitForTransferCompletion() = 0;
118 AsyncPixelTransferState* state) = 0;
119 94
120 // Gets the address of the data from shared memory. 95 // Gets the address of the data from shared memory.
121 static void* GetAddress(const AsyncMemoryParams& mem_params); 96 static void* GetAddress(const AsyncMemoryParams& mem_params);
122 97
123 // Sometimes the |safe_shared_memory| is duplicate to prevent use after free. 98 // Sometimes the |safe_shared_memory| is duplicate to prevent use after free.
124 static void* GetAddress(ScopedSafeSharedMemory* safe_shared_memory, 99 static void* GetAddress(ScopedSafeSharedMemory* safe_shared_memory,
125 const AsyncMemoryParams& mem_params); 100 const AsyncMemoryParams& mem_params);
126 101
127 protected: 102 protected:
128 AsyncPixelTransferDelegate(); 103 AsyncPixelTransferDelegate();
129 104
130 private: 105 private:
131 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegate); 106 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegate);
132 }; 107 };
133 108
134 } // namespace gpu 109 } // namespace gpu
135 110
136 #endif // GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_DELEGATE_H_ 111 #endif // GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_DELEGATE_H_
137 112
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/async_pixel_transfer_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698