Don't add an aura tooltip to bubble close buttons on Windows.
[chromium-blink-merge.git] / gpu / command_buffer / service / async_pixel_transfer_manager.h
blob3f52e1ec3a23256accb64f3dba2adcf0b7fab7f0
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 #ifndef GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_H_
8 #include <set>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/containers/hash_tables.h"
13 #include "base/memory/linked_ptr.h"
14 #include "base/memory/ref_counted.h"
15 #include "gpu/command_buffer/service/texture_manager.h"
16 #include "gpu/gpu_export.h"
18 namespace gfx {
19 class GLContext;
22 namespace gpu {
23 class AsyncPixelTransferDelegate;
24 class AsyncMemoryParams;
25 struct AsyncTexImage2DParams;
27 class AsyncPixelTransferCompletionObserver
28 : public base::RefCountedThreadSafe<AsyncPixelTransferCompletionObserver> {
29 public:
30 AsyncPixelTransferCompletionObserver();
32 virtual void DidComplete(const AsyncMemoryParams& mem_params) = 0;
34 protected:
35 virtual ~AsyncPixelTransferCompletionObserver();
37 private:
38 friend class base::RefCountedThreadSafe<AsyncPixelTransferCompletionObserver>;
40 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferCompletionObserver);
43 class GPU_EXPORT AsyncPixelTransferManager
44 : public gles2::TextureManager::DestructionObserver {
45 public:
46 static AsyncPixelTransferManager* Create(gfx::GLContext* context);
48 ~AsyncPixelTransferManager() override;
50 void Initialize(gles2::TextureManager* texture_manager);
52 virtual void BindCompletedAsyncTransfers() = 0;
54 // There's no guarantee that callback will run on the caller thread.
55 virtual void AsyncNotifyCompletion(
56 const AsyncMemoryParams& mem_params,
57 AsyncPixelTransferCompletionObserver* observer) = 0;
59 virtual uint32 GetTextureUploadCount() = 0;
60 virtual base::TimeDelta GetTotalTextureUploadTime() = 0;
62 // ProcessMorePendingTransfers() will be called at a good time
63 // to process a small amount of pending transfer work while
64 // NeedsProcessMorePendingTransfers() returns true. Implementations
65 // that can't dispatch work to separate threads should use
66 // this to avoid blocking the caller thread inappropriately.
67 virtual void ProcessMorePendingTransfers() = 0;
68 virtual bool NeedsProcessMorePendingTransfers() = 0;
70 // Wait for all AsyncTex(Sub)Image2D uploads to finish before returning.
71 virtual void WaitAllAsyncTexImage2D() = 0;
73 AsyncPixelTransferDelegate* CreatePixelTransferDelegate(
74 gles2::TextureRef* ref,
75 const AsyncTexImage2DParams& define_params);
77 AsyncPixelTransferDelegate* GetPixelTransferDelegate(
78 gles2::TextureRef* ref);
80 void ClearPixelTransferDelegateForTest(gles2::TextureRef* ref);
82 bool AsyncTransferIsInProgress(gles2::TextureRef* ref);
84 // gles2::TextureRef::DestructionObserver implementation:
85 void OnTextureManagerDestroying(gles2::TextureManager* manager) override;
86 void OnTextureRefDestroying(gles2::TextureRef* texture) override;
88 protected:
89 AsyncPixelTransferManager();
91 private:
92 gles2::TextureManager* manager_;
94 typedef base::hash_map<gles2::TextureRef*,
95 linked_ptr<AsyncPixelTransferDelegate> >
96 TextureToDelegateMap;
97 TextureToDelegateMap delegate_map_;
99 // A factory method called by CreatePixelTransferDelegate that is overriden
100 // by each implementation.
101 virtual AsyncPixelTransferDelegate* CreatePixelTransferDelegateImpl(
102 gles2::TextureRef* ref,
103 const AsyncTexImage2DParams& define_params) = 0;
105 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferManager);
108 } // namespace gpu
110 #endif // GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_H_