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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
11 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h"
12 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
13 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h"
14 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
15 #include "gpu/command_buffer/service/context_group.h"
16 #include "gpu/command_buffer/service/context_state.h"
17 #include "gpu/command_buffer/service/gl_surface_mock.h"
18 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
20 #include "gpu/command_buffer/service/gpu_switches.h"
21 #include "gpu/command_buffer/service/image_manager.h"
22 #include "gpu/command_buffer/service/mailbox_manager.h"
23 #include "gpu/command_buffer/service/mocks.h"
24 #include "gpu/command_buffer/service/program_manager.h"
25 #include "gpu/command_buffer/service/test_helper.h"
26 #include "testing/gtest/include/gtest/gtest.h"
27 #include "ui/gl/gl_implementation.h"
28 #include "ui/gl/gl_mock.h"
29 #include "ui/gl/gl_surface_stub.h"
31 #if !defined(GL_DEPTH24_STENCIL8)
32 #define GL_DEPTH24_STENCIL8 0x88F0
35 using ::gfx::MockGLInterface
;
37 using ::testing::DoAll
;
38 using ::testing::InSequence
;
39 using ::testing::Invoke
;
40 using ::testing::MatcherCast
;
41 using ::testing::Mock
;
42 using ::testing::Pointee
;
43 using ::testing::Return
;
44 using ::testing::SaveArg
;
45 using ::testing::SetArrayArgument
;
46 using ::testing::SetArgumentPointee
;
47 using ::testing::SetArgPointee
;
48 using ::testing::StrEq
;
49 using ::testing::StrictMock
;
56 class GLES2DecoderTestWithExtensionsOnGLES2
: public GLES2DecoderTest
{
58 GLES2DecoderTestWithExtensionsOnGLES2() {}
60 void SetUp() override
{}
61 void Init(const char* extensions
) {
63 init
.extensions
= extensions
;
64 init
.gl_version
= "opengl es 2.0";
65 init
.has_alpha
= true;
66 init
.has_depth
= true;
67 init
.request_alpha
= true;
68 init
.request_depth
= true;
73 TEST_P(GLES2DecoderTest
, CheckFramebufferStatusWithNoBoundTarget
) {
74 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(_
)).Times(0);
75 CheckFramebufferStatus::Result
* result
=
76 static_cast<CheckFramebufferStatus::Result
*>(shared_memory_address_
);
78 CheckFramebufferStatus cmd
;
79 cmd
.Init(GL_FRAMEBUFFER
, shared_memory_id_
, shared_memory_offset_
);
80 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
81 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
), *result
);
84 TEST_P(GLES2DecoderWithShaderTest
, BindAndDeleteFramebuffer
) {
86 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
87 SetupExpectationsForApplyingDefaultDirtyState();
89 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
90 DoDeleteFramebuffer(client_framebuffer_id_
,
91 kServiceFramebufferId
,
98 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
100 .RetiresOnSaturation();
102 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
103 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
104 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
107 TEST_P(GLES2DecoderTest
, FramebufferRenderbufferWithNoBoundTarget
) {
108 EXPECT_CALL(*gl_
, FramebufferRenderbufferEXT(_
, _
, _
, _
)).Times(0);
109 FramebufferRenderbuffer cmd
;
110 cmd
.Init(GL_FRAMEBUFFER
,
111 GL_COLOR_ATTACHMENT0
,
113 client_renderbuffer_id_
);
114 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
115 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
118 TEST_P(GLES2DecoderTest
, FramebufferTexture2DWithNoBoundTarget
) {
119 EXPECT_CALL(*gl_
, FramebufferTexture2DEXT(_
, _
, _
, _
, _
)).Times(0);
120 FramebufferTexture2D cmd
;
121 cmd
.Init(GL_FRAMEBUFFER
,
122 GL_COLOR_ATTACHMENT0
,
125 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
126 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
129 TEST_P(GLES2DecoderTest
, GetFramebufferAttachmentParameterivWithNoBoundTarget
) {
130 EXPECT_CALL(*gl_
, GetError())
131 .WillOnce(Return(GL_NO_ERROR
))
132 .WillOnce(Return(GL_NO_ERROR
))
133 .RetiresOnSaturation();
134 EXPECT_CALL(*gl_
, GetFramebufferAttachmentParameterivEXT(_
, _
, _
, _
))
136 GetFramebufferAttachmentParameteriv cmd
;
137 cmd
.Init(GL_FRAMEBUFFER
,
138 GL_COLOR_ATTACHMENT0
,
139 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
,
141 shared_memory_offset_
);
142 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
143 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
146 TEST_P(GLES2DecoderTest
, GetFramebufferAttachmentParameterivWithRenderbuffer
) {
148 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
149 EXPECT_CALL(*gl_
, GetError())
150 .WillOnce(Return(GL_NO_ERROR
))
151 .RetiresOnSaturation();
153 FramebufferRenderbufferEXT(GL_FRAMEBUFFER
,
154 GL_COLOR_ATTACHMENT0
,
156 kServiceRenderbufferId
))
158 .RetiresOnSaturation();
159 EXPECT_CALL(*gl_
, GetError())
160 .WillOnce(Return(GL_NO_ERROR
))
161 .RetiresOnSaturation();
162 EXPECT_CALL(*gl_
, GetError())
163 .WillOnce(Return(GL_NO_ERROR
))
164 .WillOnce(Return(GL_NO_ERROR
))
165 .RetiresOnSaturation();
166 GetFramebufferAttachmentParameteriv::Result
* result
=
167 static_cast<GetFramebufferAttachmentParameteriv::Result
*>(
168 shared_memory_address_
);
170 const GLint
* result_value
= result
->GetData();
171 FramebufferRenderbuffer fbrb_cmd
;
172 GetFramebufferAttachmentParameteriv cmd
;
173 fbrb_cmd
.Init(GL_FRAMEBUFFER
,
174 GL_COLOR_ATTACHMENT0
,
176 client_renderbuffer_id_
);
177 cmd
.Init(GL_FRAMEBUFFER
,
178 GL_COLOR_ATTACHMENT0
,
179 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
,
181 shared_memory_offset_
);
182 EXPECT_EQ(error::kNoError
, ExecuteCmd(fbrb_cmd
));
183 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
184 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
185 EXPECT_EQ(static_cast<GLuint
>(*result_value
), client_renderbuffer_id_
);
188 TEST_P(GLES2DecoderTest
, GetFramebufferAttachmentParameterivWithTexture
) {
190 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
191 EXPECT_CALL(*gl_
, GetError())
192 .WillOnce(Return(GL_NO_ERROR
))
193 .RetiresOnSaturation();
195 FramebufferTexture2DEXT(GL_FRAMEBUFFER
,
196 GL_COLOR_ATTACHMENT0
,
201 .RetiresOnSaturation();
202 EXPECT_CALL(*gl_
, GetError())
203 .WillOnce(Return(GL_NO_ERROR
))
204 .RetiresOnSaturation();
205 EXPECT_CALL(*gl_
, GetError())
206 .WillOnce(Return(GL_NO_ERROR
))
207 .WillOnce(Return(GL_NO_ERROR
))
208 .RetiresOnSaturation();
209 GetFramebufferAttachmentParameteriv::Result
* result
=
210 static_cast<GetFramebufferAttachmentParameteriv::Result
*>(
211 shared_memory_address_
);
212 result
->SetNumResults(0);
213 const GLint
* result_value
= result
->GetData();
214 FramebufferTexture2D fbtex_cmd
;
215 GetFramebufferAttachmentParameteriv cmd
;
216 fbtex_cmd
.Init(GL_FRAMEBUFFER
,
217 GL_COLOR_ATTACHMENT0
,
220 cmd
.Init(GL_FRAMEBUFFER
,
221 GL_COLOR_ATTACHMENT0
,
222 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
,
224 shared_memory_offset_
);
225 EXPECT_EQ(error::kNoError
, ExecuteCmd(fbtex_cmd
));
226 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
227 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
228 EXPECT_EQ(static_cast<GLuint
>(*result_value
), client_texture_id_
);
231 TEST_P(GLES2DecoderWithShaderTest
,
232 GetRenderbufferParameterivRebindRenderbuffer
) {
235 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
236 DoRenderbufferStorage(GL_RENDERBUFFER
, GL_RGBA4
, GL_RGBA
, 1, 1, GL_NO_ERROR
);
238 GetRenderbufferParameteriv cmd
;
239 cmd
.Init(GL_RENDERBUFFER
,
240 GL_RENDERBUFFER_RED_SIZE
,
242 shared_memory_offset_
);
244 RestoreRenderbufferBindings();
245 EnsureRenderbufferBound(true);
247 EXPECT_CALL(*gl_
, GetError())
248 .WillOnce(Return(GL_NO_ERROR
))
249 .WillOnce(Return(GL_NO_ERROR
))
250 .RetiresOnSaturation();
252 GetRenderbufferParameterivEXT(
253 GL_RENDERBUFFER
, GL_RENDERBUFFER_RED_SIZE
, _
));
254 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
255 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
258 TEST_P(GLES2DecoderTest
, GetRenderbufferParameterivWithNoBoundTarget
) {
259 EXPECT_CALL(*gl_
, GetError())
260 .WillOnce(Return(GL_NO_ERROR
))
261 .WillOnce(Return(GL_NO_ERROR
))
262 .RetiresOnSaturation();
263 EXPECT_CALL(*gl_
, GetRenderbufferParameterivEXT(_
, _
, _
)).Times(0);
264 GetRenderbufferParameteriv cmd
;
265 cmd
.Init(GL_RENDERBUFFER
,
266 GL_RENDERBUFFER_WIDTH
,
268 shared_memory_offset_
);
269 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
270 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
273 TEST_P(GLES2DecoderWithShaderTest
, RenderbufferStorageRebindRenderbuffer
) {
276 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
277 RestoreRenderbufferBindings();
278 EnsureRenderbufferBound(true);
279 DoRenderbufferStorage(GL_RENDERBUFFER
, GL_RGBA4
, GL_RGBA
, 1, 1, GL_NO_ERROR
);
282 TEST_P(GLES2DecoderTest
, RenderbufferStorageWithNoBoundTarget
) {
283 EXPECT_CALL(*gl_
, RenderbufferStorageEXT(_
, _
, _
, _
)).Times(0);
284 RenderbufferStorage cmd
;
285 cmd
.Init(GL_RENDERBUFFER
, GL_RGBA4
, 3, 4);
286 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
287 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
292 // A class to emulate glReadPixels
293 class ReadPixelsEmulator
{
295 // pack_alignment is the alignment you want ReadPixels to use
296 // when copying. The actual data passed in pixels should be contiguous.
297 ReadPixelsEmulator(GLsizei width
,
299 GLint bytes_per_pixel
,
300 const void* src_pixels
,
301 const void* expected_pixels
,
302 GLint pack_alignment
)
305 pack_alignment_(pack_alignment
),
306 bytes_per_pixel_(bytes_per_pixel
),
307 src_pixels_(reinterpret_cast<const int8
*>(src_pixels
)),
308 expected_pixels_(reinterpret_cast<const int8
*>(expected_pixels
)) {}
310 void ReadPixels(GLint x
,
316 void* pixels
) const {
319 DCHECK_LE(x
+ width
, width_
);
320 DCHECK_LE(y
+ height
, height_
);
321 for (GLint yy
= 0; yy
< height
; ++yy
) {
322 const int8
* src
= GetPixelAddress(src_pixels_
, x
, y
+ yy
);
323 const void* dst
= ComputePackAlignmentAddress(0, yy
, width
, pixels
);
324 memcpy(const_cast<void*>(dst
), src
, width
* bytes_per_pixel_
);
328 bool CompareRowSegment(GLint x
,
331 const void* data
) const {
332 DCHECK(x
+ width
<= width_
|| width
== 0);
334 GetPixelAddress(expected_pixels_
, x
, y
),
335 width
* bytes_per_pixel_
) == 0;
338 // Helper to compute address of pixel in pack aligned data.
339 const void* ComputePackAlignmentAddress(GLint x
,
342 const void* address
) const {
343 GLint unpadded_row_size
= ComputeImageDataSize(width
, 1);
344 GLint two_rows_size
= ComputeImageDataSize(width
, 2);
345 GLsizei padded_row_size
= two_rows_size
- unpadded_row_size
;
346 GLint offset
= y
* padded_row_size
+ x
* bytes_per_pixel_
;
347 return static_cast<const int8
*>(address
) + offset
;
350 GLint
ComputeImageDataSize(GLint width
, GLint height
) const {
351 GLint row_size
= width
* bytes_per_pixel_
;
353 GLint temp
= row_size
+ pack_alignment_
- 1;
354 GLint padded_row_size
= (temp
/ pack_alignment_
) * pack_alignment_
;
355 GLint size_of_all_but_last_row
= (height
- 1) * padded_row_size
;
356 return size_of_all_but_last_row
+ row_size
;
358 return height
* row_size
;
363 const int8
* GetPixelAddress(const int8
* base
, GLint x
, GLint y
) const {
364 return base
+ (width_
* y
+ x
) * bytes_per_pixel_
;
369 GLint pack_alignment_
;
370 GLint bytes_per_pixel_
;
371 const int8
* src_pixels_
;
372 const int8
* expected_pixels_
;
375 } // anonymous namespace
377 void GLES2DecoderTest::CheckReadPixelsOutOfRange(GLint in_read_x
,
379 GLsizei in_read_width
,
380 GLsizei in_read_height
,
382 const GLsizei kWidth
= 5;
383 const GLsizei kHeight
= 3;
384 const GLint kBytesPerPixel
= 3;
385 const GLint kPackAlignment
= 4;
386 const GLenum kFormat
= GL_RGB
;
387 static const int8 kSrcPixels
[kWidth
* kHeight
* kBytesPerPixel
] = {
388 12, 13, 14, 18, 19, 18, 19, 12, 13, 14, 18, 19, 18, 19, 13,
389 29, 28, 23, 22, 21, 22, 21, 29, 28, 23, 22, 21, 22, 21, 28,
390 31, 34, 39, 37, 32, 37, 32, 31, 34, 39, 37, 32, 37, 32, 34,
395 // We need to setup an FBO so we can know the max size that ReadPixels will
398 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
399 DoTexImage2D(GL_TEXTURE_2D
,
408 kSharedMemoryOffset
);
410 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
411 DoFramebufferTexture2D(GL_FRAMEBUFFER
,
412 GL_COLOR_ATTACHMENT0
,
418 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_FRAMEBUFFER
))
419 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
420 .RetiresOnSaturation();
423 ReadPixelsEmulator
emu(
424 kWidth
, kHeight
, kBytesPerPixel
, kSrcPixels
, kSrcPixels
, kPackAlignment
);
425 typedef ReadPixels::Result Result
;
426 Result
* result
= GetSharedMemoryAs
<Result
*>();
427 uint32 result_shm_id
= kSharedMemoryId
;
428 uint32 result_shm_offset
= kSharedMemoryOffset
;
429 uint32 pixels_shm_id
= kSharedMemoryId
;
430 uint32 pixels_shm_offset
= kSharedMemoryOffset
+ sizeof(*result
);
431 void* dest
= &result
[1];
432 EXPECT_CALL(*gl_
, GetError())
433 .WillOnce(Return(GL_NO_ERROR
))
434 .WillOnce(Return(GL_NO_ERROR
))
435 .RetiresOnSaturation();
436 // ReadPixels will be called for valid size only even though the command
437 // is requesting a larger size.
438 GLint read_x
= std::max(0, in_read_x
);
439 GLint read_y
= std::max(0, in_read_y
);
440 GLint read_end_x
= std::max(0, std::min(kWidth
, in_read_x
+ in_read_width
));
441 GLint read_end_y
= std::max(0, std::min(kHeight
, in_read_y
+ in_read_height
));
442 GLint read_width
= read_end_x
- read_x
;
443 GLint read_height
= read_end_y
- read_y
;
444 if (read_width
> 0 && read_height
> 0) {
445 for (GLint yy
= read_y
; yy
< read_end_y
; ++yy
) {
448 ReadPixels(read_x
, yy
, read_width
, 1, kFormat
, GL_UNSIGNED_BYTE
, _
))
449 .WillOnce(Invoke(&emu
, &ReadPixelsEmulator::ReadPixels
))
450 .RetiresOnSaturation();
465 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
467 GLint unpadded_row_size
= emu
.ComputeImageDataSize(in_read_width
, 1);
468 scoped_ptr
<int8
[]> zero(new int8
[unpadded_row_size
]);
469 scoped_ptr
<int8
[]> pack(new int8
[kPackAlignment
]);
470 memset(zero
.get(), 0, unpadded_row_size
);
471 memset(pack
.get(), kInitialMemoryValue
, kPackAlignment
);
472 for (GLint yy
= 0; yy
< in_read_height
; ++yy
) {
473 const int8
* row
= static_cast<const int8
*>(
474 emu
.ComputePackAlignmentAddress(0, yy
, in_read_width
, dest
));
475 GLint y
= in_read_y
+ yy
;
476 if (y
< 0 || y
>= kHeight
) {
477 EXPECT_EQ(0, memcmp(zero
.get(), row
, unpadded_row_size
));
480 GLint num_left_pixels
= std::max(-in_read_x
, 0);
481 GLint num_left_bytes
= num_left_pixels
* kBytesPerPixel
;
482 EXPECT_EQ(0, memcmp(zero
.get(), row
, num_left_bytes
));
485 GLint num_right_pixels
= std::max(in_read_x
+ in_read_width
- kWidth
, 0);
486 GLint num_right_bytes
= num_right_pixels
* kBytesPerPixel
;
489 row
+ unpadded_row_size
- num_right_bytes
,
493 GLint x
= std::max(in_read_x
, 0);
494 GLint num_middle_pixels
=
495 std::max(in_read_width
- num_left_pixels
- num_right_pixels
, 0);
497 emu
.CompareRowSegment(x
, y
, num_middle_pixels
, row
+ num_left_bytes
));
501 if (yy
!= in_read_height
- 1) {
502 GLint num_padding_bytes
=
503 (kPackAlignment
- 1) - (unpadded_row_size
% kPackAlignment
);
505 memcmp(pack
.get(), row
+ unpadded_row_size
, num_padding_bytes
));
510 TEST_P(GLES2DecoderTest
, ReadPixels
) {
511 const GLsizei kWidth
= 5;
512 const GLsizei kHeight
= 3;
513 const GLint kBytesPerPixel
= 3;
514 const GLint kPackAlignment
= 4;
515 static const int8 kSrcPixels
[kWidth
* kHeight
* kBytesPerPixel
] = {
516 12, 13, 14, 18, 19, 18, 19, 12, 13, 14, 18, 19, 18, 19, 13,
517 29, 28, 23, 22, 21, 22, 21, 29, 28, 23, 22, 21, 22, 21, 28,
518 31, 34, 39, 37, 32, 37, 32, 31, 34, 39, 37, 32, 37, 32, 34,
521 surface_
->SetSize(gfx::Size(INT_MAX
, INT_MAX
));
523 ReadPixelsEmulator
emu(
524 kWidth
, kHeight
, kBytesPerPixel
, kSrcPixels
, kSrcPixels
, kPackAlignment
);
525 typedef ReadPixels::Result Result
;
526 Result
* result
= GetSharedMemoryAs
<Result
*>();
527 uint32 result_shm_id
= kSharedMemoryId
;
528 uint32 result_shm_offset
= kSharedMemoryOffset
;
529 uint32 pixels_shm_id
= kSharedMemoryId
;
530 uint32 pixels_shm_offset
= kSharedMemoryOffset
+ sizeof(*result
);
531 void* dest
= &result
[1];
532 EXPECT_CALL(*gl_
, GetError())
533 .WillOnce(Return(GL_NO_ERROR
))
534 .WillOnce(Return(GL_NO_ERROR
))
535 .RetiresOnSaturation();
537 ReadPixels(0, 0, kWidth
, kHeight
, GL_RGB
, GL_UNSIGNED_BYTE
, _
))
538 .WillOnce(Invoke(&emu
, &ReadPixelsEmulator::ReadPixels
));
551 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
552 for (GLint yy
= 0; yy
< kHeight
; ++yy
) {
553 EXPECT_TRUE(emu
.CompareRowSegment(
554 0, yy
, kWidth
, emu
.ComputePackAlignmentAddress(0, yy
, kWidth
, dest
)));
558 TEST_P(GLES2DecoderRGBBackbufferTest
, ReadPixelsNoAlphaBackbuffer
) {
559 const GLsizei kWidth
= 3;
560 const GLsizei kHeight
= 3;
561 const GLint kBytesPerPixel
= 4;
562 const GLint kPackAlignment
= 4;
563 static const uint8 kExpectedPixels
[kWidth
* kHeight
* kBytesPerPixel
] = {
564 12, 13, 14, 255, 19, 18, 19, 255, 13, 14, 18, 255,
565 29, 28, 23, 255, 21, 22, 21, 255, 28, 23, 22, 255,
566 31, 34, 39, 255, 32, 37, 32, 255, 34, 39, 37, 255,
568 static const uint8 kSrcPixels
[kWidth
* kHeight
* kBytesPerPixel
] = {
569 12, 13, 14, 18, 19, 18, 19, 12, 13, 14, 18, 19, 29, 28, 23, 22, 21, 22,
570 21, 29, 28, 23, 22, 21, 31, 34, 39, 37, 32, 37, 32, 31, 34, 39, 37, 32,
573 surface_
->SetSize(gfx::Size(INT_MAX
, INT_MAX
));
575 ReadPixelsEmulator
emu(kWidth
,
581 typedef ReadPixels::Result Result
;
582 Result
* result
= GetSharedMemoryAs
<Result
*>();
583 uint32 result_shm_id
= kSharedMemoryId
;
584 uint32 result_shm_offset
= kSharedMemoryOffset
;
585 uint32 pixels_shm_id
= kSharedMemoryId
;
586 uint32 pixels_shm_offset
= kSharedMemoryOffset
+ sizeof(*result
);
587 void* dest
= &result
[1];
588 EXPECT_CALL(*gl_
, GetError())
589 .WillOnce(Return(GL_NO_ERROR
))
590 .WillOnce(Return(GL_NO_ERROR
))
591 .RetiresOnSaturation();
593 ReadPixels(0, 0, kWidth
, kHeight
, GL_RGBA
, GL_UNSIGNED_BYTE
, _
))
594 .WillOnce(Invoke(&emu
, &ReadPixelsEmulator::ReadPixels
));
607 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
608 for (GLint yy
= 0; yy
< kHeight
; ++yy
) {
609 EXPECT_TRUE(emu
.CompareRowSegment(
610 0, yy
, kWidth
, emu
.ComputePackAlignmentAddress(0, yy
, kWidth
, dest
)));
614 TEST_P(GLES2DecoderTest
, ReadPixelsOutOfRange
) {
615 static GLint tests
[][4] = {
618 }, // out of range on all sides
621 }, // out of range on right, bottom
624 }, // out of range on left, top
627 }, // completely off top
630 }, // completely off bottom
633 }, // completely off left
636 }, // completely off right
639 for (size_t tt
= 0; tt
< arraysize(tests
); ++tt
) {
640 CheckReadPixelsOutOfRange(
641 tests
[tt
][0], tests
[tt
][1], tests
[tt
][2], tests
[tt
][3], tt
== 0);
645 TEST_P(GLES2DecoderTest
, ReadPixelsInvalidArgs
) {
646 typedef ReadPixels::Result Result
;
647 uint32 result_shm_id
= kSharedMemoryId
;
648 uint32 result_shm_offset
= kSharedMemoryOffset
;
649 uint32 pixels_shm_id
= kSharedMemoryId
;
650 uint32 pixels_shm_offset
= kSharedMemoryOffset
+ sizeof(Result
);
651 EXPECT_CALL(*gl_
, ReadPixels(_
, _
, _
, _
, _
, _
, _
)).Times(0);
664 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
665 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
677 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
678 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
690 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
691 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
698 kInvalidSharedMemoryId
,
703 EXPECT_NE(error::kNoError
, ExecuteCmd(cmd
));
711 kInvalidSharedMemoryOffset
,
715 EXPECT_NE(error::kNoError
, ExecuteCmd(cmd
));
724 kInvalidSharedMemoryId
,
727 EXPECT_NE(error::kNoError
, ExecuteCmd(cmd
));
737 kInvalidSharedMemoryOffset
,
739 EXPECT_NE(error::kNoError
, ExecuteCmd(cmd
));
742 TEST_P(GLES2DecoderManualInitTest
, ReadPixelsAsyncError
) {
744 init
.extensions
= "GL_ARB_sync";
745 init
.gl_version
= "opengl es 3.0";
746 init
.has_alpha
= true;
747 init
.request_alpha
= true;
748 init
.bind_generates_resource
= true;
751 typedef ReadPixels::Result Result
;
753 const GLsizei kWidth
= 4;
754 const GLsizei kHeight
= 4;
755 uint32 result_shm_id
= kSharedMemoryId
;
756 uint32 result_shm_offset
= kSharedMemoryOffset
;
757 uint32 pixels_shm_id
= kSharedMemoryId
;
758 uint32 pixels_shm_offset
= kSharedMemoryOffset
+ sizeof(Result
);
760 EXPECT_CALL(*gl_
, GetError())
761 // first error check must pass to get to the test
762 .WillOnce(Return(GL_NO_ERROR
))
763 // second check is after BufferData, simulate fail here
764 .WillOnce(Return(GL_INVALID_OPERATION
))
765 // third error check is fall-through call to sync ReadPixels
766 .WillOnce(Return(GL_NO_ERROR
))
767 .RetiresOnSaturation();
770 ReadPixels(0, 0, kWidth
, kHeight
, GL_RGB
, GL_UNSIGNED_BYTE
, _
))
772 EXPECT_CALL(*gl_
, GenBuffersARB(1, _
)).Times(1);
773 EXPECT_CALL(*gl_
, DeleteBuffersARB(1, _
)).Times(1);
774 EXPECT_CALL(*gl_
, BindBuffer(GL_PIXEL_PACK_BUFFER_ARB
, _
)).Times(2);
776 BufferData(GL_PIXEL_PACK_BUFFER_ARB
, _
, NULL
, GL_STREAM_READ
))
791 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
794 // Check that if a renderbuffer is attached and GL returns
795 // GL_FRAMEBUFFER_COMPLETE that the buffer is cleared and state is restored.
796 TEST_P(GLES2DecoderTest
, FramebufferRenderbufferClearColor
) {
798 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
799 ClearColor color_cmd
;
800 ColorMask color_mask_cmd
;
802 FramebufferRenderbuffer cmd
;
803 color_cmd
.Init(0.1f
, 0.2f
, 0.3f
, 0.4f
);
804 color_mask_cmd
.Init(0, 1, 0, 1);
805 enable_cmd
.Init(GL_SCISSOR_TEST
);
806 cmd
.Init(GL_FRAMEBUFFER
,
807 GL_COLOR_ATTACHMENT0
,
809 client_renderbuffer_id_
);
811 EXPECT_CALL(*gl_
, ClearColor(0.1f
, 0.2f
, 0.3f
, 0.4f
))
813 .RetiresOnSaturation();
814 SetupExpectationsForEnableDisable(GL_SCISSOR_TEST
, true);
815 EXPECT_CALL(*gl_
, GetError())
816 .WillOnce(Return(GL_NO_ERROR
))
817 .RetiresOnSaturation();
819 FramebufferRenderbufferEXT(GL_FRAMEBUFFER
,
820 GL_COLOR_ATTACHMENT0
,
822 kServiceRenderbufferId
))
824 .RetiresOnSaturation();
825 EXPECT_CALL(*gl_
, GetError())
826 .WillOnce(Return(GL_NO_ERROR
))
827 .RetiresOnSaturation();
828 EXPECT_EQ(error::kNoError
, ExecuteCmd(color_cmd
));
829 EXPECT_EQ(error::kNoError
, ExecuteCmd(color_mask_cmd
));
830 EXPECT_EQ(error::kNoError
, ExecuteCmd(enable_cmd
));
831 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
834 TEST_P(GLES2DecoderTest
, FramebufferRenderbufferClearDepth
) {
836 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
837 ClearDepthf depth_cmd
;
838 DepthMask depth_mask_cmd
;
839 FramebufferRenderbuffer cmd
;
840 depth_cmd
.Init(0.5f
);
841 depth_mask_cmd
.Init(false);
842 cmd
.Init(GL_FRAMEBUFFER
,
845 client_renderbuffer_id_
);
847 EXPECT_CALL(*gl_
, ClearDepth(0.5f
)).Times(1).RetiresOnSaturation();
848 EXPECT_CALL(*gl_
, GetError())
849 .WillOnce(Return(GL_NO_ERROR
))
850 .RetiresOnSaturation();
852 FramebufferRenderbufferEXT(GL_FRAMEBUFFER
,
855 kServiceRenderbufferId
))
857 .RetiresOnSaturation();
858 EXPECT_CALL(*gl_
, GetError())
859 .WillOnce(Return(GL_NO_ERROR
))
860 .RetiresOnSaturation();
861 EXPECT_EQ(error::kNoError
, ExecuteCmd(depth_cmd
));
862 EXPECT_EQ(error::kNoError
, ExecuteCmd(depth_mask_cmd
));
863 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
866 TEST_P(GLES2DecoderTest
, FramebufferRenderbufferClearStencil
) {
868 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
869 ClearStencil stencil_cmd
;
870 StencilMaskSeparate stencil_mask_separate_cmd
;
871 FramebufferRenderbuffer cmd
;
872 stencil_cmd
.Init(123);
873 stencil_mask_separate_cmd
.Init(GL_BACK
, 0x1234u
);
874 cmd
.Init(GL_FRAMEBUFFER
,
875 GL_STENCIL_ATTACHMENT
,
877 client_renderbuffer_id_
);
879 EXPECT_CALL(*gl_
, ClearStencil(123)).Times(1).RetiresOnSaturation();
880 EXPECT_CALL(*gl_
, GetError())
881 .WillOnce(Return(GL_NO_ERROR
))
882 .RetiresOnSaturation();
884 FramebufferRenderbufferEXT(GL_FRAMEBUFFER
,
885 GL_STENCIL_ATTACHMENT
,
887 kServiceRenderbufferId
))
889 .RetiresOnSaturation();
890 EXPECT_CALL(*gl_
, GetError())
891 .WillOnce(Return(GL_NO_ERROR
))
892 .RetiresOnSaturation();
893 EXPECT_EQ(error::kNoError
, ExecuteCmd(stencil_cmd
));
894 EXPECT_EQ(error::kNoError
, ExecuteCmd(stencil_mask_separate_cmd
));
895 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
898 #if 0 // Turn this test on once we allow GL_DEPTH_STENCIL_ATTACHMENT
899 TEST_P(GLES2DecoderTest
, FramebufferRenderbufferClearDepthStencil
) {
900 DoBindFramebuffer(GL_FRAMEBUFFER
, client_framebuffer_id_
,
901 kServiceFramebufferId
);
902 ClearDepthf depth_cmd
;
903 ClearStencil stencil_cmd
;
904 FramebufferRenderbuffer cmd
;
905 depth_cmd
.Init(0.5f
);
906 stencil_cmd
.Init(123);
908 GL_FRAMEBUFFER
, GL_DEPTH_STENCIL_ATTACHMENT
, GL_RENDERBUFFER
,
909 client_renderbuffer_id_
);
911 EXPECT_CALL(*gl_
, ClearDepth(0.5f
))
913 .RetiresOnSaturation();
914 EXPECT_CALL(*gl_
, ClearStencil(123))
916 .RetiresOnSaturation();
917 EXPECT_CALL(*gl_
, FramebufferRenderbufferEXT(
918 GL_FRAMEBUFFER
, GL_DEPTH_STENCIL_ATTACHMENT
, GL_RENDERBUFFER
,
919 kServiceRenderbufferId
))
921 .RetiresOnSaturation();
922 EXPECT_EQ(error::kNoError
, ExecuteCmd(depth_cmd
));
923 EXPECT_EQ(error::kNoError
, ExecuteCmd(stencil_cmd
));
924 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
928 TEST_P(GLES2DecoderManualInitTest
, ActualAlphaMatchesRequestedAlpha
) {
930 init
.has_alpha
= true;
931 init
.request_alpha
= true;
932 init
.bind_generates_resource
= true;
935 EXPECT_CALL(*gl_
, GetError())
936 .WillOnce(Return(GL_NO_ERROR
))
937 .WillOnce(Return(GL_NO_ERROR
))
938 .RetiresOnSaturation();
939 typedef GetIntegerv::Result Result
;
940 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
941 EXPECT_CALL(*gl_
, GetIntegerv(GL_ALPHA_BITS
, _
))
942 .WillOnce(SetArgumentPointee
<1>(8))
943 .RetiresOnSaturation();
946 cmd2
.Init(GL_ALPHA_BITS
, shared_memory_id_
, shared_memory_offset_
);
947 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
948 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_ALPHA_BITS
),
949 result
->GetNumResults());
950 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
951 EXPECT_EQ(8, result
->GetData()[0]);
954 TEST_P(GLES2DecoderManualInitTest
, ActualAlphaDoesNotMatchRequestedAlpha
) {
956 init
.has_alpha
= true;
957 init
.bind_generates_resource
= true;
960 EXPECT_CALL(*gl_
, GetError())
961 .WillOnce(Return(GL_NO_ERROR
))
962 .WillOnce(Return(GL_NO_ERROR
))
963 .RetiresOnSaturation();
964 typedef GetIntegerv::Result Result
;
965 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
966 EXPECT_CALL(*gl_
, GetIntegerv(GL_ALPHA_BITS
, _
))
967 .WillOnce(SetArgumentPointee
<1>(8))
968 .RetiresOnSaturation();
971 cmd2
.Init(GL_ALPHA_BITS
, shared_memory_id_
, shared_memory_offset_
);
972 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
973 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_ALPHA_BITS
),
974 result
->GetNumResults());
975 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
976 EXPECT_EQ(0, result
->GetData()[0]);
979 TEST_P(GLES2DecoderManualInitTest
, ActualDepthMatchesRequestedDepth
) {
981 init
.has_depth
= true;
982 init
.request_depth
= true;
983 init
.bind_generates_resource
= true;
986 EXPECT_CALL(*gl_
, GetError())
987 .WillOnce(Return(GL_NO_ERROR
))
988 .WillOnce(Return(GL_NO_ERROR
))
989 .RetiresOnSaturation();
990 typedef GetIntegerv::Result Result
;
991 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
992 EXPECT_CALL(*gl_
, GetIntegerv(GL_DEPTH_BITS
, _
))
993 .WillOnce(SetArgumentPointee
<1>(24))
994 .RetiresOnSaturation();
997 cmd2
.Init(GL_DEPTH_BITS
, shared_memory_id_
, shared_memory_offset_
);
998 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
999 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS
),
1000 result
->GetNumResults());
1001 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1002 EXPECT_EQ(24, result
->GetData()[0]);
1005 TEST_P(GLES2DecoderManualInitTest
, ActualDepthDoesNotMatchRequestedDepth
) {
1007 init
.has_depth
= true;
1008 init
.bind_generates_resource
= true;
1011 EXPECT_CALL(*gl_
, GetError())
1012 .WillOnce(Return(GL_NO_ERROR
))
1013 .WillOnce(Return(GL_NO_ERROR
))
1014 .RetiresOnSaturation();
1015 typedef GetIntegerv::Result Result
;
1016 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
1017 EXPECT_CALL(*gl_
, GetIntegerv(GL_DEPTH_BITS
, _
))
1018 .WillOnce(SetArgumentPointee
<1>(24))
1019 .RetiresOnSaturation();
1022 cmd2
.Init(GL_DEPTH_BITS
, shared_memory_id_
, shared_memory_offset_
);
1023 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1024 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS
),
1025 result
->GetNumResults());
1026 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1027 EXPECT_EQ(0, result
->GetData()[0]);
1030 TEST_P(GLES2DecoderManualInitTest
, ActualStencilMatchesRequestedStencil
) {
1032 init
.has_stencil
= true;
1033 init
.request_stencil
= true;
1034 init
.bind_generates_resource
= true;
1037 EXPECT_CALL(*gl_
, GetError())
1038 .WillOnce(Return(GL_NO_ERROR
))
1039 .WillOnce(Return(GL_NO_ERROR
))
1040 .RetiresOnSaturation();
1041 typedef GetIntegerv::Result Result
;
1042 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
1043 EXPECT_CALL(*gl_
, GetIntegerv(GL_STENCIL_BITS
, _
))
1044 .WillOnce(SetArgumentPointee
<1>(8))
1045 .RetiresOnSaturation();
1048 cmd2
.Init(GL_STENCIL_BITS
, shared_memory_id_
, shared_memory_offset_
);
1049 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1050 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS
),
1051 result
->GetNumResults());
1052 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1053 EXPECT_EQ(8, result
->GetData()[0]);
1056 TEST_P(GLES2DecoderManualInitTest
, ActualStencilDoesNotMatchRequestedStencil
) {
1058 init
.has_stencil
= true;
1059 init
.bind_generates_resource
= true;
1062 EXPECT_CALL(*gl_
, GetError())
1063 .WillOnce(Return(GL_NO_ERROR
))
1064 .WillOnce(Return(GL_NO_ERROR
))
1065 .RetiresOnSaturation();
1066 typedef GetIntegerv::Result Result
;
1067 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
1068 EXPECT_CALL(*gl_
, GetIntegerv(GL_STENCIL_BITS
, _
))
1069 .WillOnce(SetArgumentPointee
<1>(8))
1070 .RetiresOnSaturation();
1073 cmd2
.Init(GL_STENCIL_BITS
, shared_memory_id_
, shared_memory_offset_
);
1074 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1075 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS
),
1076 result
->GetNumResults());
1077 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1078 EXPECT_EQ(0, result
->GetData()[0]);
1081 TEST_P(GLES2DecoderManualInitTest
, PackedDepthStencilReportsCorrectValues
) {
1083 init
.extensions
= "GL_OES_packed_depth_stencil";
1084 init
.gl_version
= "opengl es 2.0";
1085 init
.has_depth
= true;
1086 init
.has_stencil
= true;
1087 init
.request_depth
= true;
1088 init
.request_stencil
= true;
1089 init
.bind_generates_resource
= true;
1092 EXPECT_CALL(*gl_
, GetError())
1093 .WillOnce(Return(GL_NO_ERROR
))
1094 .WillOnce(Return(GL_NO_ERROR
))
1095 .WillOnce(Return(GL_NO_ERROR
))
1096 .WillOnce(Return(GL_NO_ERROR
))
1097 .RetiresOnSaturation();
1098 typedef GetIntegerv::Result Result
;
1099 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
1102 cmd2
.Init(GL_STENCIL_BITS
, shared_memory_id_
, shared_memory_offset_
);
1103 EXPECT_CALL(*gl_
, GetIntegerv(GL_STENCIL_BITS
, _
))
1104 .WillOnce(SetArgumentPointee
<1>(8))
1105 .RetiresOnSaturation();
1106 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1107 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS
),
1108 result
->GetNumResults());
1109 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1110 EXPECT_EQ(8, result
->GetData()[0]);
1112 cmd2
.Init(GL_DEPTH_BITS
, shared_memory_id_
, shared_memory_offset_
);
1113 EXPECT_CALL(*gl_
, GetIntegerv(GL_DEPTH_BITS
, _
))
1114 .WillOnce(SetArgumentPointee
<1>(24))
1115 .RetiresOnSaturation();
1116 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1117 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS
),
1118 result
->GetNumResults());
1119 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1120 EXPECT_EQ(24, result
->GetData()[0]);
1123 TEST_P(GLES2DecoderManualInitTest
, PackedDepthStencilNoRequestedStencil
) {
1125 init
.extensions
= "GL_OES_packed_depth_stencil";
1126 init
.gl_version
= "opengl es 2.0";
1127 init
.has_depth
= true;
1128 init
.has_stencil
= true;
1129 init
.request_depth
= true;
1130 init
.bind_generates_resource
= true;
1133 EXPECT_CALL(*gl_
, GetError())
1134 .WillOnce(Return(GL_NO_ERROR
))
1135 .WillOnce(Return(GL_NO_ERROR
))
1136 .WillOnce(Return(GL_NO_ERROR
))
1137 .WillOnce(Return(GL_NO_ERROR
))
1138 .RetiresOnSaturation();
1139 typedef GetIntegerv::Result Result
;
1140 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
1143 cmd2
.Init(GL_STENCIL_BITS
, shared_memory_id_
, shared_memory_offset_
);
1144 EXPECT_CALL(*gl_
, GetIntegerv(GL_STENCIL_BITS
, _
))
1145 .WillOnce(SetArgumentPointee
<1>(8))
1146 .RetiresOnSaturation();
1147 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1148 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS
),
1149 result
->GetNumResults());
1150 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1151 EXPECT_EQ(0, result
->GetData()[0]);
1153 cmd2
.Init(GL_DEPTH_BITS
, shared_memory_id_
, shared_memory_offset_
);
1154 EXPECT_CALL(*gl_
, GetIntegerv(GL_DEPTH_BITS
, _
))
1155 .WillOnce(SetArgumentPointee
<1>(24))
1156 .RetiresOnSaturation();
1157 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1158 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS
),
1159 result
->GetNumResults());
1160 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1161 EXPECT_EQ(24, result
->GetData()[0]);
1164 TEST_P(GLES2DecoderManualInitTest
, PackedDepthStencilRenderbufferDepth
) {
1166 init
.extensions
= "GL_OES_packed_depth_stencil";
1167 init
.gl_version
= "opengl es 2.0";
1168 init
.bind_generates_resource
= true;
1171 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1173 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
1175 EnsureRenderbufferBound(false);
1176 EXPECT_CALL(*gl_
, GetError())
1177 .WillOnce(Return(GL_NO_ERROR
)) // for RenderbufferStoage
1178 .WillOnce(Return(GL_NO_ERROR
))
1179 .WillOnce(Return(GL_NO_ERROR
)) // for FramebufferRenderbuffer
1180 .WillOnce(Return(GL_NO_ERROR
))
1181 .WillOnce(Return(GL_NO_ERROR
)) // for GetIntegerv
1182 .WillOnce(Return(GL_NO_ERROR
))
1183 .WillOnce(Return(GL_NO_ERROR
)) // for GetIntegerv
1184 .WillOnce(Return(GL_NO_ERROR
))
1185 .RetiresOnSaturation();
1189 RenderbufferStorageEXT(GL_RENDERBUFFER
, GL_DEPTH24_STENCIL8
, 100, 50))
1191 .RetiresOnSaturation();
1192 RenderbufferStorage cmd
;
1193 cmd
.Init(GL_RENDERBUFFER
, GL_DEPTH24_STENCIL8
, 100, 50);
1194 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1196 FramebufferRenderbufferEXT(GL_FRAMEBUFFER
,
1197 GL_DEPTH_ATTACHMENT
,
1199 kServiceRenderbufferId
))
1201 .RetiresOnSaturation();
1202 FramebufferRenderbuffer fbrb_cmd
;
1203 fbrb_cmd
.Init(GL_FRAMEBUFFER
,
1204 GL_DEPTH_ATTACHMENT
,
1206 client_renderbuffer_id_
);
1207 EXPECT_EQ(error::kNoError
, ExecuteCmd(fbrb_cmd
));
1209 typedef GetIntegerv::Result Result
;
1210 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
1213 cmd2
.Init(GL_STENCIL_BITS
, shared_memory_id_
, shared_memory_offset_
);
1214 EXPECT_CALL(*gl_
, GetIntegerv(GL_STENCIL_BITS
, _
))
1215 .WillOnce(SetArgumentPointee
<1>(8))
1216 .RetiresOnSaturation();
1217 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1218 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS
),
1219 result
->GetNumResults());
1220 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1221 EXPECT_EQ(0, result
->GetData()[0]);
1223 cmd2
.Init(GL_DEPTH_BITS
, shared_memory_id_
, shared_memory_offset_
);
1224 EXPECT_CALL(*gl_
, GetIntegerv(GL_DEPTH_BITS
, _
))
1225 .WillOnce(SetArgumentPointee
<1>(24))
1226 .RetiresOnSaturation();
1227 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1228 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS
),
1229 result
->GetNumResults());
1230 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1231 EXPECT_EQ(24, result
->GetData()[0]);
1234 TEST_P(GLES2DecoderManualInitTest
, PackedDepthStencilRenderbufferStencil
) {
1236 init
.extensions
= "GL_OES_packed_depth_stencil";
1237 init
.gl_version
= "opengl es 2.0";
1238 init
.bind_generates_resource
= true;
1241 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1243 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
1245 EnsureRenderbufferBound(false);
1246 EXPECT_CALL(*gl_
, GetError())
1247 .WillOnce(Return(GL_NO_ERROR
)) // for RenderbufferStoage
1248 .WillOnce(Return(GL_NO_ERROR
))
1249 .WillOnce(Return(GL_NO_ERROR
)) // for FramebufferRenderbuffer
1250 .WillOnce(Return(GL_NO_ERROR
))
1251 .WillOnce(Return(GL_NO_ERROR
)) // for GetIntegerv
1252 .WillOnce(Return(GL_NO_ERROR
))
1253 .WillOnce(Return(GL_NO_ERROR
)) // for GetIntegerv
1254 .WillOnce(Return(GL_NO_ERROR
))
1255 .RetiresOnSaturation();
1259 RenderbufferStorageEXT(GL_RENDERBUFFER
, GL_DEPTH24_STENCIL8
, 100, 50))
1261 .RetiresOnSaturation();
1262 RenderbufferStorage cmd
;
1263 cmd
.Init(GL_RENDERBUFFER
, GL_DEPTH24_STENCIL8
, 100, 50);
1264 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1266 FramebufferRenderbufferEXT(GL_FRAMEBUFFER
,
1267 GL_STENCIL_ATTACHMENT
,
1269 kServiceRenderbufferId
))
1271 .RetiresOnSaturation();
1272 FramebufferRenderbuffer fbrb_cmd
;
1273 fbrb_cmd
.Init(GL_FRAMEBUFFER
,
1274 GL_STENCIL_ATTACHMENT
,
1276 client_renderbuffer_id_
);
1277 EXPECT_EQ(error::kNoError
, ExecuteCmd(fbrb_cmd
));
1279 typedef GetIntegerv::Result Result
;
1280 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
1283 cmd2
.Init(GL_STENCIL_BITS
, shared_memory_id_
, shared_memory_offset_
);
1284 EXPECT_CALL(*gl_
, GetIntegerv(GL_STENCIL_BITS
, _
))
1285 .WillOnce(SetArgumentPointee
<1>(8))
1286 .RetiresOnSaturation();
1287 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1288 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS
),
1289 result
->GetNumResults());
1290 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1291 EXPECT_EQ(8, result
->GetData()[0]);
1293 cmd2
.Init(GL_DEPTH_BITS
, shared_memory_id_
, shared_memory_offset_
);
1294 EXPECT_CALL(*gl_
, GetIntegerv(GL_DEPTH_BITS
, _
))
1295 .WillOnce(SetArgumentPointee
<1>(24))
1296 .RetiresOnSaturation();
1297 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1298 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS
),
1299 result
->GetNumResults());
1300 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1301 EXPECT_EQ(0, result
->GetData()[0]);
1304 TEST_P(GLES2DecoderTest
, FramebufferRenderbufferGLError
) {
1306 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
1307 EXPECT_CALL(*gl_
, GetError())
1308 .WillOnce(Return(GL_NO_ERROR
))
1309 .WillOnce(Return(GL_OUT_OF_MEMORY
))
1310 .RetiresOnSaturation();
1312 FramebufferRenderbufferEXT(GL_FRAMEBUFFER
,
1313 GL_COLOR_ATTACHMENT0
,
1315 kServiceRenderbufferId
))
1317 .RetiresOnSaturation();
1318 FramebufferRenderbuffer cmd
;
1319 cmd
.Init(GL_FRAMEBUFFER
,
1320 GL_COLOR_ATTACHMENT0
,
1322 client_renderbuffer_id_
);
1323 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1324 EXPECT_EQ(GL_OUT_OF_MEMORY
, GetGLError());
1327 TEST_P(GLES2DecoderTest
, FramebufferTexture2DGLError
) {
1328 const GLsizei kWidth
= 5;
1329 const GLsizei kHeight
= 3;
1330 const GLenum kFormat
= GL_RGB
;
1331 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1332 DoTexImage2D(GL_TEXTURE_2D
,
1343 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
1344 EXPECT_CALL(*gl_
, GetError())
1345 .WillOnce(Return(GL_NO_ERROR
))
1346 .WillOnce(Return(GL_OUT_OF_MEMORY
))
1347 .RetiresOnSaturation();
1349 FramebufferTexture2DEXT(GL_FRAMEBUFFER
,
1350 GL_COLOR_ATTACHMENT0
,
1355 .RetiresOnSaturation();
1356 FramebufferTexture2D fbtex_cmd
;
1357 fbtex_cmd
.Init(GL_FRAMEBUFFER
,
1358 GL_COLOR_ATTACHMENT0
,
1360 client_texture_id_
);
1361 EXPECT_EQ(error::kNoError
, ExecuteCmd(fbtex_cmd
));
1362 EXPECT_EQ(GL_OUT_OF_MEMORY
, GetGLError());
1365 TEST_P(GLES2DecoderTest
, RenderbufferStorageGLError
) {
1367 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1368 EnsureRenderbufferBound(false);
1369 EXPECT_CALL(*gl_
, GetError())
1370 .WillOnce(Return(GL_NO_ERROR
))
1371 .WillOnce(Return(GL_OUT_OF_MEMORY
))
1372 .RetiresOnSaturation();
1373 EXPECT_CALL(*gl_
, RenderbufferStorageEXT(GL_RENDERBUFFER
, GL_RGBA
, 100, 50))
1375 .RetiresOnSaturation();
1376 RenderbufferStorage cmd
;
1377 cmd
.Init(GL_RENDERBUFFER
, GL_RGBA4
, 100, 50);
1378 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1379 EXPECT_EQ(GL_OUT_OF_MEMORY
, GetGLError());
1382 TEST_P(GLES2DecoderTest
, RenderbufferStorageBadArgs
) {
1384 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1385 EXPECT_CALL(*gl_
, RenderbufferStorageEXT(_
, _
, _
, _
))
1387 .RetiresOnSaturation();
1388 RenderbufferStorage cmd
;
1389 cmd
.Init(GL_RENDERBUFFER
, GL_RGBA4
, TestHelper::kMaxRenderbufferSize
+ 1, 1);
1390 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1391 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1392 cmd
.Init(GL_RENDERBUFFER
, GL_RGBA4
, 1, TestHelper::kMaxRenderbufferSize
+ 1);
1393 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1394 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1397 TEST_P(GLES2DecoderManualInitTest
,
1398 RenderbufferStorageMultisampleCHROMIUMGLError
) {
1400 init
.extensions
= "GL_EXT_framebuffer_multisample";
1401 init
.bind_generates_resource
= true;
1404 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1405 EnsureRenderbufferBound(false);
1406 EXPECT_CALL(*gl_
, GetError())
1407 .WillOnce(Return(GL_NO_ERROR
))
1408 .WillOnce(Return(GL_OUT_OF_MEMORY
))
1409 .RetiresOnSaturation();
1412 RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER
, 1, GL_RGBA
, 100, 50))
1414 .RetiresOnSaturation();
1415 RenderbufferStorageMultisampleCHROMIUM cmd
;
1416 cmd
.Init(GL_RENDERBUFFER
, 1, GL_RGBA4
, 100, 50);
1417 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1418 EXPECT_EQ(GL_OUT_OF_MEMORY
, GetGLError());
1421 TEST_P(GLES2DecoderManualInitTest
,
1422 RenderbufferStorageMultisampleCHROMIUMBadArgs
) {
1424 init
.extensions
= "GL_EXT_framebuffer_multisample";
1425 init
.bind_generates_resource
= true;
1428 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1429 EXPECT_CALL(*gl_
, RenderbufferStorageMultisampleEXT(_
, _
, _
, _
, _
))
1431 .RetiresOnSaturation();
1432 RenderbufferStorageMultisampleCHROMIUM cmd
;
1433 cmd
.Init(GL_RENDERBUFFER
,
1434 TestHelper::kMaxSamples
+ 1,
1436 TestHelper::kMaxRenderbufferSize
,
1438 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1439 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1440 cmd
.Init(GL_RENDERBUFFER
,
1441 TestHelper::kMaxSamples
,
1443 TestHelper::kMaxRenderbufferSize
+ 1,
1445 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1446 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1447 cmd
.Init(GL_RENDERBUFFER
,
1448 TestHelper::kMaxSamples
,
1451 TestHelper::kMaxRenderbufferSize
+ 1);
1452 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1453 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1456 TEST_P(GLES2DecoderManualInitTest
, RenderbufferStorageMultisampleCHROMIUM
) {
1458 init
.extensions
= "GL_EXT_framebuffer_multisample";
1461 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1462 InSequence sequence
;
1463 EnsureRenderbufferBound(false);
1464 DoRenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER
,
1465 TestHelper::kMaxSamples
,
1468 TestHelper::kMaxRenderbufferSize
,
1472 TEST_P(GLES2DecoderManualInitTest
,
1473 RenderbufferStorageMultisampleCHROMIUMRebindRenderbuffer
) {
1475 init
.extensions
= "GL_EXT_framebuffer_multisample";
1478 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1479 RestoreRenderbufferBindings();
1480 InSequence sequence
;
1481 EnsureRenderbufferBound(true);
1482 DoRenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER
,
1483 TestHelper::kMaxSamples
,
1486 TestHelper::kMaxRenderbufferSize
,
1490 TEST_P(GLES2DecoderManualInitTest
,
1491 RenderbufferStorageMultisampleEXTNotSupported
) {
1493 init
.extensions
= "GL_EXT_framebuffer_multisample";
1494 init
.bind_generates_resource
= true;
1497 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1498 InSequence sequence
;
1499 // GL_EXT_framebuffer_multisample uses RenderbufferStorageMultisampleCHROMIUM.
1500 RenderbufferStorageMultisampleEXT cmd
;
1501 cmd
.Init(GL_RENDERBUFFER
,
1502 TestHelper::kMaxSamples
,
1504 TestHelper::kMaxRenderbufferSize
,
1506 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1507 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1510 class GLES2DecoderMultisampledRenderToTextureTest
1511 : public GLES2DecoderTestWithExtensionsOnGLES2
{
1513 void TestNotCompatibleWithRenderbufferStorageMultisampleCHROMIUM() {
1515 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1516 RenderbufferStorageMultisampleCHROMIUM cmd
;
1517 cmd
.Init(GL_RENDERBUFFER
,
1518 TestHelper::kMaxSamples
,
1520 TestHelper::kMaxRenderbufferSize
,
1522 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1523 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1526 void TestRenderbufferStorageMultisampleEXT(const char* extension
,
1529 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1530 InSequence sequence
;
1532 RestoreRenderbufferBindings();
1533 EnsureRenderbufferBound(true);
1535 EnsureRenderbufferBound(false);
1538 EXPECT_CALL(*gl_
, GetError())
1539 .WillOnce(Return(GL_NO_ERROR
))
1540 .RetiresOnSaturation();
1541 if (strstr(extension
, "GL_IMG_multisampled_render_to_texture")) {
1544 RenderbufferStorageMultisampleIMG(GL_RENDERBUFFER
,
1545 TestHelper::kMaxSamples
,
1547 TestHelper::kMaxRenderbufferSize
,
1550 .RetiresOnSaturation();
1554 RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER
,
1555 TestHelper::kMaxSamples
,
1557 TestHelper::kMaxRenderbufferSize
,
1560 .RetiresOnSaturation();
1562 EXPECT_CALL(*gl_
, GetError())
1563 .WillOnce(Return(GL_NO_ERROR
))
1564 .RetiresOnSaturation();
1565 RenderbufferStorageMultisampleEXT cmd
;
1566 cmd
.Init(GL_RENDERBUFFER
,
1567 TestHelper::kMaxSamples
,
1569 TestHelper::kMaxRenderbufferSize
,
1571 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1572 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1576 INSTANTIATE_TEST_CASE_P(Service
,
1577 GLES2DecoderMultisampledRenderToTextureTest
,
1580 TEST_P(GLES2DecoderMultisampledRenderToTextureTest
,
1581 NotCompatibleWithRenderbufferStorageMultisampleCHROMIUM_EXT
) {
1582 Init("GL_EXT_multisampled_render_to_texture");
1583 TestNotCompatibleWithRenderbufferStorageMultisampleCHROMIUM();
1586 TEST_P(GLES2DecoderMultisampledRenderToTextureTest
,
1587 NotCompatibleWithRenderbufferStorageMultisampleCHROMIUM_IMG
) {
1588 Init("GL_IMG_multisampled_render_to_texture");
1589 TestNotCompatibleWithRenderbufferStorageMultisampleCHROMIUM();
1592 TEST_P(GLES2DecoderMultisampledRenderToTextureTest
,
1593 RenderbufferStorageMultisampleEXT_EXT
) {
1594 Init("GL_EXT_multisampled_render_to_texture");
1595 TestRenderbufferStorageMultisampleEXT("GL_EXT_multisampled_render_to_texture",
1599 TEST_P(GLES2DecoderMultisampledRenderToTextureTest
,
1600 RenderbufferStorageMultisampleEXT_IMG
) {
1601 Init("GL_IMG_multisampled_render_to_texture");
1602 TestRenderbufferStorageMultisampleEXT("GL_IMG_multisampled_render_to_texture",
1606 TEST_P(GLES2DecoderMultisampledRenderToTextureTest
,
1607 RenderbufferStorageMultisampleEXT_EXT_RebindRenderbuffer
) {
1608 Init("GL_EXT_multisampled_render_to_texture");
1609 TestRenderbufferStorageMultisampleEXT("GL_EXT_multisampled_render_to_texture",
1613 TEST_P(GLES2DecoderMultisampledRenderToTextureTest
,
1614 RenderbufferStorageMultisampleEXT_IMG_RebindRenderbuffer
) {
1615 Init("GL_IMG_multisampled_render_to_texture");
1616 TestRenderbufferStorageMultisampleEXT("GL_IMG_multisampled_render_to_texture",
1620 TEST_P(GLES2DecoderTest
, ReadPixelsGLError
) {
1621 GLenum kFormat
= GL_RGBA
;
1626 typedef ReadPixels::Result Result
;
1627 uint32 result_shm_id
= kSharedMemoryId
;
1628 uint32 result_shm_offset
= kSharedMemoryOffset
;
1629 uint32 pixels_shm_id
= kSharedMemoryId
;
1630 uint32 pixels_shm_offset
= kSharedMemoryOffset
+ sizeof(Result
);
1631 EXPECT_CALL(*gl_
, GetError())
1632 .WillOnce(Return(GL_NO_ERROR
))
1633 .WillOnce(Return(GL_OUT_OF_MEMORY
))
1634 .RetiresOnSaturation();
1636 ReadPixels(x
, y
, width
, height
, kFormat
, GL_UNSIGNED_BYTE
, _
))
1638 .RetiresOnSaturation();
1651 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1652 EXPECT_EQ(GL_OUT_OF_MEMORY
, GetGLError());
1655 TEST_P(GLES2DecoderWithShaderTest
, UnClearedAttachmentsGetClearedOnClear
) {
1656 const GLuint kFBOClientTextureId
= 4100;
1657 const GLuint kFBOServiceTextureId
= 4101;
1659 // Register a texture id.
1660 EXPECT_CALL(*gl_
, GenTextures(_
, _
))
1661 .WillOnce(SetArgumentPointee
<1>(kFBOServiceTextureId
))
1662 .RetiresOnSaturation();
1663 GenHelper
<GenTexturesImmediate
>(kFBOClientTextureId
);
1665 // Setup "render to" texture.
1666 DoBindTexture(GL_TEXTURE_2D
, kFBOClientTextureId
, kFBOServiceTextureId
);
1668 GL_TEXTURE_2D
, 0, GL_RGBA
, 1, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1670 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
1671 DoFramebufferTexture2D(GL_FRAMEBUFFER
,
1672 GL_COLOR_ATTACHMENT0
,
1674 kFBOClientTextureId
,
1675 kFBOServiceTextureId
,
1679 // Setup "render from" texture.
1682 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER
, // target
1683 GL_COLOR_BUFFER_BIT
, // clear bits
1690 false); // scissor test
1691 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB
1692 false, // Framebuffer has depth
1693 false, // Framebuffer has stencil
1694 0x1111, // color bits
1695 false, // depth mask
1696 false, // depth enabled
1697 0, // front stencil mask
1698 0, // back stencil mask
1699 false); // stencil enabled
1701 EXPECT_CALL(*gl_
, Clear(GL_COLOR_BUFFER_BIT
)).Times(1).RetiresOnSaturation();
1704 cmd
.Init(GL_COLOR_BUFFER_BIT
);
1705 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1706 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1709 TEST_P(GLES2DecoderWithShaderTest
, UnClearedAttachmentsGetClearedOnReadPixels
) {
1710 const GLuint kFBOClientTextureId
= 4100;
1711 const GLuint kFBOServiceTextureId
= 4101;
1713 // Register a texture id.
1714 EXPECT_CALL(*gl_
, GenTextures(_
, _
))
1715 .WillOnce(SetArgumentPointee
<1>(kFBOServiceTextureId
))
1716 .RetiresOnSaturation();
1717 GenHelper
<GenTexturesImmediate
>(kFBOClientTextureId
);
1719 // Setup "render to" texture.
1720 DoBindTexture(GL_TEXTURE_2D
, kFBOClientTextureId
, kFBOServiceTextureId
);
1722 GL_TEXTURE_2D
, 0, GL_RGBA
, 1, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1724 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
1725 DoFramebufferTexture2D(GL_FRAMEBUFFER
,
1726 GL_COLOR_ATTACHMENT0
,
1728 kFBOClientTextureId
,
1729 kFBOServiceTextureId
,
1733 // Setup "render from" texture.
1736 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER
, // target
1737 GL_COLOR_BUFFER_BIT
, // clear bits
1744 false); // scissor test
1746 EXPECT_CALL(*gl_
, GetError())
1747 .WillOnce(Return(GL_NO_ERROR
))
1748 .WillOnce(Return(GL_NO_ERROR
))
1749 .RetiresOnSaturation();
1750 EXPECT_CALL(*gl_
, ReadPixels(0, 0, 1, 1, GL_RGBA
, GL_UNSIGNED_BYTE
, _
))
1752 .RetiresOnSaturation();
1753 typedef ReadPixels::Result Result
;
1754 uint32 result_shm_id
= kSharedMemoryId
;
1755 uint32 result_shm_offset
= kSharedMemoryOffset
;
1756 uint32 pixels_shm_id
= kSharedMemoryId
;
1757 uint32 pixels_shm_offset
= kSharedMemoryOffset
+ sizeof(Result
);
1770 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1771 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1774 TEST_P(GLES2DecoderManualInitTest
,
1775 UnClearedAttachmentsGetClearedOnReadPixelsAndDrawBufferGetsRestored
) {
1777 init
.extensions
= "GL_EXT_framebuffer_multisample";
1778 init
.bind_generates_resource
= true;
1780 const GLuint kFBOClientTextureId
= 4100;
1781 const GLuint kFBOServiceTextureId
= 4101;
1783 // Register a texture id.
1784 EXPECT_CALL(*gl_
, GenTextures(_
, _
))
1785 .WillOnce(SetArgumentPointee
<1>(kFBOServiceTextureId
))
1786 .RetiresOnSaturation();
1787 GenHelper
<GenTexturesImmediate
>(kFBOClientTextureId
);
1789 // Setup "render from" texture.
1790 DoBindTexture(GL_TEXTURE_2D
, kFBOClientTextureId
, kFBOServiceTextureId
);
1792 GL_TEXTURE_2D
, 0, GL_RGBA
, 1, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1794 GL_READ_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
1795 DoFramebufferTexture2D(GL_READ_FRAMEBUFFER
,
1796 GL_COLOR_ATTACHMENT0
,
1798 kFBOClientTextureId
,
1799 kFBOServiceTextureId
,
1803 // Enable GL_SCISSOR_TEST to make sure we disable it in the clear,
1804 // then re-enable after.
1805 DoEnableDisable(GL_SCISSOR_TEST
, true);
1807 SetupExpectationsForFramebufferClearingMulti(
1808 kServiceFramebufferId
, // read framebuffer service id
1809 0, // backbuffer service id
1810 GL_READ_FRAMEBUFFER
, // target
1811 GL_COLOR_BUFFER_BIT
, // clear bits
1818 true); // scissor test
1820 EXPECT_CALL(*gl_
, GetError())
1821 .WillOnce(Return(GL_NO_ERROR
))
1822 .WillOnce(Return(GL_NO_ERROR
))
1823 .RetiresOnSaturation();
1824 EXPECT_CALL(*gl_
, ReadPixels(0, 0, 1, 1, GL_RGBA
, GL_UNSIGNED_BYTE
, _
))
1826 .RetiresOnSaturation();
1827 typedef ReadPixels::Result Result
;
1828 uint32 result_shm_id
= kSharedMemoryId
;
1829 uint32 result_shm_offset
= kSharedMemoryOffset
;
1830 uint32 pixels_shm_id
= kSharedMemoryId
;
1831 uint32 pixels_shm_offset
= kSharedMemoryOffset
+ sizeof(Result
);
1844 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1845 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1848 TEST_P(GLES2DecoderWithShaderTest
, CopyTexImageWithInCompleteFBOFails
) {
1849 GLenum target
= GL_TEXTURE_2D
;
1851 GLenum internal_format
= GL_RGBA
;
1856 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1858 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
1859 DoRenderbufferStorage(GL_RENDERBUFFER
, GL_RGBA4
, GL_RGBA
, 0, 0, GL_NO_ERROR
);
1860 DoFramebufferRenderbuffer(GL_FRAMEBUFFER
,
1861 GL_COLOR_ATTACHMENT0
,
1863 client_renderbuffer_id_
,
1864 kServiceRenderbufferId
,
1867 EXPECT_CALL(*gl_
, CopyTexImage2D(_
, _
, _
, _
, _
, _
, _
, _
))
1869 .RetiresOnSaturation();
1871 cmd
.Init(target
, level
, internal_format
, 0, 0, width
, height
);
1872 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1873 EXPECT_EQ(GL_INVALID_FRAMEBUFFER_OPERATION
, GetGLError());
1876 void GLES2DecoderWithShaderTest::CheckRenderbufferChangesMarkFBOAsNotComplete(
1878 FramebufferManager
* framebuffer_manager
= group().framebuffer_manager();
1881 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1883 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
1884 DoRenderbufferStorage(GL_RENDERBUFFER
, GL_RGBA4
, GL_RGBA
, 1, 1, GL_NO_ERROR
);
1885 DoFramebufferRenderbuffer(GL_FRAMEBUFFER
,
1886 GL_COLOR_ATTACHMENT0
,
1888 client_renderbuffer_id_
,
1889 kServiceRenderbufferId
,
1893 DoBindFramebuffer(GL_FRAMEBUFFER
, 0, 0);
1896 Framebuffer
* framebuffer
=
1897 framebuffer_manager
->GetFramebuffer(client_framebuffer_id_
);
1898 ASSERT_TRUE(framebuffer
!= NULL
);
1899 framebuffer_manager
->MarkAsComplete(framebuffer
);
1900 EXPECT_TRUE(framebuffer_manager
->IsComplete(framebuffer
));
1902 // Test that renderbufferStorage marks fbo as not complete.
1903 DoRenderbufferStorage(GL_RENDERBUFFER
, GL_RGBA4
, GL_RGBA
, 1, 1, GL_NO_ERROR
);
1904 EXPECT_FALSE(framebuffer_manager
->IsComplete(framebuffer
));
1905 framebuffer_manager
->MarkAsComplete(framebuffer
);
1906 EXPECT_TRUE(framebuffer_manager
->IsComplete(framebuffer
));
1908 // Test deleting renderbuffer marks fbo as not complete.
1909 DoDeleteRenderbuffer(client_renderbuffer_id_
, kServiceRenderbufferId
);
1911 EXPECT_FALSE(framebuffer_manager
->IsComplete(framebuffer
));
1913 EXPECT_TRUE(framebuffer_manager
->IsComplete(framebuffer
));
1916 DoDeleteFramebuffer(client_framebuffer_id_
,
1917 kServiceFramebufferId
,
1926 TEST_P(GLES2DecoderWithShaderTest
,
1927 RenderbufferChangesMarkFBOAsNotCompleteBoundFBO
) {
1928 CheckRenderbufferChangesMarkFBOAsNotComplete(true);
1931 TEST_P(GLES2DecoderWithShaderTest
,
1932 RenderbufferChangesMarkFBOAsNotCompleteUnboundFBO
) {
1933 CheckRenderbufferChangesMarkFBOAsNotComplete(false);
1936 void GLES2DecoderWithShaderTest::CheckTextureChangesMarkFBOAsNotComplete(
1938 FramebufferManager
* framebuffer_manager
= group().framebuffer_manager();
1939 const GLuint kFBOClientTextureId
= 4100;
1940 const GLuint kFBOServiceTextureId
= 4101;
1942 // Register a texture id.
1943 EXPECT_CALL(*gl_
, GenTextures(_
, _
))
1944 .WillOnce(SetArgumentPointee
<1>(kFBOServiceTextureId
))
1945 .RetiresOnSaturation();
1946 GenHelper
<GenTexturesImmediate
>(kFBOClientTextureId
);
1950 // Setup "render to" texture.
1951 DoBindTexture(GL_TEXTURE_2D
, kFBOClientTextureId
, kFBOServiceTextureId
);
1953 GL_TEXTURE_2D
, 0, GL_RGBA
, 1, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1955 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
1956 DoFramebufferTexture2D(GL_FRAMEBUFFER
,
1957 GL_COLOR_ATTACHMENT0
,
1959 kFBOClientTextureId
,
1960 kFBOServiceTextureId
,
1965 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
1967 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
1968 DoRenderbufferStorage(GL_RENDERBUFFER
,
1969 GL_DEPTH_COMPONENT16
,
1974 DoFramebufferRenderbuffer(GL_FRAMEBUFFER
,
1975 GL_DEPTH_ATTACHMENT
,
1977 client_renderbuffer_id_
,
1978 kServiceRenderbufferId
,
1982 DoBindFramebuffer(GL_FRAMEBUFFER
, 0, 0);
1985 Framebuffer
* framebuffer
=
1986 framebuffer_manager
->GetFramebuffer(client_framebuffer_id_
);
1987 ASSERT_TRUE(framebuffer
!= NULL
);
1988 framebuffer_manager
->MarkAsComplete(framebuffer
);
1989 EXPECT_TRUE(framebuffer_manager
->IsComplete(framebuffer
));
1991 // Test TexImage2D marks fbo as not complete.
1993 GL_TEXTURE_2D
, 0, GL_RGB
, 1, 1, 0, GL_RGB
, GL_UNSIGNED_BYTE
, 0, 0);
1994 EXPECT_FALSE(framebuffer_manager
->IsComplete(framebuffer
));
1995 framebuffer_manager
->MarkAsComplete(framebuffer
);
1996 EXPECT_TRUE(framebuffer_manager
->IsComplete(framebuffer
));
1998 // Test CopyImage2D marks fbo as not complete.
1999 EXPECT_CALL(*gl_
, GetError())
2000 .WillOnce(Return(GL_NO_ERROR
))
2001 .RetiresOnSaturation();
2002 EXPECT_CALL(*gl_
, CopyTexImage2D(GL_TEXTURE_2D
, 0, GL_RGB
, 0, 0, 1, 1, 0))
2004 .RetiresOnSaturation();
2005 EXPECT_CALL(*gl_
, GetError())
2006 .WillOnce(Return(GL_NO_ERROR
))
2007 .RetiresOnSaturation();
2009 cmd
.Init(GL_TEXTURE_2D
, 0, GL_RGB
, 0, 0, 1, 1);
2010 // Unbind fbo and bind again after CopyTexImage2D tp avoid feedback loops.
2012 DoBindFramebuffer(GL_FRAMEBUFFER
, 0, 0);
2014 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2017 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
2019 EXPECT_FALSE(framebuffer_manager
->IsComplete(framebuffer
));
2021 // Test deleting texture marks fbo as not complete.
2022 framebuffer_manager
->MarkAsComplete(framebuffer
);
2023 EXPECT_TRUE(framebuffer_manager
->IsComplete(framebuffer
));
2024 DoDeleteTexture(kFBOClientTextureId
, kFBOServiceTextureId
);
2027 EXPECT_FALSE(framebuffer_manager
->IsComplete(framebuffer
));
2029 EXPECT_TRUE(framebuffer_manager
->IsComplete(framebuffer
));
2032 DoDeleteFramebuffer(client_framebuffer_id_
,
2033 kServiceFramebufferId
,
2042 TEST_P(GLES2DecoderWithShaderTest
, TextureChangesMarkFBOAsNotCompleteBoundFBO
) {
2043 CheckTextureChangesMarkFBOAsNotComplete(true);
2046 TEST_P(GLES2DecoderWithShaderTest
,
2047 TextureChangesMarkFBOAsNotCompleteUnboundFBO
) {
2048 CheckTextureChangesMarkFBOAsNotComplete(false);
2051 TEST_P(GLES2DecoderTest
, CanChangeSurface
) {
2052 scoped_refptr
<GLSurfaceMock
> other_surface(new GLSurfaceMock
);
2053 EXPECT_CALL(*other_surface
.get(), GetBackingFrameBufferObject())
2054 .WillOnce(Return(7));
2055 EXPECT_CALL(*gl_
, BindFramebufferEXT(GL_FRAMEBUFFER_EXT
, 7));
2057 decoder_
->SetSurface(other_surface
);
2060 TEST_P(GLES2DecoderTest
, DrawBuffersEXTImmediateSuccceeds
) {
2061 const GLsizei count
= 1;
2062 const GLenum bufs
[] = {GL_COLOR_ATTACHMENT0
};
2063 DrawBuffersEXTImmediate
& cmd
= *GetImmediateAs
<DrawBuffersEXTImmediate
>();
2064 cmd
.Init(count
, bufs
);
2067 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
2068 EXPECT_CALL(*gl_
, DrawBuffersARB(count
, _
)).Times(1).RetiresOnSaturation();
2069 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(bufs
)));
2070 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2073 TEST_P(GLES2DecoderTest
, DrawBuffersEXTImmediateFails
) {
2074 const GLsizei count
= 1;
2075 const GLenum bufs
[] = {GL_COLOR_ATTACHMENT1_EXT
};
2076 DrawBuffersEXTImmediate
& cmd
= *GetImmediateAs
<DrawBuffersEXTImmediate
>();
2077 cmd
.Init(count
, bufs
);
2080 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
2081 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(bufs
)));
2082 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
2085 TEST_P(GLES2DecoderTest
, DrawBuffersEXTImmediateBackbuffer
) {
2086 const GLsizei count
= 1;
2087 const GLenum bufs
[] = {GL_BACK
};
2088 DrawBuffersEXTImmediate
& cmd
= *GetImmediateAs
<DrawBuffersEXTImmediate
>();
2089 cmd
.Init(count
, bufs
);
2092 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
2093 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(bufs
)));
2094 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
2096 DoBindFramebuffer(GL_FRAMEBUFFER
, 0, 0); // unbind
2098 EXPECT_CALL(*gl_
, DrawBuffersARB(count
, _
)).Times(1).RetiresOnSaturation();
2100 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(bufs
)));
2101 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2104 TEST_P(GLES2DecoderManualInitTest
, InvalidateFramebufferBinding
) {
2106 init
.gl_version
= "opengl es 3.0";
2109 // EXPECT_EQ can't be used to compare function pointers
2111 gfx::MockGLInterface::GetGLProcAddress("glInvalidateFramebuffer") !=
2112 gfx::g_driver_gl
.fn
.glDiscardFramebufferEXTFn
);
2114 gfx::MockGLInterface::GetGLProcAddress("glInvalidateFramebuffer") !=
2115 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT"));
2118 TEST_P(GLES2DecoderManualInitTest
, DiscardFramebufferEXT
) {
2120 init
.extensions
= "GL_EXT_discard_framebuffer";
2121 init
.gl_version
= "opengl es 2.0";
2124 // EXPECT_EQ can't be used to compare function pointers
2126 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT") ==
2127 gfx::g_driver_gl
.fn
.glDiscardFramebufferEXTFn
);
2129 const GLenum target
= GL_FRAMEBUFFER
;
2130 const GLsizei count
= 1;
2131 const GLenum attachments
[] = {GL_COLOR_ATTACHMENT0
};
2135 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
2136 DoFramebufferTexture2D(GL_FRAMEBUFFER
,
2137 GL_COLOR_ATTACHMENT0
,
2143 FramebufferManager
* framebuffer_manager
= group().framebuffer_manager();
2144 Framebuffer
* framebuffer
=
2145 framebuffer_manager
->GetFramebuffer(client_framebuffer_id_
);
2146 EXPECT_TRUE(framebuffer
->IsCleared());
2148 EXPECT_CALL(*gl_
, DiscardFramebufferEXT(target
, count
, _
))
2150 .RetiresOnSaturation();
2151 DiscardFramebufferEXTImmediate
& cmd
=
2152 *GetImmediateAs
<DiscardFramebufferEXTImmediate
>();
2153 cmd
.Init(target
, count
, attachments
);
2155 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(attachments
)));
2156 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2157 EXPECT_FALSE(framebuffer
->IsCleared());
2160 TEST_P(GLES2DecoderTest
, DiscardFramebufferEXTUnsupported
) {
2161 const GLenum target
= GL_FRAMEBUFFER
;
2162 const GLsizei count
= 1;
2163 const GLenum attachments
[] = {GL_COLOR_EXT
};
2164 DiscardFramebufferEXTImmediate
& cmd
=
2165 *GetImmediateAs
<DiscardFramebufferEXTImmediate
>();
2166 cmd
.Init(target
, count
, attachments
);
2168 // Should not result into a call into GL.
2169 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(attachments
)));
2170 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
2173 TEST_P(GLES2DecoderManualInitTest
,
2174 DiscardedAttachmentsEXTMarksFramebufferIncomplete
) {
2176 init
.extensions
= "GL_EXT_discard_framebuffer";
2177 init
.gl_version
= "opengl es 2.0";
2178 init
.has_alpha
= true;
2179 init
.bind_generates_resource
= true;
2182 const GLuint kFBOClientTextureId
= 4100;
2183 const GLuint kFBOServiceTextureId
= 4101;
2185 // Register a texture id.
2186 EXPECT_CALL(*gl_
, GenTextures(_
, _
))
2187 .WillOnce(SetArgumentPointee
<1>(kFBOServiceTextureId
))
2188 .RetiresOnSaturation();
2189 GenHelper
<GenTexturesImmediate
>(kFBOClientTextureId
);
2191 // Setup "render to" texture.
2192 DoBindTexture(GL_TEXTURE_2D
, kFBOClientTextureId
, kFBOServiceTextureId
);
2194 GL_TEXTURE_2D
, 0, GL_RGBA
, 1, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
2196 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
2197 DoFramebufferTexture2D(GL_FRAMEBUFFER
,
2198 GL_COLOR_ATTACHMENT0
,
2200 kFBOClientTextureId
,
2201 kFBOServiceTextureId
,
2205 // Setup "render from" texture.
2208 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER
, // target
2209 GL_COLOR_BUFFER_BIT
, // clear bits
2216 false); // scissor test
2217 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB
2218 false, // Framebuffer has depth
2219 false, // Framebuffer has stencil
2220 0x1111, // color bits
2221 false, // depth mask
2222 false, // depth enabled
2223 0, // front stencil mask
2224 0, // back stencil mask
2225 false); // stencil enabled
2227 EXPECT_CALL(*gl_
, Clear(GL_COLOR_BUFFER_BIT
)).Times(1).RetiresOnSaturation();
2230 clear_cmd
.Init(GL_COLOR_BUFFER_BIT
);
2231 EXPECT_EQ(error::kNoError
, ExecuteCmd(clear_cmd
));
2232 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2234 // Check that framebuffer is cleared and complete.
2235 FramebufferManager
* framebuffer_manager
= group().framebuffer_manager();
2236 Framebuffer
* framebuffer
=
2237 framebuffer_manager
->GetFramebuffer(client_framebuffer_id_
);
2238 EXPECT_TRUE(framebuffer
->IsCleared());
2239 EXPECT_TRUE(framebuffer_manager
->IsComplete(framebuffer
));
2241 // Check that Discard GL_COLOR_ATTACHMENT0, sets the attachment as uncleared
2242 // and the framebuffer as incomplete.
2244 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT") ==
2245 gfx::g_driver_gl
.fn
.glDiscardFramebufferEXTFn
);
2247 const GLenum target
= GL_FRAMEBUFFER
;
2248 const GLsizei count
= 1;
2249 const GLenum attachments
[] = {GL_COLOR_ATTACHMENT0
};
2251 DiscardFramebufferEXTImmediate
& discard_cmd
=
2252 *GetImmediateAs
<DiscardFramebufferEXTImmediate
>();
2253 discard_cmd
.Init(target
, count
, attachments
);
2255 EXPECT_CALL(*gl_
, DiscardFramebufferEXT(target
, count
, _
))
2257 .RetiresOnSaturation();
2258 EXPECT_EQ(error::kNoError
,
2259 ExecuteImmediateCmd(discard_cmd
, sizeof(attachments
)));
2260 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2261 EXPECT_FALSE(framebuffer
->IsCleared());
2262 EXPECT_FALSE(framebuffer_manager
->IsComplete(framebuffer
));
2265 TEST_P(GLES2DecoderManualInitTest
, ReadFormatExtension
) {
2267 init
.extensions
= "GL_OES_read_format";
2268 init
.bind_generates_resource
= true;
2271 EXPECT_CALL(*gl_
, GetError())
2272 .WillOnce(Return(GL_NO_ERROR
))
2273 .WillOnce(Return(GL_NO_ERROR
))
2274 .WillOnce(Return(GL_NO_ERROR
))
2275 .WillOnce(Return(GL_NO_ERROR
))
2276 .RetiresOnSaturation();
2277 EXPECT_CALL(*gl_
, GetError()).Times(6).RetiresOnSaturation();
2279 typedef GetIntegerv::Result Result
;
2280 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
2282 const GLuint kFBOClientTextureId
= 4100;
2283 const GLuint kFBOServiceTextureId
= 4101;
2285 // Register a texture id.
2286 EXPECT_CALL(*gl_
, GenTextures(_
, _
))
2287 .WillOnce(SetArgumentPointee
<1>(kFBOServiceTextureId
))
2288 .RetiresOnSaturation();
2289 GenHelper
<GenTexturesImmediate
>(kFBOClientTextureId
);
2291 // Setup "render to" texture.
2292 DoBindTexture(GL_TEXTURE_2D
, kFBOClientTextureId
, kFBOServiceTextureId
);
2294 GL_TEXTURE_2D
, 0, GL_RGBA
, 1, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
2296 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
2297 DoFramebufferTexture2D(GL_FRAMEBUFFER
,
2298 GL_COLOR_ATTACHMENT0
,
2300 kFBOClientTextureId
,
2301 kFBOServiceTextureId
,
2306 EXPECT_CALL(*gl_
, GetIntegerv(_
, _
)).Times(1).RetiresOnSaturation();
2307 cmd
.Init(GL_IMPLEMENTATION_COLOR_READ_FORMAT
,
2309 shared_memory_offset_
);
2310 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2311 EXPECT_EQ(1, result
->GetNumResults());
2312 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2315 EXPECT_CALL(*gl_
, GetIntegerv(_
, _
)).Times(1).RetiresOnSaturation();
2316 cmd
.Init(GL_IMPLEMENTATION_COLOR_READ_TYPE
,
2318 shared_memory_offset_
);
2319 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2320 EXPECT_EQ(1, result
->GetNumResults());
2321 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2324 TEST_P(GLES2DecoderManualInitTest
, NoReadFormatExtension
) {
2326 init
.bind_generates_resource
= true;
2329 EXPECT_CALL(*gl_
, GetError())
2330 .WillOnce(Return(GL_NO_ERROR
))
2331 .WillOnce(Return(GL_NO_ERROR
))
2332 .WillOnce(Return(GL_NO_ERROR
))
2333 .WillOnce(Return(GL_NO_ERROR
))
2334 .RetiresOnSaturation();
2336 typedef GetIntegerv::Result Result
;
2337 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
2339 const GLuint kFBOClientTextureId
= 4100;
2340 const GLuint kFBOServiceTextureId
= 4101;
2342 // Register a texture id.
2343 EXPECT_CALL(*gl_
, GenTextures(_
, _
))
2344 .WillOnce(SetArgumentPointee
<1>(kFBOServiceTextureId
))
2345 .RetiresOnSaturation();
2346 GenHelper
<GenTexturesImmediate
>(kFBOClientTextureId
);
2348 // Setup "render to" texture.
2349 DoBindTexture(GL_TEXTURE_2D
, kFBOClientTextureId
, kFBOServiceTextureId
);
2351 GL_TEXTURE_2D
, 0, GL_RGBA
, 1, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
2353 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
2354 DoFramebufferTexture2D(GL_FRAMEBUFFER
,
2355 GL_COLOR_ATTACHMENT0
,
2357 kFBOClientTextureId
,
2358 kFBOServiceTextureId
,
2363 EXPECT_CALL(*gl_
, GetIntegerv(_
, _
)).Times(0).RetiresOnSaturation();
2364 cmd
.Init(GL_IMPLEMENTATION_COLOR_READ_FORMAT
,
2366 shared_memory_offset_
);
2367 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2368 EXPECT_EQ(1, result
->GetNumResults());
2369 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2372 EXPECT_CALL(*gl_
, GetIntegerv(_
, _
)).Times(0).RetiresOnSaturation();
2373 cmd
.Init(GL_IMPLEMENTATION_COLOR_READ_TYPE
,
2375 shared_memory_offset_
);
2376 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2377 EXPECT_EQ(1, result
->GetNumResults());
2378 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2381 // TODO(gman): PixelStorei
2383 // TODO(gman): SwapBuffers
2385 } // namespace gles2