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

Side by Side Diff: gpu/command_buffer/service/async_pixel_transfer_manager.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
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 #ifndef GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/linked_ptr.h"
14 #include "gpu/command_buffer/service/texture_manager.h" 14 #include "gpu/command_buffer/service/texture_manager.h"
15 #include "gpu/gpu_export.h" 15 #include "gpu/gpu_export.h"
16 16
17 #if defined(COMPILER_GCC) 17 #if defined(COMPILER_GCC)
18 namespace BASE_HASH_NAMESPACE { 18 namespace BASE_HASH_NAMESPACE {
19 template <> 19 template <>
20 struct hash<gpu::gles2::TextureRef*> { 20 struct hash<gpu::gles2::TextureRef*> {
21 size_t operator()(gpu::gles2::TextureRef* ptr) const { 21 size_t operator()(gpu::gles2::TextureRef* ptr) const {
22 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); 22 return hash<size_t>()(reinterpret_cast<size_t>(ptr));
23 } 23 }
24 }; 24 };
25 } // namespace BASE_HASH_NAMESPACE 25 } // namespace BASE_HASH_NAMESPACE
26 #endif // COMPILER 26 #endif // COMPILER
27 27
28 namespace gfx { 28 namespace gfx {
29 class GLContext; 29 class GLContext;
30 } 30 }
31 31
32 namespace gpu { 32 namespace gpu {
33 class AsyncPixelTransferDelegate; 33 class AsyncPixelTransferDelegate;
34 class AsyncPixelTransferState;
35 struct AsyncMemoryParams; 34 struct AsyncMemoryParams;
36 struct AsyncTexImage2DParams; 35 struct AsyncTexImage2DParams;
37 36
38 class GPU_EXPORT AsyncPixelTransferManager 37 class GPU_EXPORT AsyncPixelTransferManager
39 : public gles2::TextureManager::DestructionObserver { 38 : public gles2::TextureManager::DestructionObserver {
40 public: 39 public:
41 typedef base::Callback<void(const AsyncMemoryParams&)> CompletionCallback; 40 typedef base::Callback<void(const AsyncMemoryParams&)> CompletionCallback;
42 41
43 static AsyncPixelTransferManager* Create(gfx::GLContext* context); 42 static AsyncPixelTransferManager* Create(gfx::GLContext* context);
44 43
(...skipping 12 matching lines...) Expand all
57 virtual base::TimeDelta GetTotalTextureUploadTime() = 0; 56 virtual base::TimeDelta GetTotalTextureUploadTime() = 0;
58 57
59 // ProcessMorePendingTransfers() will be called at a good time 58 // ProcessMorePendingTransfers() will be called at a good time
60 // to process a small amount of pending transfer work while 59 // to process a small amount of pending transfer work while
61 // NeedsProcessMorePendingTransfers() returns true. Implementations 60 // NeedsProcessMorePendingTransfers() returns true. Implementations
62 // that can't dispatch work to separate threads should use 61 // that can't dispatch work to separate threads should use
63 // this to avoid blocking the caller thread inappropriately. 62 // this to avoid blocking the caller thread inappropriately.
64 virtual void ProcessMorePendingTransfers() = 0; 63 virtual void ProcessMorePendingTransfers() = 0;
65 virtual bool NeedsProcessMorePendingTransfers() = 0; 64 virtual bool NeedsProcessMorePendingTransfers() = 0;
66 65
67 virtual AsyncPixelTransferDelegate* GetAsyncPixelTransferDelegate() = 0; 66 AsyncPixelTransferDelegate* CreatePixelTransferDelegate(
68
69 AsyncPixelTransferState* CreatePixelTransferState(
70 gles2::TextureRef* ref, 67 gles2::TextureRef* ref,
71 const AsyncTexImage2DParams& define_params); 68 const AsyncTexImage2DParams& define_params);
72 69
73 AsyncPixelTransferState* GetPixelTransferState( 70 AsyncPixelTransferDelegate* GetPixelTransferDelegate(
74 gles2::TextureRef* ref); 71 gles2::TextureRef* ref);
75 72
76 void ClearPixelTransferStateForTest(gles2::TextureRef* ref); 73 void ClearPixelTransferDelegateForTest(gles2::TextureRef* ref);
77 74
78 bool AsyncTransferIsInProgress(gles2::TextureRef* ref); 75 bool AsyncTransferIsInProgress(gles2::TextureRef* ref);
79 76
80 // gles2::TextureRef::DestructionObserver implementation: 77 // gles2::TextureRef::DestructionObserver implementation:
81 virtual void OnTextureManagerDestroying(gles2::TextureManager* manager) 78 virtual void OnTextureManagerDestroying(gles2::TextureManager* manager)
82 OVERRIDE; 79 OVERRIDE;
83 virtual void OnTextureRefDestroying(gles2::TextureRef* texture) OVERRIDE; 80 virtual void OnTextureRefDestroying(gles2::TextureRef* texture) OVERRIDE;
84 81
85 protected: 82 protected:
86 AsyncPixelTransferManager(); 83 AsyncPixelTransferManager();
87 84
88 private: 85 private:
89 gles2::TextureManager* manager_; 86 gles2::TextureManager* manager_;
90 87
91 typedef base::hash_map<gles2::TextureRef*, 88 typedef base::hash_map<gles2::TextureRef*,
92 scoped_refptr<AsyncPixelTransferState> > 89 linked_ptr<AsyncPixelTransferDelegate> >
93 TextureToStateMap; 90 TextureToDelegateMap;
94 TextureToStateMap state_map_; 91 TextureToDelegateMap delegate_map_;
92
93 // A factory method called by CreatePixelTransferDelegate that is overriden
94 // by each implementation.
95 virtual AsyncPixelTransferDelegate* CreatePixelTransferDelegateImpl(
96 gles2::TextureRef* ref,
97 const AsyncTexImage2DParams& define_params) = 0;
95 98
96 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferManager); 99 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferManager);
97 }; 100 };
98 101
99 } // namespace gpu 102 } // namespace gpu
100 103
101 #endif // GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_H_ 104 #endif // GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698