summaryrefslogtreecommitdiffstats
path: root/ui/gl/async_pixel_transfer_delegate_stub.h
blob: cf95a98583276662daca1a91938d4671427f24e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_GL_ASYNC_TASK_DELEGATE_STUB_H_
#define UI_GL_ASYNC_TASK_DELEGATE_STUB_H_

#include "ui/gl/async_pixel_transfer_delegate.h"

namespace gfx {

class AsyncTransferStateStub : public AsyncPixelTransferState {
 public:
  // implement AsyncPixelTransferState:
  virtual bool TransferIsInProgress() OVERRIDE;
  virtual void BindTransfer(AsyncTexImage2DParams* bound_params) OVERRIDE;

 private:
  friend class AsyncPixelTransferDelegateStub;
  bool needs_late_bind_;
  AsyncTexImage2DParams late_bind_define_params_ ;

  explicit AsyncTransferStateStub(GLuint texture_id);
  virtual ~AsyncTransferStateStub();
  DISALLOW_COPY_AND_ASSIGN(AsyncTransferStateStub);
};

// Class which handles async pixel transfers (as a fallback).
// This class just does the uploads synchronously.
class AsyncPixelTransferDelegateStub : public AsyncPixelTransferDelegate {
 public:
  static scoped_ptr<AsyncPixelTransferDelegate>
      Create(gfx::GLContext* context);

  AsyncPixelTransferDelegateStub();
  virtual ~AsyncPixelTransferDelegateStub();

  // implement AsyncPixelTransferDelegate:
  virtual void AsyncNotifyCompletion(
      const AsyncMemoryParams& mem_params,
      const CompletionCallback& callback) OVERRIDE;
  virtual void AsyncTexImage2D(
      AsyncPixelTransferState* transfer_state,
      const AsyncTexImage2DParams& tex_params,
      const AsyncMemoryParams& mem_params) OVERRIDE;
  virtual void AsyncTexSubImage2D(
      AsyncPixelTransferState* transfer_state,
      const AsyncTexSubImage2DParams& tex_params,
      const AsyncMemoryParams& mem_params) OVERRIDE;
  virtual uint32 GetTextureUploadCount() OVERRIDE;
  virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
 private:
  // implement AsyncPixelTransferDelegate:
  virtual AsyncPixelTransferState*
      CreateRawPixelTransferState(GLuint texture_id) OVERRIDE;

  int texture_upload_count_;
  base::TimeDelta total_texture_upload_time_;

  DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateStub);
};

}  // namespace gfx

#endif  // UI_GL_ASYNC_TASK_DELEGATE_ANDROID_H_