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

Side by Side Diff: gpu/command_buffer/service/texture_definition.h

Issue 180723023: gpu: Mailbox emulation with EGLImage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops Created 6 years, 9 months 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014 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 GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_
7
8 #include <list>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/memory/linked_ptr.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/synchronization/lock.h"
16 #include "gpu/command_buffer/service/gl_utils.h"
17 #include "ui/gl/gl_fence.h"
18
19 namespace gfx {
20 class GLFence;
21 class GLImage;
22 }
23
24 namespace gpu {
25 namespace gles2 {
26
27 class Texture;
28
29 class NativeImageBuffer : public base::RefCountedThreadSafe<NativeImageBuffer> {
30 public:
31 static NativeImageBuffer* Create(GLuint texture_id);
32 virtual void BindToTexture(GLenum target) = 0;
33
34 void AddClient(gfx::GLImage* client);
35 void RemoveClient(gfx::GLImage* client);
36 bool IsClient(gfx::GLImage* client);
37
38 void WillRead(gfx::GLImage* client);
39 void WillWrite(gfx::GLImage* client);
40 void DidRead(gfx::GLImage* client);
41 void DidWrite(gfx::GLImage* client);
42
43 protected:
44 friend class base::RefCountedThreadSafe<NativeImageBuffer>;
45 NativeImageBuffer();
46 virtual ~NativeImageBuffer();
47
48 base::Lock lock_;
49
50 struct ClientInfo {
51 ClientInfo(gfx::GLImage* client);
52 ~ClientInfo();
53
54 gfx::GLImage* client;
55 bool needs_wait_before_read;
56 linked_ptr<gfx::GLFence> read_fence;
57 };
58 std::list<ClientInfo> client_infos_;
59 scoped_ptr<gfx::GLFence> write_fence_;
60 gfx::GLImage* write_client_;
61
62 DISALLOW_COPY_AND_ASSIGN(NativeImageBuffer);
63 };
64
65 // An immutable description that can be used to create a texture that shares
66 // the underlying image buffer(s).
67 class TextureDefinition {
68 public:
69 TextureDefinition(GLenum target,
70 Texture* texture,
71 unsigned int version,
72 NativeImageBuffer* image);
73 virtual ~TextureDefinition();
74
75 Texture* CreateTexture() const;
76 void UpdateTexture(Texture* texture) const;
77
78 unsigned int version() const { return version_; }
79 bool IsNewerThan(unsigned int version) const {
80 return (int)(version_ - version) > 0;
piman 2014/03/13 04:41:58 int overflow = undefined. I'm afraid the compiler
no sievers 2014/03/13 20:50:15 Done. Inverted, since you pointed out that 'equal'
piman 2014/03/13 23:29:06 Why can't we skip for Pull?
81 }
82 bool Matches(const Texture* texture) const;
83
84 scoped_refptr<NativeImageBuffer> image() { return image_; }
85
86 private:
87 struct LevelInfo {
88 LevelInfo(GLenum target,
89 GLenum internal_format,
90 GLsizei width,
91 GLsizei height,
92 GLsizei depth,
93 GLint border,
94 GLenum format,
95 GLenum type,
96 bool cleared);
97 ~LevelInfo();
98
99 GLenum target;
100 GLenum internal_format;
101 GLsizei width;
102 GLsizei height;
103 GLsizei depth;
104 GLint border;
105 GLenum format;
106 GLenum type;
107 bool cleared;
108 };
109
110 typedef std::vector<std::vector<LevelInfo> > LevelInfos;
111
112 unsigned int version_;
113 GLenum target_;
114 scoped_refptr<NativeImageBuffer> image_;
piman 2014/03/13 04:41:58 nit: image_buffer_ maybe? The callsites are confus
no sievers 2014/03/13 20:50:15 Done.
115 GLenum min_filter_;
116 GLenum mag_filter_;
117 GLenum wrap_s_;
118 GLenum wrap_t_;
119 GLenum usage_;
120 bool immutable_;
121 LevelInfos level_infos_;
122 };
123
124 } // namespage gles2
125 } // namespace gpu
126
127 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698