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 "cc/test/test_context_support.h"
15 #include "gpu/GLES2/gl2extchromium.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/khronos/GLES2/gl2ext.h"
21 static unsigned s_context_id
= 1;
23 const GLuint
TestWebGraphicsContext3D::kExternalTextureId
= 1337;
25 static base::LazyInstance
<base::Lock
>::Leaky
26 g_shared_namespace_lock
= LAZY_INSTANCE_INITIALIZER
;
28 TestWebGraphicsContext3D::Namespace
*
29 TestWebGraphicsContext3D::shared_namespace_
= NULL
;
31 TestWebGraphicsContext3D::Namespace::Namespace()
35 next_renderbuffer_id(1) {
38 TestWebGraphicsContext3D::Namespace::~Namespace() {
39 g_shared_namespace_lock
.Get().AssertAcquired();
40 if (shared_namespace_
== this)
41 shared_namespace_
= NULL
;
45 scoped_ptr
<TestWebGraphicsContext3D
> TestWebGraphicsContext3D::Create() {
46 return make_scoped_ptr(new TestWebGraphicsContext3D());
49 TestWebGraphicsContext3D::TestWebGraphicsContext3D()
50 : context_id_(s_context_id
++),
51 times_bind_texture_succeeds_(-1),
52 times_end_query_succeeds_(-1),
54 times_map_buffer_chromium_succeeds_(-1),
55 current_used_transfer_buffer_usage_bytes_(0),
56 max_used_transfer_buffer_usage_bytes_(0),
57 next_program_id_(1000),
58 next_shader_id_(2000),
59 next_framebuffer_id_(1),
60 current_framebuffer_(0),
61 max_texture_size_(2048),
62 reshape_called_(false),
67 last_update_type_(NO_UPDATE
),
68 next_insert_sync_point_(1),
69 last_waited_sync_point_(0),
72 weak_ptr_factory_(this) {
74 set_support_image(true);
77 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() {
78 base::AutoLock
lock(g_shared_namespace_lock
.Get());
82 void TestWebGraphicsContext3D::CreateNamespace() {
83 base::AutoLock
lock(g_shared_namespace_lock
.Get());
84 if (shared_namespace_
) {
85 namespace_
= shared_namespace_
;
87 namespace_
= new Namespace
;
88 shared_namespace_
= namespace_
.get();
92 void TestWebGraphicsContext3D::reshapeWithScaleFactor(
93 int width
, int height
, float scale_factor
) {
94 reshape_called_
= true;
97 scale_factor_
= scale_factor
;
100 bool TestWebGraphicsContext3D::isContextLost() {
101 return context_lost_
;
104 GLenum
TestWebGraphicsContext3D::checkFramebufferStatus(
107 return GL_FRAMEBUFFER_UNDEFINED_OES
;
108 return GL_FRAMEBUFFER_COMPLETE
;
111 GLint
TestWebGraphicsContext3D::getUniformLocation(
113 const GLchar
* name
) {
117 GLsizeiptr
TestWebGraphicsContext3D::getVertexAttribOffset(
123 GLboolean
TestWebGraphicsContext3D::isBuffer(
128 GLboolean
TestWebGraphicsContext3D::isEnabled(
133 GLboolean
TestWebGraphicsContext3D::isFramebuffer(
134 GLuint framebuffer
) {
138 GLboolean
TestWebGraphicsContext3D::isProgram(
143 GLboolean
TestWebGraphicsContext3D::isRenderbuffer(
144 GLuint renderbuffer
) {
148 GLboolean
TestWebGraphicsContext3D::isShader(
153 GLboolean
TestWebGraphicsContext3D::isTexture(
158 void TestWebGraphicsContext3D::genBuffers(GLsizei count
, GLuint
* ids
) {
159 for (int i
= 0; i
< count
; ++i
)
160 ids
[i
] = NextBufferId();
163 void TestWebGraphicsContext3D::genFramebuffers(
164 GLsizei count
, GLuint
* ids
) {
165 for (int i
= 0; i
< count
; ++i
)
166 ids
[i
] = NextFramebufferId();
169 void TestWebGraphicsContext3D::genRenderbuffers(
170 GLsizei count
, GLuint
* ids
) {
171 for (int i
= 0; i
< count
; ++i
)
172 ids
[i
] = NextRenderbufferId();
175 void TestWebGraphicsContext3D::genTextures(GLsizei count
, GLuint
* ids
) {
176 for (int i
= 0; i
< count
; ++i
) {
177 ids
[i
] = NextTextureId();
178 DCHECK_NE(ids
[i
], kExternalTextureId
);
180 base::AutoLock
lock(namespace_
->lock
);
181 for (int i
= 0; i
< count
; ++i
)
182 namespace_
->textures
.Append(ids
[i
], new TestTexture());
185 void TestWebGraphicsContext3D::deleteBuffers(GLsizei count
, GLuint
* ids
) {
186 for (int i
= 0; i
< count
; ++i
)
187 RetireBufferId(ids
[i
]);
190 void TestWebGraphicsContext3D::deleteFramebuffers(
191 GLsizei count
, GLuint
* ids
) {
192 for (int i
= 0; i
< count
; ++i
) {
194 RetireFramebufferId(ids
[i
]);
195 if (ids
[i
] == current_framebuffer_
)
196 current_framebuffer_
= 0;
201 void TestWebGraphicsContext3D::deleteRenderbuffers(
202 GLsizei count
, GLuint
* ids
) {
203 for (int i
= 0; i
< count
; ++i
)
204 RetireRenderbufferId(ids
[i
]);
207 void TestWebGraphicsContext3D::deleteTextures(GLsizei count
, GLuint
* ids
) {
208 for (int i
= 0; i
< count
; ++i
)
209 RetireTextureId(ids
[i
]);
210 base::AutoLock
lock(namespace_
->lock
);
211 for (int i
= 0; i
< count
; ++i
) {
212 namespace_
->textures
.Remove(ids
[i
]);
213 texture_targets_
.UnbindTexture(ids
[i
]);
217 GLuint
TestWebGraphicsContext3D::createBuffer() {
223 GLuint
TestWebGraphicsContext3D::createFramebuffer() {
225 genFramebuffers(1, &id
);
229 GLuint
TestWebGraphicsContext3D::createRenderbuffer() {
231 genRenderbuffers(1, &id
);
235 GLuint
TestWebGraphicsContext3D::createTexture() {
241 void TestWebGraphicsContext3D::deleteBuffer(GLuint id
) {
242 deleteBuffers(1, &id
);
245 void TestWebGraphicsContext3D::deleteFramebuffer(GLuint id
) {
246 deleteFramebuffers(1, &id
);
249 void TestWebGraphicsContext3D::deleteRenderbuffer(GLuint id
) {
250 deleteRenderbuffers(1, &id
);
253 void TestWebGraphicsContext3D::deleteTexture(GLuint id
) {
254 deleteTextures(1, &id
);
257 unsigned TestWebGraphicsContext3D::createProgram() {
258 unsigned program
= next_program_id_
++ | context_id_
<< 16;
259 program_set_
.insert(program
);
263 GLuint
TestWebGraphicsContext3D::createShader(GLenum
) {
264 unsigned shader
= next_shader_id_
++ | context_id_
<< 16;
265 shader_set_
.insert(shader
);
269 GLuint
TestWebGraphicsContext3D::createExternalTexture() {
270 base::AutoLock
lock(namespace_
->lock
);
271 namespace_
->textures
.Append(kExternalTextureId
, new TestTexture());
272 return kExternalTextureId
;
275 void TestWebGraphicsContext3D::deleteProgram(GLuint id
) {
276 if (!program_set_
.count(id
))
277 ADD_FAILURE() << "deleteProgram called on unknown program " << id
;
278 program_set_
.erase(id
);
281 void TestWebGraphicsContext3D::deleteShader(GLuint id
) {
282 if (!shader_set_
.count(id
))
283 ADD_FAILURE() << "deleteShader called on unknown shader " << id
;
284 shader_set_
.erase(id
);
287 void TestWebGraphicsContext3D::attachShader(GLuint program
, GLuint shader
) {
288 if (!program_set_
.count(program
))
289 ADD_FAILURE() << "attachShader called with unknown program " << program
;
290 if (!shader_set_
.count(shader
))
291 ADD_FAILURE() << "attachShader called with unknown shader " << shader
;
294 void TestWebGraphicsContext3D::useProgram(GLuint program
) {
297 if (!program_set_
.count(program
))
298 ADD_FAILURE() << "useProgram called on unknown program " << program
;
301 void TestWebGraphicsContext3D::bindFramebuffer(
302 GLenum target
, GLuint framebuffer
) {
303 base::AutoLock
lock_for_framebuffer_access(namespace_
->lock
);
304 if (framebuffer
!= 0 &&
305 framebuffer_set_
.find(framebuffer
) == framebuffer_set_
.end()) {
306 ADD_FAILURE() << "bindFramebuffer called with unknown framebuffer";
307 } else if (framebuffer
!= 0 && (framebuffer
>> 16) != context_id_
) {
309 << "bindFramebuffer called with framebuffer from other context";
311 current_framebuffer_
= framebuffer
;
315 void TestWebGraphicsContext3D::bindRenderbuffer(
316 GLenum target
, GLuint renderbuffer
) {
319 base::AutoLock
lock_for_renderbuffer_access(namespace_
->lock
);
320 if (renderbuffer
!= 0 &&
321 namespace_
->renderbuffer_set
.find(renderbuffer
) ==
322 namespace_
->renderbuffer_set
.end()) {
323 ADD_FAILURE() << "bindRenderbuffer called with unknown renderbuffer";
324 } else if ((renderbuffer
>> 16) != context_id_
) {
326 << "bindRenderbuffer called with renderbuffer from other context";
330 void TestWebGraphicsContext3D::bindTexture(
331 GLenum target
, GLuint texture_id
) {
332 if (times_bind_texture_succeeds_
>= 0) {
333 if (!times_bind_texture_succeeds_
) {
334 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB
,
335 GL_INNOCENT_CONTEXT_RESET_ARB
);
337 --times_bind_texture_succeeds_
;
342 base::AutoLock
lock(namespace_
->lock
);
343 DCHECK(namespace_
->textures
.ContainsId(texture_id
));
344 texture_targets_
.BindTexture(target
, texture_id
);
345 used_textures_
.insert(texture_id
);
348 GLuint
TestWebGraphicsContext3D::BoundTextureId(
350 return texture_targets_
.BoundTexture(target
);
353 scoped_refptr
<TestTexture
> TestWebGraphicsContext3D::BoundTexture(
355 // The caller is expected to lock the namespace for texture access.
356 namespace_
->lock
.AssertAcquired();
357 return namespace_
->textures
.TextureForId(BoundTextureId(target
));
360 scoped_refptr
<TestTexture
> TestWebGraphicsContext3D::UnboundTexture(
362 // The caller is expected to lock the namespace for texture access.
363 namespace_
->lock
.AssertAcquired();
364 return namespace_
->textures
.TextureForId(texture
);
367 void TestWebGraphicsContext3D::CheckTextureIsBound(GLenum target
) {
368 DCHECK(BoundTextureId(target
));
371 GLuint
TestWebGraphicsContext3D::createQueryEXT() { return 1u; }
373 void TestWebGraphicsContext3D::endQueryEXT(GLenum target
) {
374 if (times_end_query_succeeds_
>= 0) {
375 if (!times_end_query_succeeds_
) {
376 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB
,
377 GL_INNOCENT_CONTEXT_RESET_ARB
);
379 --times_end_query_succeeds_
;
383 void TestWebGraphicsContext3D::getQueryObjectuivEXT(
387 // If the context is lost, behave as if result is available.
388 if (pname
== GL_QUERY_RESULT_AVAILABLE_EXT
)
392 void TestWebGraphicsContext3D::getIntegerv(
395 if (pname
== GL_MAX_TEXTURE_SIZE
)
396 *value
= max_texture_size_
;
397 else if (pname
== GL_ACTIVE_TEXTURE
)
398 *value
= GL_TEXTURE0
;
399 else if (pname
== GL_UNPACK_ALIGNMENT
)
400 *value
= unpack_alignment_
;
401 else if (pname
== GL_FRAMEBUFFER_BINDING
)
402 *value
= current_framebuffer_
;
405 void TestWebGraphicsContext3D::getProgramiv(GLuint program
,
408 if (pname
== GL_LINK_STATUS
)
412 void TestWebGraphicsContext3D::getShaderiv(GLuint shader
,
415 if (pname
== GL_COMPILE_STATUS
)
419 void TestWebGraphicsContext3D::getShaderPrecisionFormat(GLenum shadertype
,
420 GLenum precisiontype
,
423 // Return the minimum precision requirements of the GLES2
425 switch (precisiontype
) {
446 case GL_MEDIUM_FLOAT
:
462 void TestWebGraphicsContext3D::genMailboxCHROMIUM(GLbyte
* mailbox
) {
463 static char mailbox_name1
= '1';
464 static char mailbox_name2
= '1';
465 mailbox
[0] = mailbox_name1
;
466 mailbox
[1] = mailbox_name2
;
468 if (++mailbox_name1
== 0) {
474 GLuint
TestWebGraphicsContext3D::createAndConsumeTextureCHROMIUM(
476 const GLbyte
* mailbox
) {
477 GLuint texture_id
= createTexture();
478 consumeTextureCHROMIUM(target
, mailbox
);
482 void TestWebGraphicsContext3D::loseContextCHROMIUM(GLenum current
,
486 context_lost_
= true;
487 if (!context_lost_callback_
.is_null())
488 context_lost_callback_
.Run();
490 for (size_t i
= 0; i
< shared_contexts_
.size(); ++i
)
491 shared_contexts_
[i
]->loseContextCHROMIUM(current
, other
);
492 shared_contexts_
.clear();
495 void TestWebGraphicsContext3D::finish() {
496 test_support_
->CallAllSyncPointCallbacks();
499 void TestWebGraphicsContext3D::flush() {
500 test_support_
->CallAllSyncPointCallbacks();
503 void TestWebGraphicsContext3D::shallowFinishCHROMIUM() {
504 test_support_
->CallAllSyncPointCallbacks();
507 GLint
TestWebGraphicsContext3D::getAttribLocation(GLuint program
,
508 const GLchar
* name
) {
512 GLenum
TestWebGraphicsContext3D::getError() { return GL_NO_ERROR
; }
514 void TestWebGraphicsContext3D::bindBuffer(GLenum target
,
516 bound_buffer_
= buffer
;
519 unsigned context_id
= buffer
>> 16;
520 unsigned buffer_id
= buffer
& 0xffff;
521 base::AutoLock
lock(namespace_
->lock
);
523 DCHECK_LT(buffer_id
, namespace_
->next_buffer_id
);
524 DCHECK_EQ(context_id
, context_id_
);
526 base::ScopedPtrHashMap
<unsigned, scoped_ptr
<Buffer
>>& buffers
=
528 if (buffers
.count(bound_buffer_
) == 0)
529 buffers
.set(bound_buffer_
, make_scoped_ptr(new Buffer
).Pass());
531 buffers
.get(bound_buffer_
)->target
= target
;
534 void TestWebGraphicsContext3D::bufferData(GLenum target
,
538 base::AutoLock
lock(namespace_
->lock
);
539 base::ScopedPtrHashMap
<unsigned, scoped_ptr
<Buffer
>>& buffers
=
541 DCHECK_GT(buffers
.count(bound_buffer_
), 0u);
542 DCHECK_EQ(target
, buffers
.get(bound_buffer_
)->target
);
543 Buffer
* buffer
= buffers
.get(bound_buffer_
);
545 buffer
->pixels
= nullptr;
549 size_t old_size
= buffer
->size
;
551 buffer
->pixels
.reset(new uint8
[size
]);
554 memcpy(buffer
->pixels
.get(), data
, size
);
555 if (buffer
->target
== GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM
)
556 current_used_transfer_buffer_usage_bytes_
+= buffer
->size
- old_size
;
557 max_used_transfer_buffer_usage_bytes_
=
558 std::max(max_used_transfer_buffer_usage_bytes_
,
559 current_used_transfer_buffer_usage_bytes_
);
562 void TestWebGraphicsContext3D::pixelStorei(GLenum pname
, GLint param
) {
564 case GL_UNPACK_ALIGNMENT
:
565 // Param should be a power of two <= 8.
566 EXPECT_EQ(0, param
& (param
- 1));
573 unpack_alignment_
= param
;
584 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target
,
586 base::AutoLock
lock(namespace_
->lock
);
587 base::ScopedPtrHashMap
<unsigned, scoped_ptr
<Buffer
>>& buffers
=
589 DCHECK_GT(buffers
.count(bound_buffer_
), 0u);
590 DCHECK_EQ(target
, buffers
.get(bound_buffer_
)->target
);
591 if (times_map_buffer_chromium_succeeds_
>= 0) {
592 if (!times_map_buffer_chromium_succeeds_
) {
595 --times_map_buffer_chromium_succeeds_
;
598 return buffers
.get(bound_buffer_
)->pixels
.get();
601 GLboolean
TestWebGraphicsContext3D::unmapBufferCHROMIUM(
603 base::AutoLock
lock(namespace_
->lock
);
604 base::ScopedPtrHashMap
<unsigned, scoped_ptr
<Buffer
>>& buffers
=
606 DCHECK_GT(buffers
.count(bound_buffer_
), 0u);
607 DCHECK_EQ(target
, buffers
.get(bound_buffer_
)->target
);
608 buffers
.get(bound_buffer_
)->pixels
= nullptr;
612 GLuint
TestWebGraphicsContext3D::createImageCHROMIUM(ClientBuffer buffer
,
615 GLenum internalformat
) {
616 DCHECK_EQ(GL_RGBA
, static_cast<int>(internalformat
));
617 GLuint image_id
= NextImageId();
618 base::AutoLock
lock(namespace_
->lock
);
619 base::hash_set
<unsigned>& images
= namespace_
->images
;
620 images
.insert(image_id
);
624 void TestWebGraphicsContext3D::destroyImageCHROMIUM(
627 base::AutoLock
lock(namespace_
->lock
);
628 base::hash_set
<unsigned>& images
= namespace_
->images
;
629 if (!images
.count(id
))
630 ADD_FAILURE() << "destroyImageCHROMIUM called on unknown image " << id
;
634 GLuint
TestWebGraphicsContext3D::createGpuMemoryBufferImageCHROMIUM(
637 GLenum internalformat
,
639 DCHECK_EQ(GL_RGBA
, static_cast<int>(internalformat
));
640 GLuint image_id
= NextImageId();
641 base::AutoLock
lock(namespace_
->lock
);
642 base::hash_set
<unsigned>& images
= namespace_
->images
;
643 images
.insert(image_id
);
647 unsigned TestWebGraphicsContext3D::insertSyncPoint() {
648 return next_insert_sync_point_
++;
651 void TestWebGraphicsContext3D::waitSyncPoint(unsigned sync_point
) {
653 last_waited_sync_point_
= sync_point
;
656 size_t TestWebGraphicsContext3D::NumTextures() const {
657 base::AutoLock
lock(namespace_
->lock
);
658 return namespace_
->textures
.Size();
661 GLuint
TestWebGraphicsContext3D::TextureAt(int i
) const {
662 base::AutoLock
lock(namespace_
->lock
);
663 return namespace_
->textures
.IdAt(i
);
666 GLuint
TestWebGraphicsContext3D::NextTextureId() {
667 base::AutoLock
lock(namespace_
->lock
);
668 GLuint texture_id
= namespace_
->next_texture_id
++;
669 DCHECK(texture_id
< (1 << 16));
670 texture_id
|= context_id_
<< 16;
674 void TestWebGraphicsContext3D::RetireTextureId(GLuint id
) {
675 base::AutoLock
lock(namespace_
->lock
);
676 unsigned context_id
= id
>> 16;
677 unsigned texture_id
= id
& 0xffff;
679 DCHECK_LT(texture_id
, namespace_
->next_texture_id
);
680 DCHECK_EQ(context_id
, context_id_
);
683 GLuint
TestWebGraphicsContext3D::NextBufferId() {
684 base::AutoLock
lock(namespace_
->lock
);
685 GLuint buffer_id
= namespace_
->next_buffer_id
++;
686 DCHECK(buffer_id
< (1 << 16));
687 buffer_id
|= context_id_
<< 16;
691 void TestWebGraphicsContext3D::RetireBufferId(GLuint id
) {
692 base::AutoLock
lock(namespace_
->lock
);
693 unsigned context_id
= id
>> 16;
694 unsigned buffer_id
= id
& 0xffff;
696 DCHECK_LT(buffer_id
, namespace_
->next_buffer_id
);
697 DCHECK_EQ(context_id
, context_id_
);
700 GLuint
TestWebGraphicsContext3D::NextImageId() {
701 base::AutoLock
lock(namespace_
->lock
);
702 GLuint image_id
= namespace_
->next_image_id
++;
703 DCHECK(image_id
< (1 << 16));
704 image_id
|= context_id_
<< 16;
708 void TestWebGraphicsContext3D::RetireImageId(GLuint id
) {
709 base::AutoLock
lock(namespace_
->lock
);
710 unsigned context_id
= id
>> 16;
711 unsigned image_id
= id
& 0xffff;
713 DCHECK_LT(image_id
, namespace_
->next_image_id
);
714 DCHECK_EQ(context_id
, context_id_
);
717 GLuint
TestWebGraphicsContext3D::NextFramebufferId() {
718 base::AutoLock
lock_for_framebuffer_access(namespace_
->lock
);
719 GLuint id
= next_framebuffer_id_
++;
720 DCHECK(id
< (1 << 16));
721 id
|= context_id_
<< 16;
722 framebuffer_set_
.insert(id
);
726 void TestWebGraphicsContext3D::RetireFramebufferId(GLuint id
) {
727 base::AutoLock
lock_for_framebuffer_access(namespace_
->lock
);
728 DCHECK(framebuffer_set_
.find(id
) != framebuffer_set_
.end());
729 framebuffer_set_
.erase(id
);
732 GLuint
TestWebGraphicsContext3D::NextRenderbufferId() {
733 base::AutoLock
lock_for_renderbuffer_access(namespace_
->lock
);
734 GLuint id
= namespace_
->next_renderbuffer_id
++;
735 DCHECK(id
< (1 << 16));
736 id
|= context_id_
<< 16;
737 namespace_
->renderbuffer_set
.insert(id
);
741 void TestWebGraphicsContext3D::RetireRenderbufferId(GLuint id
) {
742 base::AutoLock
lock_for_renderbuffer_access(namespace_
->lock
);
743 DCHECK(namespace_
->renderbuffer_set
.find(id
) !=
744 namespace_
->renderbuffer_set
.end());
745 namespace_
->renderbuffer_set
.erase(id
);
748 void TestWebGraphicsContext3D::SetMaxTransferBufferUsageBytes(
749 size_t max_transfer_buffer_usage_bytes
) {
750 test_capabilities_
.max_transfer_buffer_usage_bytes
=
751 max_transfer_buffer_usage_bytes
;
754 void TestWebGraphicsContext3D::SetMaxSamples(int max_samples
) {
755 test_capabilities_
.gpu
.max_samples
= max_samples
;
758 TestWebGraphicsContext3D::TextureTargets::TextureTargets() {
759 // Initialize default bindings.
760 bound_textures_
[GL_TEXTURE_2D
] = 0;
761 bound_textures_
[GL_TEXTURE_EXTERNAL_OES
] = 0;
762 bound_textures_
[GL_TEXTURE_RECTANGLE_ARB
] = 0;
765 TestWebGraphicsContext3D::TextureTargets::~TextureTargets() {}
767 void TestWebGraphicsContext3D::TextureTargets::BindTexture(
770 // Make sure this is a supported target by seeing if it was bound to before.
771 DCHECK(bound_textures_
.find(target
) != bound_textures_
.end());
772 bound_textures_
[target
] = id
;
775 void TestWebGraphicsContext3D::texParameteri(GLenum target
,
778 CheckTextureIsBound(target
);
779 base::AutoLock
lock_for_texture_access(namespace_
->lock
);
780 scoped_refptr
<TestTexture
> texture
= BoundTexture(target
);
781 DCHECK(texture
->IsValidParameter(pname
));
782 texture
->params
[pname
] = param
;
785 void TestWebGraphicsContext3D::getTexParameteriv(GLenum target
,
788 CheckTextureIsBound(target
);
789 base::AutoLock
lock_for_texture_access(namespace_
->lock
);
790 scoped_refptr
<TestTexture
> texture
= BoundTexture(target
);
791 DCHECK(texture
->IsValidParameter(pname
));
792 TestTexture::TextureParametersMap::iterator it
= texture
->params
.find(pname
);
793 if (it
!= texture
->params
.end())
797 void TestWebGraphicsContext3D::TextureTargets::UnbindTexture(
799 // Bind zero to any targets that the id is bound to.
800 for (TargetTextureMap::iterator it
= bound_textures_
.begin();
801 it
!= bound_textures_
.end();
803 if (it
->second
== id
)
808 GLuint
TestWebGraphicsContext3D::TextureTargets::BoundTexture(
810 DCHECK(bound_textures_
.find(target
) != bound_textures_
.end());
811 return bound_textures_
[target
];
814 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {}
816 TestWebGraphicsContext3D::Buffer::~Buffer() {}
818 TestWebGraphicsContext3D::Image::Image() {}
820 TestWebGraphicsContext3D::Image::~Image() {}