1 // Copyright 2013 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 "cc/test/test_web_graphics_context_3d.h"
10 #include "base/bind.h"
11 #include "base/lazy_instance.h"
12 #include "base/logging.h"
13 #include "base/message_loop/message_loop.h"
14 #include "base/numerics/safe_conversions.h"
15 #include "cc/test/test_context_support.h"
16 #include "gpu/GLES2/gl2extchromium.h"
17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/khronos/GLES2/gl2ext.h"
22 static unsigned s_context_id
= 1;
24 const GLuint
TestWebGraphicsContext3D::kExternalTextureId
= 1337;
26 static base::LazyInstance
<base::Lock
>::Leaky
27 g_shared_namespace_lock
= LAZY_INSTANCE_INITIALIZER
;
29 TestWebGraphicsContext3D::Namespace
*
30 TestWebGraphicsContext3D::shared_namespace_
= NULL
;
32 TestWebGraphicsContext3D::Namespace::Namespace()
36 next_renderbuffer_id(1) {
39 TestWebGraphicsContext3D::Namespace::~Namespace() {
40 g_shared_namespace_lock
.Get().AssertAcquired();
41 if (shared_namespace_
== this)
42 shared_namespace_
= NULL
;
46 scoped_ptr
<TestWebGraphicsContext3D
> TestWebGraphicsContext3D::Create() {
47 return make_scoped_ptr(new TestWebGraphicsContext3D());
50 TestWebGraphicsContext3D::TestWebGraphicsContext3D()
51 : context_id_(s_context_id
++),
52 times_bind_texture_succeeds_(-1),
53 times_end_query_succeeds_(-1),
55 times_map_buffer_chromium_succeeds_(-1),
56 current_used_transfer_buffer_usage_bytes_(0),
57 max_used_transfer_buffer_usage_bytes_(0),
58 next_program_id_(1000),
59 next_shader_id_(2000),
60 next_framebuffer_id_(1),
61 current_framebuffer_(0),
62 max_texture_size_(2048),
63 reshape_called_(false),
68 last_update_type_(NO_UPDATE
),
69 next_insert_sync_point_(1),
70 last_waited_sync_point_(0),
73 weak_ptr_factory_(this) {
75 set_support_image(true);
78 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() {
79 base::AutoLock
lock(g_shared_namespace_lock
.Get());
83 void TestWebGraphicsContext3D::CreateNamespace() {
84 base::AutoLock
lock(g_shared_namespace_lock
.Get());
85 if (shared_namespace_
) {
86 namespace_
= shared_namespace_
;
88 namespace_
= new Namespace
;
89 shared_namespace_
= namespace_
.get();
93 void TestWebGraphicsContext3D::reshapeWithScaleFactor(
94 int width
, int height
, float scale_factor
) {
95 reshape_called_
= true;
98 scale_factor_
= scale_factor
;
101 bool TestWebGraphicsContext3D::isContextLost() {
102 return context_lost_
;
105 GLenum
TestWebGraphicsContext3D::checkFramebufferStatus(
108 return GL_FRAMEBUFFER_UNDEFINED_OES
;
109 return GL_FRAMEBUFFER_COMPLETE
;
112 GLint
TestWebGraphicsContext3D::getUniformLocation(
114 const GLchar
* name
) {
118 GLsizeiptr
TestWebGraphicsContext3D::getVertexAttribOffset(
124 GLboolean
TestWebGraphicsContext3D::isBuffer(
129 GLboolean
TestWebGraphicsContext3D::isEnabled(
134 GLboolean
TestWebGraphicsContext3D::isFramebuffer(
135 GLuint framebuffer
) {
139 GLboolean
TestWebGraphicsContext3D::isProgram(
144 GLboolean
TestWebGraphicsContext3D::isRenderbuffer(
145 GLuint renderbuffer
) {
149 GLboolean
TestWebGraphicsContext3D::isShader(
154 GLboolean
TestWebGraphicsContext3D::isTexture(
159 void TestWebGraphicsContext3D::genBuffers(GLsizei count
, GLuint
* ids
) {
160 for (int i
= 0; i
< count
; ++i
)
161 ids
[i
] = NextBufferId();
164 void TestWebGraphicsContext3D::genFramebuffers(
165 GLsizei count
, GLuint
* ids
) {
166 for (int i
= 0; i
< count
; ++i
)
167 ids
[i
] = NextFramebufferId();
170 void TestWebGraphicsContext3D::genRenderbuffers(
171 GLsizei count
, GLuint
* ids
) {
172 for (int i
= 0; i
< count
; ++i
)
173 ids
[i
] = NextRenderbufferId();
176 void TestWebGraphicsContext3D::genTextures(GLsizei count
, GLuint
* ids
) {
177 for (int i
= 0; i
< count
; ++i
) {
178 ids
[i
] = NextTextureId();
179 DCHECK_NE(ids
[i
], kExternalTextureId
);
181 base::AutoLock
lock(namespace_
->lock
);
182 for (int i
= 0; i
< count
; ++i
)
183 namespace_
->textures
.Append(ids
[i
], new TestTexture());
186 void TestWebGraphicsContext3D::deleteBuffers(GLsizei count
, GLuint
* ids
) {
187 for (int i
= 0; i
< count
; ++i
)
188 RetireBufferId(ids
[i
]);
191 void TestWebGraphicsContext3D::deleteFramebuffers(
192 GLsizei count
, GLuint
* ids
) {
193 for (int i
= 0; i
< count
; ++i
) {
195 RetireFramebufferId(ids
[i
]);
196 if (ids
[i
] == current_framebuffer_
)
197 current_framebuffer_
= 0;
202 void TestWebGraphicsContext3D::deleteRenderbuffers(
203 GLsizei count
, GLuint
* ids
) {
204 for (int i
= 0; i
< count
; ++i
)
205 RetireRenderbufferId(ids
[i
]);
208 void TestWebGraphicsContext3D::deleteTextures(GLsizei count
, GLuint
* ids
) {
209 for (int i
= 0; i
< count
; ++i
)
210 RetireTextureId(ids
[i
]);
211 base::AutoLock
lock(namespace_
->lock
);
212 for (int i
= 0; i
< count
; ++i
) {
213 namespace_
->textures
.Remove(ids
[i
]);
214 texture_targets_
.UnbindTexture(ids
[i
]);
218 GLuint
TestWebGraphicsContext3D::createBuffer() {
224 GLuint
TestWebGraphicsContext3D::createFramebuffer() {
226 genFramebuffers(1, &id
);
230 GLuint
TestWebGraphicsContext3D::createRenderbuffer() {
232 genRenderbuffers(1, &id
);
236 GLuint
TestWebGraphicsContext3D::createTexture() {
242 void TestWebGraphicsContext3D::deleteBuffer(GLuint id
) {
243 deleteBuffers(1, &id
);
246 void TestWebGraphicsContext3D::deleteFramebuffer(GLuint id
) {
247 deleteFramebuffers(1, &id
);
250 void TestWebGraphicsContext3D::deleteRenderbuffer(GLuint id
) {
251 deleteRenderbuffers(1, &id
);
254 void TestWebGraphicsContext3D::deleteTexture(GLuint id
) {
255 deleteTextures(1, &id
);
258 unsigned TestWebGraphicsContext3D::createProgram() {
259 unsigned program
= next_program_id_
++ | context_id_
<< 16;
260 program_set_
.insert(program
);
264 GLuint
TestWebGraphicsContext3D::createShader(GLenum
) {
265 unsigned shader
= next_shader_id_
++ | context_id_
<< 16;
266 shader_set_
.insert(shader
);
270 GLuint
TestWebGraphicsContext3D::createExternalTexture() {
271 base::AutoLock
lock(namespace_
->lock
);
272 namespace_
->textures
.Append(kExternalTextureId
, new TestTexture());
273 return kExternalTextureId
;
276 void TestWebGraphicsContext3D::deleteProgram(GLuint id
) {
277 if (!program_set_
.count(id
))
278 ADD_FAILURE() << "deleteProgram called on unknown program " << id
;
279 program_set_
.erase(id
);
282 void TestWebGraphicsContext3D::deleteShader(GLuint id
) {
283 if (!shader_set_
.count(id
))
284 ADD_FAILURE() << "deleteShader called on unknown shader " << id
;
285 shader_set_
.erase(id
);
288 void TestWebGraphicsContext3D::attachShader(GLuint program
, GLuint shader
) {
289 if (!program_set_
.count(program
))
290 ADD_FAILURE() << "attachShader called with unknown program " << program
;
291 if (!shader_set_
.count(shader
))
292 ADD_FAILURE() << "attachShader called with unknown shader " << shader
;
295 void TestWebGraphicsContext3D::useProgram(GLuint program
) {
298 if (!program_set_
.count(program
))
299 ADD_FAILURE() << "useProgram called on unknown program " << program
;
302 void TestWebGraphicsContext3D::bindFramebuffer(
303 GLenum target
, GLuint framebuffer
) {
304 base::AutoLock
lock_for_framebuffer_access(namespace_
->lock
);
305 if (framebuffer
!= 0 &&
306 framebuffer_set_
.find(framebuffer
) == framebuffer_set_
.end()) {
307 ADD_FAILURE() << "bindFramebuffer called with unknown framebuffer";
308 } else if (framebuffer
!= 0 && (framebuffer
>> 16) != context_id_
) {
310 << "bindFramebuffer called with framebuffer from other context";
312 current_framebuffer_
= framebuffer
;
316 void TestWebGraphicsContext3D::bindRenderbuffer(
317 GLenum target
, GLuint renderbuffer
) {
320 base::AutoLock
lock_for_renderbuffer_access(namespace_
->lock
);
321 if (renderbuffer
!= 0 &&
322 namespace_
->renderbuffer_set
.find(renderbuffer
) ==
323 namespace_
->renderbuffer_set
.end()) {
324 ADD_FAILURE() << "bindRenderbuffer called with unknown renderbuffer";
325 } else if ((renderbuffer
>> 16) != context_id_
) {
327 << "bindRenderbuffer called with renderbuffer from other context";
331 void TestWebGraphicsContext3D::bindTexture(
332 GLenum target
, GLuint texture_id
) {
333 if (times_bind_texture_succeeds_
>= 0) {
334 if (!times_bind_texture_succeeds_
) {
335 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB
,
336 GL_INNOCENT_CONTEXT_RESET_ARB
);
338 --times_bind_texture_succeeds_
;
343 base::AutoLock
lock(namespace_
->lock
);
344 DCHECK(namespace_
->textures
.ContainsId(texture_id
));
345 texture_targets_
.BindTexture(target
, texture_id
);
346 used_textures_
.insert(texture_id
);
349 GLuint
TestWebGraphicsContext3D::BoundTextureId(
351 return texture_targets_
.BoundTexture(target
);
354 scoped_refptr
<TestTexture
> TestWebGraphicsContext3D::BoundTexture(
356 // The caller is expected to lock the namespace for texture access.
357 namespace_
->lock
.AssertAcquired();
358 return namespace_
->textures
.TextureForId(BoundTextureId(target
));
361 scoped_refptr
<TestTexture
> TestWebGraphicsContext3D::UnboundTexture(
363 // The caller is expected to lock the namespace for texture access.
364 namespace_
->lock
.AssertAcquired();
365 return namespace_
->textures
.TextureForId(texture
);
368 void TestWebGraphicsContext3D::CheckTextureIsBound(GLenum target
) {
369 DCHECK(BoundTextureId(target
));
372 GLuint
TestWebGraphicsContext3D::createQueryEXT() { return 1u; }
374 void TestWebGraphicsContext3D::endQueryEXT(GLenum target
) {
375 if (times_end_query_succeeds_
>= 0) {
376 if (!times_end_query_succeeds_
) {
377 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB
,
378 GL_INNOCENT_CONTEXT_RESET_ARB
);
380 --times_end_query_succeeds_
;
384 void TestWebGraphicsContext3D::getQueryObjectuivEXT(
388 // If the context is lost, behave as if result is available.
389 if (pname
== GL_QUERY_RESULT_AVAILABLE_EXT
)
393 void TestWebGraphicsContext3D::getIntegerv(
396 if (pname
== GL_MAX_TEXTURE_SIZE
)
397 *value
= max_texture_size_
;
398 else if (pname
== GL_ACTIVE_TEXTURE
)
399 *value
= GL_TEXTURE0
;
400 else if (pname
== GL_UNPACK_ALIGNMENT
)
401 *value
= unpack_alignment_
;
402 else if (pname
== GL_FRAMEBUFFER_BINDING
)
403 *value
= current_framebuffer_
;
406 void TestWebGraphicsContext3D::getProgramiv(GLuint program
,
409 if (pname
== GL_LINK_STATUS
)
413 void TestWebGraphicsContext3D::getShaderiv(GLuint shader
,
416 if (pname
== GL_COMPILE_STATUS
)
420 void TestWebGraphicsContext3D::getShaderPrecisionFormat(GLenum shadertype
,
421 GLenum precisiontype
,
424 // Return the minimum precision requirements of the GLES2
426 switch (precisiontype
) {
447 case GL_MEDIUM_FLOAT
:
463 void TestWebGraphicsContext3D::genMailboxCHROMIUM(GLbyte
* mailbox
) {
464 static char mailbox_name1
= '1';
465 static char mailbox_name2
= '1';
466 mailbox
[0] = mailbox_name1
;
467 mailbox
[1] = mailbox_name2
;
469 if (++mailbox_name1
== 0) {
475 GLuint
TestWebGraphicsContext3D::createAndConsumeTextureCHROMIUM(
477 const GLbyte
* mailbox
) {
478 GLuint texture_id
= createTexture();
479 consumeTextureCHROMIUM(target
, mailbox
);
483 void TestWebGraphicsContext3D::loseContextCHROMIUM(GLenum current
,
487 context_lost_
= true;
488 if (!context_lost_callback_
.is_null())
489 context_lost_callback_
.Run();
491 for (size_t i
= 0; i
< shared_contexts_
.size(); ++i
)
492 shared_contexts_
[i
]->loseContextCHROMIUM(current
, other
);
493 shared_contexts_
.clear();
496 void TestWebGraphicsContext3D::finish() {
497 test_support_
->CallAllSyncPointCallbacks();
500 void TestWebGraphicsContext3D::flush() {
501 test_support_
->CallAllSyncPointCallbacks();
504 void TestWebGraphicsContext3D::shallowFinishCHROMIUM() {
505 test_support_
->CallAllSyncPointCallbacks();
508 GLint
TestWebGraphicsContext3D::getAttribLocation(GLuint program
,
509 const GLchar
* name
) {
513 GLenum
TestWebGraphicsContext3D::getError() { return GL_NO_ERROR
; }
515 void TestWebGraphicsContext3D::bindBuffer(GLenum target
,
517 bound_buffer_
= buffer
;
520 unsigned context_id
= buffer
>> 16;
521 unsigned buffer_id
= buffer
& 0xffff;
522 base::AutoLock
lock(namespace_
->lock
);
524 DCHECK_LT(buffer_id
, namespace_
->next_buffer_id
);
525 DCHECK_EQ(context_id
, context_id_
);
527 base::ScopedPtrHashMap
<unsigned, scoped_ptr
<Buffer
>>& buffers
=
529 if (buffers
.count(bound_buffer_
) == 0)
530 buffers
.set(bound_buffer_
, make_scoped_ptr(new Buffer
).Pass());
532 buffers
.get(bound_buffer_
)->target
= target
;
535 void TestWebGraphicsContext3D::bufferData(GLenum target
,
539 base::AutoLock
lock(namespace_
->lock
);
540 base::ScopedPtrHashMap
<unsigned, scoped_ptr
<Buffer
>>& buffers
=
542 DCHECK_GT(buffers
.count(bound_buffer_
), 0u);
543 DCHECK_EQ(target
, buffers
.get(bound_buffer_
)->target
);
544 Buffer
* buffer
= buffers
.get(bound_buffer_
);
546 buffer
->pixels
= nullptr;
550 size_t old_size
= buffer
->size
;
552 buffer
->pixels
.reset(new uint8
[size
]);
555 memcpy(buffer
->pixels
.get(), data
, size
);
556 if (buffer
->target
== GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM
)
557 current_used_transfer_buffer_usage_bytes_
+=
558 base::checked_cast
<int>(buffer
->size
) -
559 base::checked_cast
<int>(old_size
);
560 max_used_transfer_buffer_usage_bytes_
=
561 std::max(max_used_transfer_buffer_usage_bytes_
,
562 current_used_transfer_buffer_usage_bytes_
);
565 void TestWebGraphicsContext3D::pixelStorei(GLenum pname
, GLint param
) {
567 case GL_UNPACK_ALIGNMENT
:
568 // Param should be a power of two <= 8.
569 EXPECT_EQ(0, param
& (param
- 1));
576 unpack_alignment_
= param
;
587 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target
,
589 base::AutoLock
lock(namespace_
->lock
);
590 base::ScopedPtrHashMap
<unsigned, scoped_ptr
<Buffer
>>& buffers
=
592 DCHECK_GT(buffers
.count(bound_buffer_
), 0u);
593 DCHECK_EQ(target
, buffers
.get(bound_buffer_
)->target
);
594 if (times_map_buffer_chromium_succeeds_
>= 0) {
595 if (!times_map_buffer_chromium_succeeds_
) {
598 --times_map_buffer_chromium_succeeds_
;
601 return buffers
.get(bound_buffer_
)->pixels
.get();
604 GLboolean
TestWebGraphicsContext3D::unmapBufferCHROMIUM(
606 base::AutoLock
lock(namespace_
->lock
);
607 base::ScopedPtrHashMap
<unsigned, scoped_ptr
<Buffer
>>& buffers
=
609 DCHECK_GT(buffers
.count(bound_buffer_
), 0u);
610 DCHECK_EQ(target
, buffers
.get(bound_buffer_
)->target
);
611 buffers
.get(bound_buffer_
)->pixels
= nullptr;
615 GLuint
TestWebGraphicsContext3D::createImageCHROMIUM(ClientBuffer buffer
,
618 GLenum internalformat
) {
619 DCHECK_EQ(GL_RGBA
, static_cast<int>(internalformat
));
620 GLuint image_id
= NextImageId();
621 base::AutoLock
lock(namespace_
->lock
);
622 base::hash_set
<unsigned>& images
= namespace_
->images
;
623 images
.insert(image_id
);
627 void TestWebGraphicsContext3D::destroyImageCHROMIUM(
630 base::AutoLock
lock(namespace_
->lock
);
631 base::hash_set
<unsigned>& images
= namespace_
->images
;
632 if (!images
.count(id
))
633 ADD_FAILURE() << "destroyImageCHROMIUM called on unknown image " << id
;
637 GLuint
TestWebGraphicsContext3D::createGpuMemoryBufferImageCHROMIUM(
640 GLenum internalformat
,
642 DCHECK_EQ(GL_RGBA
, static_cast<int>(internalformat
));
643 GLuint image_id
= NextImageId();
644 base::AutoLock
lock(namespace_
->lock
);
645 base::hash_set
<unsigned>& images
= namespace_
->images
;
646 images
.insert(image_id
);
650 unsigned TestWebGraphicsContext3D::insertSyncPoint() {
651 return next_insert_sync_point_
++;
654 void TestWebGraphicsContext3D::waitSyncPoint(unsigned sync_point
) {
656 last_waited_sync_point_
= sync_point
;
659 size_t TestWebGraphicsContext3D::NumTextures() const {
660 base::AutoLock
lock(namespace_
->lock
);
661 return namespace_
->textures
.Size();
664 GLuint
TestWebGraphicsContext3D::TextureAt(int i
) const {
665 base::AutoLock
lock(namespace_
->lock
);
666 return namespace_
->textures
.IdAt(i
);
669 GLuint
TestWebGraphicsContext3D::NextTextureId() {
670 base::AutoLock
lock(namespace_
->lock
);
671 GLuint texture_id
= namespace_
->next_texture_id
++;
672 DCHECK(texture_id
< (1 << 16));
673 texture_id
|= context_id_
<< 16;
677 void TestWebGraphicsContext3D::RetireTextureId(GLuint id
) {
678 base::AutoLock
lock(namespace_
->lock
);
679 unsigned context_id
= id
>> 16;
680 unsigned texture_id
= id
& 0xffff;
682 DCHECK_LT(texture_id
, namespace_
->next_texture_id
);
683 DCHECK_EQ(context_id
, context_id_
);
686 GLuint
TestWebGraphicsContext3D::NextBufferId() {
687 base::AutoLock
lock(namespace_
->lock
);
688 GLuint buffer_id
= namespace_
->next_buffer_id
++;
689 DCHECK(buffer_id
< (1 << 16));
690 buffer_id
|= context_id_
<< 16;
694 void TestWebGraphicsContext3D::RetireBufferId(GLuint id
) {
695 base::AutoLock
lock(namespace_
->lock
);
696 unsigned context_id
= id
>> 16;
697 unsigned buffer_id
= id
& 0xffff;
699 DCHECK_LT(buffer_id
, namespace_
->next_buffer_id
);
700 DCHECK_EQ(context_id
, context_id_
);
703 GLuint
TestWebGraphicsContext3D::NextImageId() {
704 base::AutoLock
lock(namespace_
->lock
);
705 GLuint image_id
= namespace_
->next_image_id
++;
706 DCHECK(image_id
< (1 << 16));
707 image_id
|= context_id_
<< 16;
711 void TestWebGraphicsContext3D::RetireImageId(GLuint id
) {
712 base::AutoLock
lock(namespace_
->lock
);
713 unsigned context_id
= id
>> 16;
714 unsigned image_id
= id
& 0xffff;
716 DCHECK_LT(image_id
, namespace_
->next_image_id
);
717 DCHECK_EQ(context_id
, context_id_
);
720 GLuint
TestWebGraphicsContext3D::NextFramebufferId() {
721 base::AutoLock
lock_for_framebuffer_access(namespace_
->lock
);
722 GLuint id
= next_framebuffer_id_
++;
723 DCHECK(id
< (1 << 16));
724 id
|= context_id_
<< 16;
725 framebuffer_set_
.insert(id
);
729 void TestWebGraphicsContext3D::RetireFramebufferId(GLuint id
) {
730 base::AutoLock
lock_for_framebuffer_access(namespace_
->lock
);
731 DCHECK(framebuffer_set_
.find(id
) != framebuffer_set_
.end());
732 framebuffer_set_
.erase(id
);
735 GLuint
TestWebGraphicsContext3D::NextRenderbufferId() {
736 base::AutoLock
lock_for_renderbuffer_access(namespace_
->lock
);
737 GLuint id
= namespace_
->next_renderbuffer_id
++;
738 DCHECK(id
< (1 << 16));
739 id
|= context_id_
<< 16;
740 namespace_
->renderbuffer_set
.insert(id
);
744 void TestWebGraphicsContext3D::RetireRenderbufferId(GLuint id
) {
745 base::AutoLock
lock_for_renderbuffer_access(namespace_
->lock
);
746 DCHECK(namespace_
->renderbuffer_set
.find(id
) !=
747 namespace_
->renderbuffer_set
.end());
748 namespace_
->renderbuffer_set
.erase(id
);
751 void TestWebGraphicsContext3D::SetMaxTransferBufferUsageBytes(
752 size_t max_transfer_buffer_usage_bytes
) {
753 test_capabilities_
.max_transfer_buffer_usage_bytes
=
754 max_transfer_buffer_usage_bytes
;
757 void TestWebGraphicsContext3D::SetMaxSamples(int max_samples
) {
758 test_capabilities_
.gpu
.max_samples
= max_samples
;
761 TestWebGraphicsContext3D::TextureTargets::TextureTargets() {
762 // Initialize default bindings.
763 bound_textures_
[GL_TEXTURE_2D
] = 0;
764 bound_textures_
[GL_TEXTURE_EXTERNAL_OES
] = 0;
765 bound_textures_
[GL_TEXTURE_RECTANGLE_ARB
] = 0;
768 TestWebGraphicsContext3D::TextureTargets::~TextureTargets() {}
770 void TestWebGraphicsContext3D::TextureTargets::BindTexture(
773 // Make sure this is a supported target by seeing if it was bound to before.
774 DCHECK(bound_textures_
.find(target
) != bound_textures_
.end());
775 bound_textures_
[target
] = id
;
778 void TestWebGraphicsContext3D::texParameteri(GLenum target
,
781 CheckTextureIsBound(target
);
782 base::AutoLock
lock_for_texture_access(namespace_
->lock
);
783 scoped_refptr
<TestTexture
> texture
= BoundTexture(target
);
784 DCHECK(texture
->IsValidParameter(pname
));
785 texture
->params
[pname
] = param
;
788 void TestWebGraphicsContext3D::getTexParameteriv(GLenum target
,
791 CheckTextureIsBound(target
);
792 base::AutoLock
lock_for_texture_access(namespace_
->lock
);
793 scoped_refptr
<TestTexture
> texture
= BoundTexture(target
);
794 DCHECK(texture
->IsValidParameter(pname
));
795 TestTexture::TextureParametersMap::iterator it
= texture
->params
.find(pname
);
796 if (it
!= texture
->params
.end())
800 void TestWebGraphicsContext3D::TextureTargets::UnbindTexture(
802 // Bind zero to any targets that the id is bound to.
803 for (TargetTextureMap::iterator it
= bound_textures_
.begin();
804 it
!= bound_textures_
.end();
806 if (it
->second
== id
)
811 GLuint
TestWebGraphicsContext3D::TextureTargets::BoundTexture(
813 DCHECK(bound_textures_
.find(target
) != bound_textures_
.end());
814 return bound_textures_
[target
];
817 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {}
819 TestWebGraphicsContext3D::Buffer::~Buffer() {}
821 TestWebGraphicsContext3D::Image::Image() {}
823 TestWebGraphicsContext3D::Image::~Image() {}