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

Side by Side Diff: ui/gl/async_pixel_transfer_delegate.h

Issue 11428140: gpu: Add async pixel transfer interface, stub and tests. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix bots. Created 8 years 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #ifndef UI_GL_ASYNC_TASK_DELEGATE_H_
6 #define UI_GL_ASYNC_TASK_DELEGATE_H_
7
8 #include "base/basictypes.h"
9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "build/build_config.h"
13 #include "ui/gl/gl_bindings.h"
14 #include "ui/gl/gl_export.h"
15
16 namespace base {
17 class SharedMemory;
18 }
19
20 namespace gfx {
21
22 struct AsyncTexImage2DParams {
23 GLenum target;
24 GLint level;
25 GLenum internal_format;
26 GLsizei width;
27 GLsizei height;
28 GLint border;
29 GLenum format;
30 GLenum type;
31 };
32
33 struct AsyncTexSubImage2DParams {
34 GLenum target;
35 GLint level;
36 GLint xoffset;
37 GLint yoffset;
38 GLsizei width;
39 GLsizei height;
40 GLenum format;
41 GLenum type;
42 };
43
44 struct AsyncMemoryParams {
45 base::SharedMemory* shared_memory;
46 uint32 shm_size;
47 uint32 shm_data_offset;
48 uint32 shm_data_size;
49 };
50
51 // AsyncPixelTransferState holds the resources required to do async
52 // transfers on one texture. It should stay alive for the lifetime
53 // of the texture to allow multiple transfers.
54 class GL_EXPORT AsyncPixelTransferState :
55 public base::SupportsWeakPtr<AsyncPixelTransferState> {
56 public:
57 virtual ~AsyncPixelTransferState() {}
58
59 // Returns true if there is a transfer in progress.
60 virtual bool TransferIsInProgress() = 0;
61
62 // Perform any custom binding of the transfer (currently only
63 // needed for AsyncTexImage2D). The params used to define the texture
64 // are returned in level_params.
65 //
66 // The transfer must be complete to call this (!TransferIsInProgress).
67 virtual void BindTransfer(AsyncTexImage2DParams* level_params) = 0;
68
69 protected:
70 friend class base::RefCounted<AsyncPixelTransferState>;
71 AsyncPixelTransferState() {}
72
73
74 private:
75 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferState);
76 };
77
78 class GL_EXPORT AsyncPixelTransferDelegate {
79 public:
80 static scoped_ptr<AsyncPixelTransferDelegate>
81 Create(gfx::GLContext* context);
82 virtual ~AsyncPixelTransferDelegate() {}
83
84 virtual scoped_ptr<AsyncPixelTransferState>
85 CreatePixelTransferState(GLuint texture) = 0;
86
87 virtual void AsyncNotifyCompletion(
88 const base::Closure& notify_task) = 0;
89
90 virtual void AsyncTexImage2D(
91 AsyncPixelTransferState* state,
92 const AsyncTexImage2DParams& tex_params,
93 const AsyncMemoryParams& mem_params) = 0;
94
95 virtual void AsyncTexSubImage2D(
96 AsyncPixelTransferState* state,
97 const AsyncTexSubImage2DParams& tex_params,
98 const AsyncMemoryParams& mem_params) = 0;
99
100 protected:
101 AsyncPixelTransferDelegate() {}
102 // For testing, as returning scoped_ptr wouldn't work with MOCK_METHOD.
103 virtual AsyncPixelTransferState*
104 CreateRawPixelTransferState(GLuint texture_id) = 0;
105
106 private:
107 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegate);
108 };
109
110 } // namespace gfx
111
112 #endif // UI_GL_ASYNC_TASK_DELEGATE_H_
113
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698