1 // Copyright 2018 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 // This file is auto-generated from
6 // gpu/command_buffer/build_raster_cmd_buffer.py
7 // It's formatted by clang-format using chromium coding style:
8 //    clang-format -i -style=chromium filename
9 // DO NOT EDIT!
10 
11 // It is included by raster_cmd_decoder.cc
12 #ifndef GPU_COMMAND_BUFFER_SERVICE_RASTER_DECODER_AUTOGEN_H_
13 #define GPU_COMMAND_BUFFER_SERVICE_RASTER_DECODER_AUTOGEN_H_
14 
HandleFinish(uint32_t immediate_data_size,const volatile void * cmd_data)15 error::Error RasterDecoderImpl::HandleFinish(uint32_t immediate_data_size,
16                                              const volatile void* cmd_data) {
17   DoFinish();
18   return error::kNoError;
19 }
20 
HandleFlush(uint32_t immediate_data_size,const volatile void * cmd_data)21 error::Error RasterDecoderImpl::HandleFlush(uint32_t immediate_data_size,
22                                             const volatile void* cmd_data) {
23   DoFlush();
24   return error::kNoError;
25 }
26 
HandleGetError(uint32_t immediate_data_size,const volatile void * cmd_data)27 error::Error RasterDecoderImpl::HandleGetError(uint32_t immediate_data_size,
28                                                const volatile void* cmd_data) {
29   const volatile raster::cmds::GetError& c =
30       *static_cast<const volatile raster::cmds::GetError*>(cmd_data);
31   typedef cmds::GetError::Result Result;
32   Result* result_dst = GetSharedMemoryAs<Result*>(
33       c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
34   if (!result_dst) {
35     return error::kOutOfBounds;
36   }
37   *result_dst = GetErrorState()->GetGLError();
38   return error::kNoError;
39 }
40 
HandleGenQueriesEXTImmediate(uint32_t immediate_data_size,const volatile void * cmd_data)41 error::Error RasterDecoderImpl::HandleGenQueriesEXTImmediate(
42     uint32_t immediate_data_size,
43     const volatile void* cmd_data) {
44   const volatile raster::cmds::GenQueriesEXTImmediate& c =
45       *static_cast<const volatile raster::cmds::GenQueriesEXTImmediate*>(
46           cmd_data);
47   GLsizei n = static_cast<GLsizei>(c.n);
48   uint32_t queries_size;
49   if (!base::CheckMul(n, sizeof(GLuint)).AssignIfValid(&queries_size)) {
50     return error::kOutOfBounds;
51   }
52   volatile GLuint* queries = gles2::GetImmediateDataAs<volatile GLuint*>(
53       c, queries_size, immediate_data_size);
54   if (queries == nullptr) {
55     return error::kOutOfBounds;
56   }
57   auto queries_copy = std::make_unique<GLuint[]>(n);
58   GLuint* queries_safe = queries_copy.get();
59   std::copy(queries, queries + n, queries_safe);
60   if (!gles2::CheckUniqueAndNonNullIds(n, queries_safe) ||
61       !GenQueriesEXTHelper(n, queries_safe)) {
62     return error::kInvalidArguments;
63   }
64   return error::kNoError;
65 }
66 
HandleDeleteQueriesEXTImmediate(uint32_t immediate_data_size,const volatile void * cmd_data)67 error::Error RasterDecoderImpl::HandleDeleteQueriesEXTImmediate(
68     uint32_t immediate_data_size,
69     const volatile void* cmd_data) {
70   const volatile raster::cmds::DeleteQueriesEXTImmediate& c =
71       *static_cast<const volatile raster::cmds::DeleteQueriesEXTImmediate*>(
72           cmd_data);
73   GLsizei n = static_cast<GLsizei>(c.n);
74   uint32_t queries_size;
75   if (!base::CheckMul(n, sizeof(GLuint)).AssignIfValid(&queries_size)) {
76     return error::kOutOfBounds;
77   }
78   volatile const GLuint* queries =
79       gles2::GetImmediateDataAs<volatile const GLuint*>(c, queries_size,
80                                                         immediate_data_size);
81   if (queries == nullptr) {
82     return error::kOutOfBounds;
83   }
84   DeleteQueriesEXTHelper(n, queries);
85   return error::kNoError;
86 }
87 
HandleLoseContextCHROMIUM(uint32_t immediate_data_size,const volatile void * cmd_data)88 error::Error RasterDecoderImpl::HandleLoseContextCHROMIUM(
89     uint32_t immediate_data_size,
90     const volatile void* cmd_data) {
91   const volatile raster::cmds::LoseContextCHROMIUM& c =
92       *static_cast<const volatile raster::cmds::LoseContextCHROMIUM*>(cmd_data);
93   GLenum current = static_cast<GLenum>(c.current);
94   GLenum other = static_cast<GLenum>(c.other);
95   if (!validators_->reset_status.IsValid(current)) {
96     LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", current,
97                                     "current");
98     return error::kNoError;
99   }
100   if (!validators_->reset_status.IsValid(other)) {
101     LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", other, "other");
102     return error::kNoError;
103   }
104   DoLoseContextCHROMIUM(current, other);
105   return error::kNoError;
106 }
107 
HandleBeginRasterCHROMIUMImmediate(uint32_t immediate_data_size,const volatile void * cmd_data)108 error::Error RasterDecoderImpl::HandleBeginRasterCHROMIUMImmediate(
109     uint32_t immediate_data_size,
110     const volatile void* cmd_data) {
111   const volatile raster::cmds::BeginRasterCHROMIUMImmediate& c =
112       *static_cast<const volatile raster::cmds::BeginRasterCHROMIUMImmediate*>(
113           cmd_data);
114   GLuint sk_color = static_cast<GLuint>(c.sk_color);
115   GLuint msaa_sample_count = static_cast<GLuint>(c.msaa_sample_count);
116   GLboolean can_use_lcd_text = static_cast<GLboolean>(c.can_use_lcd_text);
117   uint32_t mailbox_size;
118   if (!gles2::GLES2Util::ComputeDataSize<GLbyte, 16>(1, &mailbox_size)) {
119     return error::kOutOfBounds;
120   }
121   if (mailbox_size > immediate_data_size) {
122     return error::kOutOfBounds;
123   }
124   volatile const GLbyte* mailbox =
125       gles2::GetImmediateDataAs<volatile const GLbyte*>(c, mailbox_size,
126                                                         immediate_data_size);
127   if (mailbox == nullptr) {
128     return error::kOutOfBounds;
129   }
130   DoBeginRasterCHROMIUM(sk_color, msaa_sample_count, can_use_lcd_text, mailbox);
131   return error::kNoError;
132 }
133 
HandleRasterCHROMIUM(uint32_t immediate_data_size,const volatile void * cmd_data)134 error::Error RasterDecoderImpl::HandleRasterCHROMIUM(
135     uint32_t immediate_data_size,
136     const volatile void* cmd_data) {
137   const volatile raster::cmds::RasterCHROMIUM& c =
138       *static_cast<const volatile raster::cmds::RasterCHROMIUM*>(cmd_data);
139   if (!features().chromium_raster_transport) {
140     return error::kUnknownCommand;
141   }
142 
143   GLuint raster_shm_id = static_cast<GLuint>(c.raster_shm_id);
144   GLuint raster_shm_offset = static_cast<GLuint>(c.raster_shm_offset);
145   GLuint raster_shm_size = static_cast<GLuint>(c.raster_shm_size);
146   GLuint font_shm_id = static_cast<GLuint>(c.font_shm_id);
147   GLuint font_shm_offset = static_cast<GLuint>(c.font_shm_offset);
148   GLuint font_shm_size = static_cast<GLuint>(c.font_shm_size);
149   DoRasterCHROMIUM(raster_shm_id, raster_shm_offset, raster_shm_size,
150                    font_shm_id, font_shm_offset, font_shm_size);
151   return error::kNoError;
152 }
153 
HandleEndRasterCHROMIUM(uint32_t immediate_data_size,const volatile void * cmd_data)154 error::Error RasterDecoderImpl::HandleEndRasterCHROMIUM(
155     uint32_t immediate_data_size,
156     const volatile void* cmd_data) {
157   DoEndRasterCHROMIUM();
158   return error::kNoError;
159 }
160 
HandleCreateTransferCacheEntryINTERNAL(uint32_t immediate_data_size,const volatile void * cmd_data)161 error::Error RasterDecoderImpl::HandleCreateTransferCacheEntryINTERNAL(
162     uint32_t immediate_data_size,
163     const volatile void* cmd_data) {
164   const volatile raster::cmds::CreateTransferCacheEntryINTERNAL& c =
165       *static_cast<
166           const volatile raster::cmds::CreateTransferCacheEntryINTERNAL*>(
167           cmd_data);
168   GLuint entry_type = static_cast<GLuint>(c.entry_type);
169   GLuint entry_id = static_cast<GLuint>(c.entry_id);
170   GLuint handle_shm_id = static_cast<GLuint>(c.handle_shm_id);
171   GLuint handle_shm_offset = static_cast<GLuint>(c.handle_shm_offset);
172   GLuint data_shm_id = static_cast<GLuint>(c.data_shm_id);
173   GLuint data_shm_offset = static_cast<GLuint>(c.data_shm_offset);
174   GLuint data_size = static_cast<GLuint>(c.data_size);
175   DoCreateTransferCacheEntryINTERNAL(entry_type, entry_id, handle_shm_id,
176                                      handle_shm_offset, data_shm_id,
177                                      data_shm_offset, data_size);
178   return error::kNoError;
179 }
180 
HandleDeleteTransferCacheEntryINTERNAL(uint32_t immediate_data_size,const volatile void * cmd_data)181 error::Error RasterDecoderImpl::HandleDeleteTransferCacheEntryINTERNAL(
182     uint32_t immediate_data_size,
183     const volatile void* cmd_data) {
184   const volatile raster::cmds::DeleteTransferCacheEntryINTERNAL& c =
185       *static_cast<
186           const volatile raster::cmds::DeleteTransferCacheEntryINTERNAL*>(
187           cmd_data);
188   GLuint entry_type = static_cast<GLuint>(c.entry_type);
189   GLuint entry_id = static_cast<GLuint>(c.entry_id);
190   DoDeleteTransferCacheEntryINTERNAL(entry_type, entry_id);
191   return error::kNoError;
192 }
193 
HandleUnlockTransferCacheEntryINTERNAL(uint32_t immediate_data_size,const volatile void * cmd_data)194 error::Error RasterDecoderImpl::HandleUnlockTransferCacheEntryINTERNAL(
195     uint32_t immediate_data_size,
196     const volatile void* cmd_data) {
197   const volatile raster::cmds::UnlockTransferCacheEntryINTERNAL& c =
198       *static_cast<
199           const volatile raster::cmds::UnlockTransferCacheEntryINTERNAL*>(
200           cmd_data);
201   GLuint entry_type = static_cast<GLuint>(c.entry_type);
202   GLuint entry_id = static_cast<GLuint>(c.entry_id);
203   DoUnlockTransferCacheEntryINTERNAL(entry_type, entry_id);
204   return error::kNoError;
205 }
206 
207 error::Error
HandleDeletePaintCacheTextBlobsINTERNALImmediate(uint32_t immediate_data_size,const volatile void * cmd_data)208 RasterDecoderImpl::HandleDeletePaintCacheTextBlobsINTERNALImmediate(
209     uint32_t immediate_data_size,
210     const volatile void* cmd_data) {
211   const volatile raster::cmds::DeletePaintCacheTextBlobsINTERNALImmediate& c =
212       *static_cast<const volatile raster::cmds::
213                        DeletePaintCacheTextBlobsINTERNALImmediate*>(cmd_data);
214   GLsizei n = static_cast<GLsizei>(c.n);
215   uint32_t ids_size;
216   if (!base::CheckMul(n, sizeof(GLuint)).AssignIfValid(&ids_size)) {
217     return error::kOutOfBounds;
218   }
219   volatile const GLuint* ids =
220       gles2::GetImmediateDataAs<volatile const GLuint*>(c, ids_size,
221                                                         immediate_data_size);
222   if (ids == nullptr) {
223     return error::kOutOfBounds;
224   }
225   DeletePaintCacheTextBlobsINTERNALHelper(n, ids);
226   return error::kNoError;
227 }
228 
HandleDeletePaintCachePathsINTERNALImmediate(uint32_t immediate_data_size,const volatile void * cmd_data)229 error::Error RasterDecoderImpl::HandleDeletePaintCachePathsINTERNALImmediate(
230     uint32_t immediate_data_size,
231     const volatile void* cmd_data) {
232   const volatile raster::cmds::DeletePaintCachePathsINTERNALImmediate& c =
233       *static_cast<
234           const volatile raster::cmds::DeletePaintCachePathsINTERNALImmediate*>(
235           cmd_data);
236   GLsizei n = static_cast<GLsizei>(c.n);
237   uint32_t ids_size;
238   if (!base::CheckMul(n, sizeof(GLuint)).AssignIfValid(&ids_size)) {
239     return error::kOutOfBounds;
240   }
241   volatile const GLuint* ids =
242       gles2::GetImmediateDataAs<volatile const GLuint*>(c, ids_size,
243                                                         immediate_data_size);
244   if (ids == nullptr) {
245     return error::kOutOfBounds;
246   }
247   DeletePaintCachePathsINTERNALHelper(n, ids);
248   return error::kNoError;
249 }
250 
HandleClearPaintCacheINTERNAL(uint32_t immediate_data_size,const volatile void * cmd_data)251 error::Error RasterDecoderImpl::HandleClearPaintCacheINTERNAL(
252     uint32_t immediate_data_size,
253     const volatile void* cmd_data) {
254   DoClearPaintCacheINTERNAL();
255   return error::kNoError;
256 }
257 
HandleCopySubTextureINTERNALImmediate(uint32_t immediate_data_size,const volatile void * cmd_data)258 error::Error RasterDecoderImpl::HandleCopySubTextureINTERNALImmediate(
259     uint32_t immediate_data_size,
260     const volatile void* cmd_data) {
261   const volatile raster::cmds::CopySubTextureINTERNALImmediate& c =
262       *static_cast<
263           const volatile raster::cmds::CopySubTextureINTERNALImmediate*>(
264           cmd_data);
265   GLint xoffset = static_cast<GLint>(c.xoffset);
266   GLint yoffset = static_cast<GLint>(c.yoffset);
267   GLint x = static_cast<GLint>(c.x);
268   GLint y = static_cast<GLint>(c.y);
269   GLsizei width = static_cast<GLsizei>(c.width);
270   GLsizei height = static_cast<GLsizei>(c.height);
271   GLboolean unpack_flip_y = static_cast<GLboolean>(c.unpack_flip_y);
272   uint32_t mailboxes_size;
273   if (!gles2::GLES2Util::ComputeDataSize<GLbyte, 32>(1, &mailboxes_size)) {
274     return error::kOutOfBounds;
275   }
276   if (mailboxes_size > immediate_data_size) {
277     return error::kOutOfBounds;
278   }
279   volatile const GLbyte* mailboxes =
280       gles2::GetImmediateDataAs<volatile const GLbyte*>(c, mailboxes_size,
281                                                         immediate_data_size);
282   if (width < 0) {
283     LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureINTERNAL",
284                        "width < 0");
285     return error::kNoError;
286   }
287   if (height < 0) {
288     LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureINTERNAL",
289                        "height < 0");
290     return error::kNoError;
291   }
292   if (mailboxes == nullptr) {
293     return error::kOutOfBounds;
294   }
295   DoCopySubTextureINTERNAL(xoffset, yoffset, x, y, width, height, unpack_flip_y,
296                            mailboxes);
297   return error::kNoError;
298 }
299 
HandleWritePixelsINTERNALImmediate(uint32_t immediate_data_size,const volatile void * cmd_data)300 error::Error RasterDecoderImpl::HandleWritePixelsINTERNALImmediate(
301     uint32_t immediate_data_size,
302     const volatile void* cmd_data) {
303   const volatile raster::cmds::WritePixelsINTERNALImmediate& c =
304       *static_cast<const volatile raster::cmds::WritePixelsINTERNALImmediate*>(
305           cmd_data);
306   GLint x_offset = static_cast<GLint>(c.x_offset);
307   GLint y_offset = static_cast<GLint>(c.y_offset);
308   GLuint src_width = static_cast<GLuint>(c.src_width);
309   GLuint src_height = static_cast<GLuint>(c.src_height);
310   GLuint row_bytes = static_cast<GLuint>(c.row_bytes);
311   GLuint src_sk_color_type = static_cast<GLuint>(c.src_sk_color_type);
312   GLuint src_sk_alpha_type = static_cast<GLuint>(c.src_sk_alpha_type);
313   GLint shm_id = static_cast<GLint>(c.shm_id);
314   GLuint shm_offset = static_cast<GLuint>(c.shm_offset);
315   GLuint pixels_offset = static_cast<GLuint>(c.pixels_offset);
316   uint32_t mailbox_size;
317   if (!gles2::GLES2Util::ComputeDataSize<GLbyte, 16>(1, &mailbox_size)) {
318     return error::kOutOfBounds;
319   }
320   if (mailbox_size > immediate_data_size) {
321     return error::kOutOfBounds;
322   }
323   volatile const GLbyte* mailbox =
324       gles2::GetImmediateDataAs<volatile const GLbyte*>(c, mailbox_size,
325                                                         immediate_data_size);
326   if (mailbox == nullptr) {
327     return error::kOutOfBounds;
328   }
329   DoWritePixelsINTERNAL(x_offset, y_offset, src_width, src_height, row_bytes,
330                         src_sk_color_type, src_sk_alpha_type, shm_id,
331                         shm_offset, pixels_offset, mailbox);
332   return error::kNoError;
333 }
334 
HandleReadbackImagePixelsINTERNALImmediate(uint32_t immediate_data_size,const volatile void * cmd_data)335 error::Error RasterDecoderImpl::HandleReadbackImagePixelsINTERNALImmediate(
336     uint32_t immediate_data_size,
337     const volatile void* cmd_data) {
338   const volatile raster::cmds::ReadbackImagePixelsINTERNALImmediate& c =
339       *static_cast<
340           const volatile raster::cmds::ReadbackImagePixelsINTERNALImmediate*>(
341           cmd_data);
342   GLint src_x = static_cast<GLint>(c.src_x);
343   GLint src_y = static_cast<GLint>(c.src_y);
344   GLuint dst_width = static_cast<GLuint>(c.dst_width);
345   GLuint dst_height = static_cast<GLuint>(c.dst_height);
346   GLuint row_bytes = static_cast<GLuint>(c.row_bytes);
347   GLuint dst_sk_color_type = static_cast<GLuint>(c.dst_sk_color_type);
348   GLuint dst_sk_alpha_type = static_cast<GLuint>(c.dst_sk_alpha_type);
349   GLint shm_id = static_cast<GLint>(c.shm_id);
350   GLuint shm_offset = static_cast<GLuint>(c.shm_offset);
351   GLuint pixels_offset = static_cast<GLuint>(c.pixels_offset);
352   uint32_t mailbox_size;
353   if (!gles2::GLES2Util::ComputeDataSize<GLbyte, 16>(1, &mailbox_size)) {
354     return error::kOutOfBounds;
355   }
356   if (mailbox_size > immediate_data_size) {
357     return error::kOutOfBounds;
358   }
359   volatile const GLbyte* mailbox =
360       gles2::GetImmediateDataAs<volatile const GLbyte*>(c, mailbox_size,
361                                                         immediate_data_size);
362   if (mailbox == nullptr) {
363     return error::kOutOfBounds;
364   }
365   DoReadbackImagePixelsINTERNAL(src_x, src_y, dst_width, dst_height, row_bytes,
366                                 dst_sk_color_type, dst_sk_alpha_type, shm_id,
367                                 shm_offset, pixels_offset, mailbox);
368   return error::kNoError;
369 }
370 
HandleConvertYUVMailboxesToRGBINTERNALImmediate(uint32_t immediate_data_size,const volatile void * cmd_data)371 error::Error RasterDecoderImpl::HandleConvertYUVMailboxesToRGBINTERNALImmediate(
372     uint32_t immediate_data_size,
373     const volatile void* cmd_data) {
374   const volatile raster::cmds::ConvertYUVMailboxesToRGBINTERNALImmediate& c =
375       *static_cast<const volatile raster::cmds::
376                        ConvertYUVMailboxesToRGBINTERNALImmediate*>(cmd_data);
377   GLenum planes_yuv_color_space = static_cast<GLenum>(c.planes_yuv_color_space);
378   GLboolean is_nv12 = static_cast<GLboolean>(c.is_nv12);
379   uint32_t mailboxes_size;
380   if (!gles2::GLES2Util::ComputeDataSize<GLbyte, 64>(1, &mailboxes_size)) {
381     return error::kOutOfBounds;
382   }
383   if (mailboxes_size > immediate_data_size) {
384     return error::kOutOfBounds;
385   }
386   volatile const GLbyte* mailboxes =
387       gles2::GetImmediateDataAs<volatile const GLbyte*>(c, mailboxes_size,
388                                                         immediate_data_size);
389   if (mailboxes == nullptr) {
390     return error::kOutOfBounds;
391   }
392   DoConvertYUVMailboxesToRGBINTERNAL(planes_yuv_color_space, is_nv12,
393                                      mailboxes);
394   return error::kNoError;
395 }
396 
HandleTraceEndCHROMIUM(uint32_t immediate_data_size,const volatile void * cmd_data)397 error::Error RasterDecoderImpl::HandleTraceEndCHROMIUM(
398     uint32_t immediate_data_size,
399     const volatile void* cmd_data) {
400   DoTraceEndCHROMIUM();
401   return error::kNoError;
402 }
403 
404 #endif  // GPU_COMMAND_BUFFER_SERVICE_RASTER_DECODER_AUTOGEN_H_
405