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

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 Asan bot. 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/ref_counted.h"
11 #include "base/memory/scoped_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::RefCounted<AsyncPixelTransferState> {
56 public:
57 // Returns true if there is a transfer in progress.
58 virtual bool TransferIsInProgress() = 0;
59
60 // Perform any custom binding of the transfer, if needed. If true is
61 // returned, level_params is set to the params used to define the texture
62 // (via AsyncTexImage2D), and the level is now defined with those params
63 // and contains fully valid data.
64 virtual bool BindTransfer(
65 GLenum target, AsyncTexImage2DParams* level_params) = 0;
66
67 protected:
68 friend class base::RefCounted<AsyncPixelTransferState>;
69 AsyncPixelTransferState() {}
70 virtual ~AsyncPixelTransferState() {}
71
72 private:
73 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferState);
74 };
75
76 class GL_EXPORT AsyncPixelTransferDelegate {
77 public:
78 static scoped_ptr<AsyncPixelTransferDelegate>
79 Create(gfx::GLContext* context);
80 virtual ~AsyncPixelTransferDelegate() {}
81
82 virtual scoped_refptr<AsyncPixelTransferState>
83 CreatePixelTransferState(GLuint texture) = 0;
84
85 virtual void AsyncNotifyCompletion(
86 const base::Closure& notify_task) = 0;
87
88 virtual void AsyncTexImage2D(
89 AsyncPixelTransferState* state,
90 const AsyncTexImage2DParams& tex_params,
91 const AsyncMemoryParams& mem_params) = 0;
92
93 virtual void AsyncTexSubImage2D(
94 AsyncPixelTransferState* state,
95 const AsyncTexSubImage2DParams& tex_params,
96 const AsyncMemoryParams& mem_params) = 0;
97
98 protected:
99 AsyncPixelTransferDelegate() {}
100
101 private:
102 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegate);
103 };
104
105 } // namespace gfx
106
107 #endif // UI_GL_ASYNC_TASK_DELEGATE_H_
108
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698