Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / gpu / command_buffer / service / texture_definition.h
blobe5311846295239523be71a7b803a4776e24597a6
1 // Copyright 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.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_
8 #include <vector>
10 #include "base/memory/ref_counted.h"
11 #include "gpu/command_buffer/service/gl_utils.h"
13 namespace gfx {
14 class GLImage;
17 namespace gpu {
18 namespace gles2 {
20 class Texture;
22 class NativeImageBuffer : public base::RefCountedThreadSafe<NativeImageBuffer> {
23 public:
24 static scoped_refptr<NativeImageBuffer> Create(GLuint texture_id);
26 virtual void AddClient(gfx::GLImage* client) = 0;
27 virtual void RemoveClient(gfx::GLImage* client) = 0;
28 virtual bool IsClient(gfx::GLImage* client) = 0;
29 virtual void BindToTexture(GLenum target) const = 0;
31 protected:
32 friend class base::RefCountedThreadSafe<NativeImageBuffer>;
33 NativeImageBuffer() {}
34 virtual ~NativeImageBuffer() {}
36 DISALLOW_COPY_AND_ASSIGN(NativeImageBuffer);
39 class ScopedUpdateTexture {
40 public:
41 ScopedUpdateTexture();
42 ~ScopedUpdateTexture();
44 private:
45 DISALLOW_COPY_AND_ASSIGN(ScopedUpdateTexture);
48 // An immutable description that can be used to create a texture that shares
49 // the underlying image buffer(s).
50 class TextureDefinition {
51 public:
52 static void AvoidEGLTargetTextureReuse();
54 TextureDefinition();
55 TextureDefinition(Texture* texture,
56 unsigned int version,
57 const scoped_refptr<NativeImageBuffer>& image);
58 virtual ~TextureDefinition();
60 Texture* CreateTexture() const;
62 // Must be wrapped with ScopedUpdateTexture.
63 void UpdateTexture(Texture* texture) const;
65 unsigned int version() const { return version_; }
66 bool IsOlderThan(unsigned int version) const {
67 return (version - version_) < 0x80000000;
69 bool Matches(const Texture* texture) const;
71 scoped_refptr<NativeImageBuffer> image() const { return image_buffer_; }
73 private:
74 bool SafeToRenderFrom() const;
75 void UpdateTextureInternal(Texture* texture) const;
77 struct LevelInfo {
78 LevelInfo();
79 LevelInfo(GLenum target,
80 GLenum internal_format,
81 GLsizei width,
82 GLsizei height,
83 GLsizei depth,
84 GLint border,
85 GLenum format,
86 GLenum type,
87 bool cleared);
88 ~LevelInfo();
90 GLenum target;
91 GLenum internal_format;
92 GLsizei width;
93 GLsizei height;
94 GLsizei depth;
95 GLint border;
96 GLenum format;
97 GLenum type;
98 bool cleared;
101 unsigned int version_;
102 GLenum target_;
103 scoped_refptr<NativeImageBuffer> image_buffer_;
104 GLenum min_filter_;
105 GLenum mag_filter_;
106 GLenum wrap_s_;
107 GLenum wrap_t_;
108 GLenum usage_;
109 bool immutable_;
110 bool defined_;
112 // Only support textures with one face and one level.
113 LevelInfo level_info_;
116 } // namespage gles2
117 } // namespace gpu
119 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_