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

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: Address Feedback. 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
« no previous file with comments | « gpu/gpu.gyp ('k') | ui/gl/async_pixel_transfer_delegate_stub.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This wouldn't work with MOCK_METHOD, so it routes through
85 // a virtual protected version which returns a raw pointer.
86 scoped_ptr<AsyncPixelTransferState>
87 CreatePixelTransferState(GLuint texture_id) {
88 return make_scoped_ptr(CreateRawPixelTransferState(texture_id));
89 }
90
91 virtual void AsyncNotifyCompletion(
92 const base::Closure& notify_task) = 0;
93
94 virtual void AsyncTexImage2D(
95 AsyncPixelTransferState* state,
96 const AsyncTexImage2DParams& tex_params,
97 const AsyncMemoryParams& mem_params) = 0;
98
99 virtual void AsyncTexSubImage2D(
100 AsyncPixelTransferState* state,
101 const AsyncTexSubImage2DParams& tex_params,
102 const AsyncMemoryParams& mem_params) = 0;
103
104 protected:
105 AsyncPixelTransferDelegate() {}
106 // For testing, as returning scoped_ptr wouldn't work with MOCK_METHOD.
107 virtual AsyncPixelTransferState*
108 CreateRawPixelTransferState(GLuint texture_id) = 0;
109
110 private:
111 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegate);
112 };
113
114 } // namespace gfx
115
116 #endif // UI_GL_ASYNC_TASK_DELEGATE_H_
117
OLDNEW
« no previous file with comments | « gpu/gpu.gyp ('k') | ui/gl/async_pixel_transfer_delegate_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698