1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file.
4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#ifndef GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_IDLE_H_
6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_IDLE_H_
7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include <list>
9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace gpu {
13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class AsyncPixelTransferManagerIdle : public AsyncPixelTransferManager {
15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public:
16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  AsyncPixelTransferManagerIdle();
17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  virtual ~AsyncPixelTransferManagerIdle();
18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // AsyncPixelTransferManager implementation:
20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  virtual void BindCompletedAsyncTransfers() OVERRIDE;
21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  virtual void AsyncNotifyCompletion(
22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      const AsyncMemoryParams& mem_params,
23eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      AsyncPixelTransferCompletionObserver* observer) OVERRIDE;
24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  virtual uint32 GetTextureUploadCount() OVERRIDE;
25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  virtual void ProcessMorePendingTransfers() OVERRIDE;
27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
284ad1aa43a48567659193a298fad74f55e00b3dd9Ben Murdoch  virtual void WaitAllAsyncTexImage2D() OVERRIDE;
29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  struct Task {
314ad1aa43a48567659193a298fad74f55e00b3dd9Ben Murdoch    Task(uint64 transfer_id,
324ad1aa43a48567659193a298fad74f55e00b3dd9Ben Murdoch         AsyncPixelTransferDelegate* delegate,
334ad1aa43a48567659193a298fad74f55e00b3dd9Ben Murdoch         const base::Closure& task);
34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ~Task();
35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    // This is non-zero if pixel transfer task.
37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    uint64 transfer_id;
38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
394ad1aa43a48567659193a298fad74f55e00b3dd9Ben Murdoch    AsyncPixelTransferDelegate* delegate;
404ad1aa43a48567659193a298fad74f55e00b3dd9Ben Murdoch
41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    base::Closure task;
42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  };
43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // State shared between Managers and Delegates.
45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  struct SharedState {
46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    SharedState();
47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ~SharedState();
48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    void ProcessNotificationTasks();
49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    int texture_upload_count;
51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    base::TimeDelta total_texture_upload_time;
52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    std::list<Task> tasks;
53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  };
54868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private:
567d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // AsyncPixelTransferManager implementation:
577d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  virtual AsyncPixelTransferDelegate* CreatePixelTransferDelegateImpl(
587d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)      gles2::TextureRef* ref,
597d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)      const AsyncTexImage2DParams& define_params) OVERRIDE;
607d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
61868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  SharedState shared_state_;
62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferManagerIdle);
64868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)};
65868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
66868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}  // namespace gpu
67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif  // GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_IDLE_H_
69