diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-16 23:03:47 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-16 23:03:47 +0000 |
commit | a93bb846c70d2491171bd7211d24f6f0fa56e853 (patch) | |
tree | 8cb20ea75cf5f9a175d756d0605ddaa302f6d751 /gpu/command_buffer/service/shader_manager.h | |
parent | 024d468c601e94f26717c1ddc68f68cfcdf4c23c (diff) | |
download | chromium_src-a93bb846c70d2491171bd7211d24f6f0fa56e853.zip chromium_src-a93bb846c70d2491171bd7211d24f6f0fa56e853.tar.gz chromium_src-a93bb846c70d2491171bd7211d24f6f0fa56e853.tar.bz2 |
Adds texture tracking.
I need to add a bunch more unit tests for the TextureManager
but this CL is getting large so if you don't mind I'll
do that in the next CL.
I still need to use the texture tracking at draw time but
that's going to require uniform tracking! UGH!
Also breaks out a bunch of the tracking classes into their own files.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/605018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39153 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service/shader_manager.h')
-rw-r--r-- | gpu/command_buffer/service/shader_manager.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/gpu/command_buffer/service/shader_manager.h b/gpu/command_buffer/service/shader_manager.h new file mode 100644 index 0000000..833117b --- /dev/null +++ b/gpu/command_buffer/service/shader_manager.h @@ -0,0 +1,72 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ +#define GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ + +#include <map> +#include <string> +#include "base/basictypes.h" +#include "gpu/command_buffer/service/gl_utils.h" + +namespace gpu { +namespace gles2 { + +// Tracks the Shaders. +// +// NOTE: To support shared resources an instance of this class will +// need to be shared by multiple GLES2Decoders. +class ShaderManager { + public: + // This is used to keep the source code for a shader. This is because in order + // to emluate GLES2 the shaders will have to be re-written before passed to + // the underlying OpenGL. But, when the user calls glGetShaderSource they + // should get the source they passed in, not the re-written source. + class ShaderInfo { + public: + explicit ShaderInfo(GLuint shader) + : shader_(shader) { + } + + void Update(const std::string& source) { + source_ = source; + } + + const std::string& source() { + return source_; + } + + private: + // The shader this ShaderInfo is tracking. + GLuint shader_; + + // The shader source as passed to glShaderSource. + std::string source_; + }; + + ShaderManager() { }; + + // Creates a shader info for the given shader ID. + void CreateShaderInfo(GLuint shader); + + // Gets an existing shader info for the given shader ID. Returns NULL if none + // exists. + ShaderInfo* GetShaderInfo(GLuint shader); + + // Deletes the shader info for the given shader. + void RemoveShaderInfo(GLuint shader); + + private: + // Info for each shader by service side shader Id. + typedef std::map<GLuint, ShaderInfo> ShaderInfoMap; + ShaderInfoMap shader_infos_; + + DISALLOW_COPY_AND_ASSIGN(ShaderManager); +}; + +} // namespace gles2 +} // namespace gpu + +#endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ + |