• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 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_CLIENT_GLES2_CMD_HELPER_H_
6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_H_
7 
8 #include "gpu/command_buffer/client/cmd_buffer_helper.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/gpu_export.h"
11 
12 namespace gpu {
13 namespace gles2 {
14 
15 // A class that helps write GL command buffers.
16 class GPU_EXPORT GLES2CmdHelper : public CommandBufferHelper {
17  public:
18   explicit GLES2CmdHelper(CommandBuffer* command_buffer);
19   virtual ~GLES2CmdHelper();
20 
21   // Include the auto-generated part of this class. We split this because it
22   // means we can easily edit the non-auto generated parts right here in this
23   // file instead of having to edit some template or the code generator.
24   #include "gpu/command_buffer/client/gles2_cmd_helper_autogen.h"
25 
26   // Helpers that could not be auto-generated.
27   // TODO(gman): Auto generate these.
GetAttribLocation(GLuint program,uint32 name_bucket_id,uint32 location_shm_id,uint32 location_shm_offset)28   void GetAttribLocation(
29       GLuint program, uint32 name_bucket_id,
30       uint32 location_shm_id, uint32 location_shm_offset) {
31     gles2::cmds::GetAttribLocation* c =
32         GetCmdSpace<gles2::cmds::GetAttribLocation>();
33     if (c) {
34       c->Init(program, name_bucket_id, location_shm_id, location_shm_offset);
35     }
36   }
37 
GetUniformLocation(GLuint program,uint32 name_bucket_id,uint32 location_shm_id,uint32 location_shm_offset)38   void GetUniformLocation(
39       GLuint program, uint32 name_bucket_id,
40       uint32 location_shm_id, uint32 location_shm_offset) {
41     gles2::cmds::GetUniformLocation* c =
42         GetCmdSpace<gles2::cmds::GetUniformLocation>();
43     if (c) {
44       c->Init(program, name_bucket_id, location_shm_id, location_shm_offset);
45     }
46   }
47 
CreateAndConsumeTextureCHROMIUMImmediate(GLenum target,uint32_t client_id,const GLbyte * _mailbox)48   void CreateAndConsumeTextureCHROMIUMImmediate(GLenum target,
49                                                 uint32_t client_id,
50                                                 const GLbyte* _mailbox) {
51     const uint32_t size =
52         gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate::ComputeSize();
53     gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate* c =
54         GetImmediateCmdSpaceTotalSize<
55             gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate>(size);
56     if (c) {
57       c->Init(target, client_id, _mailbox);
58     }
59   }
60 
61  private:
62   DISALLOW_COPY_AND_ASSIGN(GLES2CmdHelper);
63 };
64 
65 }  // namespace gles2
66 }  // namespace gpu
67 
68 #endif  // GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_H_
69 
70