| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/test/test_web_graphics_context_3d.h" | 5 #include "cc/test/test_web_graphics_context_3d.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "cc/test/test_context_support.h" | 14 #include "cc/test/test_context_support.h" |
| 15 #include "gpu/GLES2/gl2extchromium.h" | 15 #include "gpu/GLES2/gl2extchromium.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "third_party/khronos/GLES2/gl2ext.h" | 17 #include "third_party/khronos/GLES2/gl2ext.h" |
| 18 | 18 |
| 19 using blink::WGC3Dboolean; | |
| 20 using blink::WGC3Dchar; | |
| 21 using blink::WGC3Denum; | |
| 22 using blink::WGC3Dint; | |
| 23 using blink::WGC3Dsizei; | |
| 24 using blink::WGC3Dsizeiptr; | |
| 25 using blink::WGC3Duint; | |
| 26 using blink::WebGLId; | |
| 27 using blink::WebGraphicsContext3D; | 19 using blink::WebGraphicsContext3D; |
| 28 | 20 |
| 29 namespace cc { | 21 namespace cc { |
| 30 | 22 |
| 31 static const WebGLId kFramebufferId = 1; | 23 static const GLuint kFramebufferId = 1; |
| 32 static const WebGLId kRenderbufferId = 2; | 24 static const GLuint kRenderbufferId = 2; |
| 33 | 25 |
| 34 static unsigned s_context_id = 1; | 26 static unsigned s_context_id = 1; |
| 35 | 27 |
| 36 const WebGLId TestWebGraphicsContext3D::kExternalTextureId = 1337; | 28 const GLuint TestWebGraphicsContext3D::kExternalTextureId = 1337; |
| 37 | 29 |
| 38 static base::LazyInstance<base::Lock>::Leaky | 30 static base::LazyInstance<base::Lock>::Leaky |
| 39 g_shared_namespace_lock = LAZY_INSTANCE_INITIALIZER; | 31 g_shared_namespace_lock = LAZY_INSTANCE_INITIALIZER; |
| 40 | 32 |
| 41 TestWebGraphicsContext3D::Namespace* | 33 TestWebGraphicsContext3D::Namespace* |
| 42 TestWebGraphicsContext3D::shared_namespace_ = NULL; | 34 TestWebGraphicsContext3D::shared_namespace_ = NULL; |
| 43 | 35 |
| 44 TestWebGraphicsContext3D::Namespace::Namespace() | 36 TestWebGraphicsContext3D::Namespace::Namespace() |
| 45 : next_buffer_id(1), | 37 : next_buffer_id(1), |
| 46 next_image_id(1), | 38 next_image_id(1), |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 reshape_called_ = true; | 97 reshape_called_ = true; |
| 106 width_ = width; | 98 width_ = width; |
| 107 height_ = height; | 99 height_ = height; |
| 108 scale_factor_ = scale_factor; | 100 scale_factor_ = scale_factor; |
| 109 } | 101 } |
| 110 | 102 |
| 111 bool TestWebGraphicsContext3D::isContextLost() { | 103 bool TestWebGraphicsContext3D::isContextLost() { |
| 112 return context_lost_; | 104 return context_lost_; |
| 113 } | 105 } |
| 114 | 106 |
| 115 WGC3Denum TestWebGraphicsContext3D::checkFramebufferStatus( | 107 GLenum TestWebGraphicsContext3D::checkFramebufferStatus( |
| 116 WGC3Denum target) { | 108 GLenum target) { |
| 117 if (context_lost_) | 109 if (context_lost_) |
| 118 return GL_FRAMEBUFFER_UNDEFINED_OES; | 110 return GL_FRAMEBUFFER_UNDEFINED_OES; |
| 119 return GL_FRAMEBUFFER_COMPLETE; | 111 return GL_FRAMEBUFFER_COMPLETE; |
| 120 } | 112 } |
| 121 | 113 |
| 122 blink::WebString TestWebGraphicsContext3D::getString(WGC3Denum name) { | 114 blink::WebString TestWebGraphicsContext3D::getString(GLenum name) { |
| 123 return blink::WebString(); | 115 return blink::WebString(); |
| 124 } | 116 } |
| 125 | 117 |
| 126 WGC3Dint TestWebGraphicsContext3D::getUniformLocation( | 118 GLint TestWebGraphicsContext3D::getUniformLocation( |
| 127 WebGLId program, | 119 GLuint program, |
| 128 const WGC3Dchar* name) { | 120 const GLchar* name) { |
| 129 return 0; | 121 return 0; |
| 130 } | 122 } |
| 131 | 123 |
| 132 WGC3Dsizeiptr TestWebGraphicsContext3D::getVertexAttribOffset( | 124 GLsizeiptr TestWebGraphicsContext3D::getVertexAttribOffset( |
| 133 WGC3Duint index, | 125 GLuint index, |
| 134 WGC3Denum pname) { | 126 GLenum pname) { |
| 135 return 0; | 127 return 0; |
| 136 } | 128 } |
| 137 | 129 |
| 138 WGC3Dboolean TestWebGraphicsContext3D::isBuffer( | 130 GLboolean TestWebGraphicsContext3D::isBuffer( |
| 139 WebGLId buffer) { | 131 GLuint buffer) { |
| 140 return false; | 132 return false; |
| 141 } | 133 } |
| 142 | 134 |
| 143 WGC3Dboolean TestWebGraphicsContext3D::isEnabled( | 135 GLboolean TestWebGraphicsContext3D::isEnabled( |
| 144 WGC3Denum cap) { | 136 GLenum cap) { |
| 145 return false; | 137 return false; |
| 146 } | 138 } |
| 147 | 139 |
| 148 WGC3Dboolean TestWebGraphicsContext3D::isFramebuffer( | 140 GLboolean TestWebGraphicsContext3D::isFramebuffer( |
| 149 WebGLId framebuffer) { | 141 GLuint framebuffer) { |
| 150 return false; | 142 return false; |
| 151 } | 143 } |
| 152 | 144 |
| 153 WGC3Dboolean TestWebGraphicsContext3D::isProgram( | 145 GLboolean TestWebGraphicsContext3D::isProgram( |
| 154 WebGLId program) { | 146 GLuint program) { |
| 155 return false; | 147 return false; |
| 156 } | 148 } |
| 157 | 149 |
| 158 WGC3Dboolean TestWebGraphicsContext3D::isRenderbuffer( | 150 GLboolean TestWebGraphicsContext3D::isRenderbuffer( |
| 159 WebGLId renderbuffer) { | 151 GLuint renderbuffer) { |
| 160 return false; | 152 return false; |
| 161 } | 153 } |
| 162 | 154 |
| 163 WGC3Dboolean TestWebGraphicsContext3D::isShader( | 155 GLboolean TestWebGraphicsContext3D::isShader( |
| 164 WebGLId shader) { | 156 GLuint shader) { |
| 165 return false; | 157 return false; |
| 166 } | 158 } |
| 167 | 159 |
| 168 WGC3Dboolean TestWebGraphicsContext3D::isTexture( | 160 GLboolean TestWebGraphicsContext3D::isTexture( |
| 169 WebGLId texture) { | 161 GLuint texture) { |
| 170 return false; | 162 return false; |
| 171 } | 163 } |
| 172 | 164 |
| 173 void TestWebGraphicsContext3D::genBuffers(WGC3Dsizei count, WebGLId* ids) { | 165 void TestWebGraphicsContext3D::genBuffers(GLsizei count, GLuint* ids) { |
| 174 for (int i = 0; i < count; ++i) | 166 for (int i = 0; i < count; ++i) |
| 175 ids[i] = NextBufferId(); | 167 ids[i] = NextBufferId(); |
| 176 } | 168 } |
| 177 | 169 |
| 178 void TestWebGraphicsContext3D::genFramebuffers( | 170 void TestWebGraphicsContext3D::genFramebuffers( |
| 179 WGC3Dsizei count, WebGLId* ids) { | 171 GLsizei count, GLuint* ids) { |
| 180 for (int i = 0; i < count; ++i) | 172 for (int i = 0; i < count; ++i) |
| 181 ids[i] = kFramebufferId | context_id_ << 16; | 173 ids[i] = kFramebufferId | context_id_ << 16; |
| 182 } | 174 } |
| 183 | 175 |
| 184 void TestWebGraphicsContext3D::genRenderbuffers( | 176 void TestWebGraphicsContext3D::genRenderbuffers( |
| 185 WGC3Dsizei count, WebGLId* ids) { | 177 GLsizei count, GLuint* ids) { |
| 186 for (int i = 0; i < count; ++i) | 178 for (int i = 0; i < count; ++i) |
| 187 ids[i] = kRenderbufferId | context_id_ << 16; | 179 ids[i] = kRenderbufferId | context_id_ << 16; |
| 188 } | 180 } |
| 189 | 181 |
| 190 void TestWebGraphicsContext3D::genTextures(WGC3Dsizei count, WebGLId* ids) { | 182 void TestWebGraphicsContext3D::genTextures(GLsizei count, GLuint* ids) { |
| 191 for (int i = 0; i < count; ++i) { | 183 for (int i = 0; i < count; ++i) { |
| 192 ids[i] = NextTextureId(); | 184 ids[i] = NextTextureId(); |
| 193 DCHECK_NE(ids[i], kExternalTextureId); | 185 DCHECK_NE(ids[i], kExternalTextureId); |
| 194 } | 186 } |
| 195 base::AutoLock lock(namespace_->lock); | 187 base::AutoLock lock(namespace_->lock); |
| 196 for (int i = 0; i < count; ++i) | 188 for (int i = 0; i < count; ++i) |
| 197 namespace_->textures.Append(ids[i], new TestTexture()); | 189 namespace_->textures.Append(ids[i], new TestTexture()); |
| 198 } | 190 } |
| 199 | 191 |
| 200 void TestWebGraphicsContext3D::deleteBuffers(WGC3Dsizei count, WebGLId* ids) { | 192 void TestWebGraphicsContext3D::deleteBuffers(GLsizei count, GLuint* ids) { |
| 201 for (int i = 0; i < count; ++i) | 193 for (int i = 0; i < count; ++i) |
| 202 RetireBufferId(ids[i]); | 194 RetireBufferId(ids[i]); |
| 203 } | 195 } |
| 204 | 196 |
| 205 void TestWebGraphicsContext3D::deleteFramebuffers( | 197 void TestWebGraphicsContext3D::deleteFramebuffers( |
| 206 WGC3Dsizei count, WebGLId* ids) { | 198 GLsizei count, GLuint* ids) { |
| 207 for (int i = 0; i < count; ++i) | 199 for (int i = 0; i < count; ++i) |
| 208 DCHECK_EQ(kFramebufferId | context_id_ << 16, ids[i]); | 200 DCHECK_EQ(kFramebufferId | context_id_ << 16, ids[i]); |
| 209 } | 201 } |
| 210 | 202 |
| 211 void TestWebGraphicsContext3D::deleteRenderbuffers( | 203 void TestWebGraphicsContext3D::deleteRenderbuffers( |
| 212 WGC3Dsizei count, WebGLId* ids) { | 204 GLsizei count, GLuint* ids) { |
| 213 for (int i = 0; i < count; ++i) | 205 for (int i = 0; i < count; ++i) |
| 214 DCHECK_EQ(kRenderbufferId | context_id_ << 16, ids[i]); | 206 DCHECK_EQ(kRenderbufferId | context_id_ << 16, ids[i]); |
| 215 } | 207 } |
| 216 | 208 |
| 217 void TestWebGraphicsContext3D::deleteTextures(WGC3Dsizei count, WebGLId* ids) { | 209 void TestWebGraphicsContext3D::deleteTextures(GLsizei count, GLuint* ids) { |
| 218 for (int i = 0; i < count; ++i) | 210 for (int i = 0; i < count; ++i) |
| 219 RetireTextureId(ids[i]); | 211 RetireTextureId(ids[i]); |
| 220 base::AutoLock lock(namespace_->lock); | 212 base::AutoLock lock(namespace_->lock); |
| 221 for (int i = 0; i < count; ++i) { | 213 for (int i = 0; i < count; ++i) { |
| 222 namespace_->textures.Remove(ids[i]); | 214 namespace_->textures.Remove(ids[i]); |
| 223 texture_targets_.UnbindTexture(ids[i]); | 215 texture_targets_.UnbindTexture(ids[i]); |
| 224 } | 216 } |
| 225 } | 217 } |
| 226 | 218 |
| 227 WebGLId TestWebGraphicsContext3D::createBuffer() { | 219 GLuint TestWebGraphicsContext3D::createBuffer() { |
| 228 WebGLId id; | 220 GLuint id; |
| 229 genBuffers(1, &id); | 221 genBuffers(1, &id); |
| 230 return id; | 222 return id; |
| 231 } | 223 } |
| 232 | 224 |
| 233 WebGLId TestWebGraphicsContext3D::createFramebuffer() { | 225 GLuint TestWebGraphicsContext3D::createFramebuffer() { |
| 234 WebGLId id; | 226 GLuint id; |
| 235 genFramebuffers(1, &id); | 227 genFramebuffers(1, &id); |
| 236 return id; | 228 return id; |
| 237 } | 229 } |
| 238 | 230 |
| 239 WebGLId TestWebGraphicsContext3D::createRenderbuffer() { | 231 GLuint TestWebGraphicsContext3D::createRenderbuffer() { |
| 240 WebGLId id; | 232 GLuint id; |
| 241 genRenderbuffers(1, &id); | 233 genRenderbuffers(1, &id); |
| 242 return id; | 234 return id; |
| 243 } | 235 } |
| 244 | 236 |
| 245 WebGLId TestWebGraphicsContext3D::createTexture() { | 237 GLuint TestWebGraphicsContext3D::createTexture() { |
| 246 WebGLId id; | 238 GLuint id; |
| 247 genTextures(1, &id); | 239 genTextures(1, &id); |
| 248 return id; | 240 return id; |
| 249 } | 241 } |
| 250 | 242 |
| 251 void TestWebGraphicsContext3D::deleteBuffer(WebGLId id) { | 243 void TestWebGraphicsContext3D::deleteBuffer(GLuint id) { |
| 252 deleteBuffers(1, &id); | 244 deleteBuffers(1, &id); |
| 253 } | 245 } |
| 254 | 246 |
| 255 void TestWebGraphicsContext3D::deleteFramebuffer(WebGLId id) { | 247 void TestWebGraphicsContext3D::deleteFramebuffer(GLuint id) { |
| 256 deleteFramebuffers(1, &id); | 248 deleteFramebuffers(1, &id); |
| 257 } | 249 } |
| 258 | 250 |
| 259 void TestWebGraphicsContext3D::deleteRenderbuffer(WebGLId id) { | 251 void TestWebGraphicsContext3D::deleteRenderbuffer(GLuint id) { |
| 260 deleteRenderbuffers(1, &id); | 252 deleteRenderbuffers(1, &id); |
| 261 } | 253 } |
| 262 | 254 |
| 263 void TestWebGraphicsContext3D::deleteTexture(WebGLId id) { | 255 void TestWebGraphicsContext3D::deleteTexture(GLuint id) { |
| 264 deleteTextures(1, &id); | 256 deleteTextures(1, &id); |
| 265 } | 257 } |
| 266 | 258 |
| 267 unsigned TestWebGraphicsContext3D::createProgram() { | 259 unsigned TestWebGraphicsContext3D::createProgram() { |
| 268 unsigned program = next_program_id_++ | context_id_ << 16; | 260 unsigned program = next_program_id_++ | context_id_ << 16; |
| 269 program_set_.insert(program); | 261 program_set_.insert(program); |
| 270 return program; | 262 return program; |
| 271 } | 263 } |
| 272 | 264 |
| 273 WebGLId TestWebGraphicsContext3D::createShader(WGC3Denum) { | 265 GLuint TestWebGraphicsContext3D::createShader(GLenum) { |
| 274 unsigned shader = next_shader_id_++ | context_id_ << 16; | 266 unsigned shader = next_shader_id_++ | context_id_ << 16; |
| 275 shader_set_.insert(shader); | 267 shader_set_.insert(shader); |
| 276 return shader; | 268 return shader; |
| 277 } | 269 } |
| 278 | 270 |
| 279 WebGLId TestWebGraphicsContext3D::createExternalTexture() { | 271 GLuint TestWebGraphicsContext3D::createExternalTexture() { |
| 280 base::AutoLock lock(namespace_->lock); | 272 base::AutoLock lock(namespace_->lock); |
| 281 namespace_->textures.Append(kExternalTextureId, new TestTexture()); | 273 namespace_->textures.Append(kExternalTextureId, new TestTexture()); |
| 282 return kExternalTextureId; | 274 return kExternalTextureId; |
| 283 } | 275 } |
| 284 | 276 |
| 285 void TestWebGraphicsContext3D::deleteProgram(WebGLId id) { | 277 void TestWebGraphicsContext3D::deleteProgram(GLuint id) { |
| 286 if (!program_set_.count(id)) | 278 if (!program_set_.count(id)) |
| 287 ADD_FAILURE() << "deleteProgram called on unknown program " << id; | 279 ADD_FAILURE() << "deleteProgram called on unknown program " << id; |
| 288 program_set_.erase(id); | 280 program_set_.erase(id); |
| 289 } | 281 } |
| 290 | 282 |
| 291 void TestWebGraphicsContext3D::deleteShader(WebGLId id) { | 283 void TestWebGraphicsContext3D::deleteShader(GLuint id) { |
| 292 if (!shader_set_.count(id)) | 284 if (!shader_set_.count(id)) |
| 293 ADD_FAILURE() << "deleteShader called on unknown shader " << id; | 285 ADD_FAILURE() << "deleteShader called on unknown shader " << id; |
| 294 shader_set_.erase(id); | 286 shader_set_.erase(id); |
| 295 } | 287 } |
| 296 | 288 |
| 297 void TestWebGraphicsContext3D::attachShader(WebGLId program, WebGLId shader) { | 289 void TestWebGraphicsContext3D::attachShader(GLuint program, GLuint shader) { |
| 298 if (!program_set_.count(program)) | 290 if (!program_set_.count(program)) |
| 299 ADD_FAILURE() << "attachShader called with unknown program " << program; | 291 ADD_FAILURE() << "attachShader called with unknown program " << program; |
| 300 if (!shader_set_.count(shader)) | 292 if (!shader_set_.count(shader)) |
| 301 ADD_FAILURE() << "attachShader called with unknown shader " << shader; | 293 ADD_FAILURE() << "attachShader called with unknown shader " << shader; |
| 302 } | 294 } |
| 303 | 295 |
| 304 void TestWebGraphicsContext3D::useProgram(WebGLId program) { | 296 void TestWebGraphicsContext3D::useProgram(GLuint program) { |
| 305 if (!program) | 297 if (!program) |
| 306 return; | 298 return; |
| 307 if (!program_set_.count(program)) | 299 if (!program_set_.count(program)) |
| 308 ADD_FAILURE() << "useProgram called on unknown program " << program; | 300 ADD_FAILURE() << "useProgram called on unknown program " << program; |
| 309 } | 301 } |
| 310 | 302 |
| 311 void TestWebGraphicsContext3D::bindFramebuffer( | 303 void TestWebGraphicsContext3D::bindFramebuffer( |
| 312 WGC3Denum target, WebGLId framebuffer) { | 304 GLenum target, GLuint framebuffer) { |
| 313 if (!framebuffer) | 305 if (!framebuffer) |
| 314 return; | 306 return; |
| 315 DCHECK_EQ(kFramebufferId | context_id_ << 16, framebuffer); | 307 DCHECK_EQ(kFramebufferId | context_id_ << 16, framebuffer); |
| 316 } | 308 } |
| 317 | 309 |
| 318 void TestWebGraphicsContext3D::bindRenderbuffer( | 310 void TestWebGraphicsContext3D::bindRenderbuffer( |
| 319 WGC3Denum target, WebGLId renderbuffer) { | 311 GLenum target, GLuint renderbuffer) { |
| 320 if (!renderbuffer) | 312 if (!renderbuffer) |
| 321 return; | 313 return; |
| 322 DCHECK_EQ(kRenderbufferId | context_id_ << 16, renderbuffer); | 314 DCHECK_EQ(kRenderbufferId | context_id_ << 16, renderbuffer); |
| 323 } | 315 } |
| 324 | 316 |
| 325 void TestWebGraphicsContext3D::bindTexture( | 317 void TestWebGraphicsContext3D::bindTexture( |
| 326 WGC3Denum target, WebGLId texture_id) { | 318 GLenum target, GLuint texture_id) { |
| 327 if (times_bind_texture_succeeds_ >= 0) { | 319 if (times_bind_texture_succeeds_ >= 0) { |
| 328 if (!times_bind_texture_succeeds_) { | 320 if (!times_bind_texture_succeeds_) { |
| 329 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 321 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 330 GL_INNOCENT_CONTEXT_RESET_ARB); | 322 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 331 } | 323 } |
| 332 --times_bind_texture_succeeds_; | 324 --times_bind_texture_succeeds_; |
| 333 } | 325 } |
| 334 | 326 |
| 335 if (!texture_id) | 327 if (!texture_id) |
| 336 return; | 328 return; |
| 337 base::AutoLock lock(namespace_->lock); | 329 base::AutoLock lock(namespace_->lock); |
| 338 DCHECK(namespace_->textures.ContainsId(texture_id)); | 330 DCHECK(namespace_->textures.ContainsId(texture_id)); |
| 339 texture_targets_.BindTexture(target, texture_id); | 331 texture_targets_.BindTexture(target, texture_id); |
| 340 used_textures_.insert(texture_id); | 332 used_textures_.insert(texture_id); |
| 341 } | 333 } |
| 342 | 334 |
| 343 blink::WebGLId TestWebGraphicsContext3D::BoundTextureId( | 335 GLuint TestWebGraphicsContext3D::BoundTextureId( |
| 344 blink::WGC3Denum target) { | 336 GLenum target) { |
| 345 return texture_targets_.BoundTexture(target); | 337 return texture_targets_.BoundTexture(target); |
| 346 } | 338 } |
| 347 | 339 |
| 348 scoped_refptr<TestTexture> TestWebGraphicsContext3D::BoundTexture( | 340 scoped_refptr<TestTexture> TestWebGraphicsContext3D::BoundTexture( |
| 349 WGC3Denum target) { | 341 GLenum target) { |
| 350 // The caller is expected to lock the namespace for texture access. | 342 // The caller is expected to lock the namespace for texture access. |
| 351 namespace_->lock.AssertAcquired(); | 343 namespace_->lock.AssertAcquired(); |
| 352 return namespace_->textures.TextureForId(BoundTextureId(target)); | 344 return namespace_->textures.TextureForId(BoundTextureId(target)); |
| 353 } | 345 } |
| 354 | 346 |
| 355 void TestWebGraphicsContext3D::CheckTextureIsBound(WGC3Denum target) { | 347 void TestWebGraphicsContext3D::CheckTextureIsBound(GLenum target) { |
| 356 DCHECK(BoundTextureId(target)); | 348 DCHECK(BoundTextureId(target)); |
| 357 } | 349 } |
| 358 | 350 |
| 359 void TestWebGraphicsContext3D::endQueryEXT(WGC3Denum target) { | 351 void TestWebGraphicsContext3D::endQueryEXT(GLenum target) { |
| 360 if (times_end_query_succeeds_ >= 0) { | 352 if (times_end_query_succeeds_ >= 0) { |
| 361 if (!times_end_query_succeeds_) { | 353 if (!times_end_query_succeeds_) { |
| 362 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 354 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 363 GL_INNOCENT_CONTEXT_RESET_ARB); | 355 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 364 } | 356 } |
| 365 --times_end_query_succeeds_; | 357 --times_end_query_succeeds_; |
| 366 } | 358 } |
| 367 } | 359 } |
| 368 | 360 |
| 369 void TestWebGraphicsContext3D::getQueryObjectuivEXT( | 361 void TestWebGraphicsContext3D::getQueryObjectuivEXT( |
| 370 WebGLId query, | 362 GLuint query, |
| 371 WGC3Denum pname, | 363 GLenum pname, |
| 372 WGC3Duint* params) { | 364 GLuint* params) { |
| 373 // If the context is lost, behave as if result is available. | 365 // If the context is lost, behave as if result is available. |
| 374 if (pname == GL_QUERY_RESULT_AVAILABLE_EXT) | 366 if (pname == GL_QUERY_RESULT_AVAILABLE_EXT) |
| 375 *params = 1; | 367 *params = 1; |
| 376 } | 368 } |
| 377 | 369 |
| 378 void TestWebGraphicsContext3D::getIntegerv( | 370 void TestWebGraphicsContext3D::getIntegerv( |
| 379 WGC3Denum pname, | 371 GLenum pname, |
| 380 blink::WGC3Dint* value) { | 372 GLint* value) { |
| 381 if (pname == GL_MAX_TEXTURE_SIZE) | 373 if (pname == GL_MAX_TEXTURE_SIZE) |
| 382 *value = max_texture_size_; | 374 *value = max_texture_size_; |
| 383 else if (pname == GL_ACTIVE_TEXTURE) | 375 else if (pname == GL_ACTIVE_TEXTURE) |
| 384 *value = GL_TEXTURE0; | 376 *value = GL_TEXTURE0; |
| 385 } | 377 } |
| 386 | 378 |
| 387 void TestWebGraphicsContext3D::genMailboxCHROMIUM(blink::WGC3Dbyte* mailbox) { | 379 void TestWebGraphicsContext3D::genMailboxCHROMIUM(GLbyte* mailbox) { |
| 388 if (times_gen_mailbox_succeeds_ >= 0) { | 380 if (times_gen_mailbox_succeeds_ >= 0) { |
| 389 if (!times_gen_mailbox_succeeds_) { | 381 if (!times_gen_mailbox_succeeds_) { |
| 390 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 382 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 391 GL_INNOCENT_CONTEXT_RESET_ARB); | 383 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 392 } | 384 } |
| 393 --times_gen_mailbox_succeeds_; | 385 --times_gen_mailbox_succeeds_; |
| 394 } | 386 } |
| 395 if (context_lost_) { | 387 if (context_lost_) { |
| 396 memset(mailbox, 0, 64); | 388 memset(mailbox, 0, 64); |
| 397 return; | 389 return; |
| 398 } | 390 } |
| 399 | 391 |
| 400 static char mailbox_name1 = '1'; | 392 static char mailbox_name1 = '1'; |
| 401 static char mailbox_name2 = '1'; | 393 static char mailbox_name2 = '1'; |
| 402 mailbox[0] = mailbox_name1; | 394 mailbox[0] = mailbox_name1; |
| 403 mailbox[1] = mailbox_name2; | 395 mailbox[1] = mailbox_name2; |
| 404 mailbox[2] = '\0'; | 396 mailbox[2] = '\0'; |
| 405 if (++mailbox_name1 == 0) { | 397 if (++mailbox_name1 == 0) { |
| 406 mailbox_name1 = '1'; | 398 mailbox_name1 = '1'; |
| 407 ++mailbox_name2; | 399 ++mailbox_name2; |
| 408 } | 400 } |
| 409 } | 401 } |
| 410 | 402 |
| 411 void TestWebGraphicsContext3D::setContextLostCallback( | 403 void TestWebGraphicsContext3D::setContextLostCallback( |
| 412 blink::WebGraphicsContext3D::WebGraphicsContextLostCallback* callback) { | 404 blink::WebGraphicsContext3D::WebGraphicsContextLostCallback* callback) { |
| 413 context_lost_callback_ = callback; | 405 context_lost_callback_ = callback; |
| 414 } | 406 } |
| 415 | 407 |
| 416 void TestWebGraphicsContext3D::loseContextCHROMIUM(WGC3Denum current, | 408 void TestWebGraphicsContext3D::loseContextCHROMIUM(GLenum current, |
| 417 WGC3Denum other) { | 409 GLenum other) { |
| 418 if (context_lost_) | 410 if (context_lost_) |
| 419 return; | 411 return; |
| 420 context_lost_ = true; | 412 context_lost_ = true; |
| 421 if (context_lost_callback_) | 413 if (context_lost_callback_) |
| 422 context_lost_callback_->onContextLost(); | 414 context_lost_callback_->onContextLost(); |
| 423 | 415 |
| 424 for (size_t i = 0; i < shared_contexts_.size(); ++i) | 416 for (size_t i = 0; i < shared_contexts_.size(); ++i) |
| 425 shared_contexts_[i]->loseContextCHROMIUM(current, other); | 417 shared_contexts_[i]->loseContextCHROMIUM(current, other); |
| 426 shared_contexts_.clear(); | 418 shared_contexts_.clear(); |
| 427 } | 419 } |
| 428 | 420 |
| 429 void TestWebGraphicsContext3D::finish() { | 421 void TestWebGraphicsContext3D::finish() { |
| 430 test_support_->CallAllSyncPointCallbacks(); | 422 test_support_->CallAllSyncPointCallbacks(); |
| 431 } | 423 } |
| 432 | 424 |
| 433 void TestWebGraphicsContext3D::flush() { | 425 void TestWebGraphicsContext3D::flush() { |
| 434 test_support_->CallAllSyncPointCallbacks(); | 426 test_support_->CallAllSyncPointCallbacks(); |
| 435 } | 427 } |
| 436 | 428 |
| 437 void TestWebGraphicsContext3D::bindBuffer(blink::WGC3Denum target, | 429 void TestWebGraphicsContext3D::bindBuffer(GLenum target, |
| 438 blink::WebGLId buffer) { | 430 GLuint buffer) { |
| 439 bound_buffer_ = buffer; | 431 bound_buffer_ = buffer; |
| 440 if (!bound_buffer_) | 432 if (!bound_buffer_) |
| 441 return; | 433 return; |
| 442 unsigned context_id = buffer >> 16; | 434 unsigned context_id = buffer >> 16; |
| 443 unsigned buffer_id = buffer & 0xffff; | 435 unsigned buffer_id = buffer & 0xffff; |
| 444 base::AutoLock lock(namespace_->lock); | 436 base::AutoLock lock(namespace_->lock); |
| 445 DCHECK(buffer_id); | 437 DCHECK(buffer_id); |
| 446 DCHECK_LT(buffer_id, namespace_->next_buffer_id); | 438 DCHECK_LT(buffer_id, namespace_->next_buffer_id); |
| 447 DCHECK_EQ(context_id, context_id_); | 439 DCHECK_EQ(context_id, context_id_); |
| 448 | 440 |
| 449 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; | 441 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
| 450 if (buffers.count(bound_buffer_) == 0) | 442 if (buffers.count(bound_buffer_) == 0) |
| 451 buffers.set(bound_buffer_, make_scoped_ptr(new Buffer).Pass()); | 443 buffers.set(bound_buffer_, make_scoped_ptr(new Buffer).Pass()); |
| 452 | 444 |
| 453 buffers.get(bound_buffer_)->target = target; | 445 buffers.get(bound_buffer_)->target = target; |
| 454 } | 446 } |
| 455 | 447 |
| 456 void TestWebGraphicsContext3D::bufferData(blink::WGC3Denum target, | 448 void TestWebGraphicsContext3D::bufferData(GLenum target, |
| 457 blink::WGC3Dsizeiptr size, | 449 GLsizeiptr size, |
| 458 const void* data, | 450 const void* data, |
| 459 blink::WGC3Denum usage) { | 451 GLenum usage) { |
| 460 base::AutoLock lock(namespace_->lock); | 452 base::AutoLock lock(namespace_->lock); |
| 461 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; | 453 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
| 462 DCHECK_GT(buffers.count(bound_buffer_), 0u); | 454 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
| 463 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); | 455 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); |
| 464 Buffer* buffer = buffers.get(bound_buffer_); | 456 Buffer* buffer = buffers.get(bound_buffer_); |
| 465 if (context_lost_) { | 457 if (context_lost_) { |
| 466 buffer->pixels.reset(); | 458 buffer->pixels.reset(); |
| 467 return; | 459 return; |
| 468 } | 460 } |
| 469 | 461 |
| 470 buffer->pixels.reset(new uint8[size]); | 462 buffer->pixels.reset(new uint8[size]); |
| 471 buffer->size = size; | 463 buffer->size = size; |
| 472 if (data != NULL) | 464 if (data != NULL) |
| 473 memcpy(buffer->pixels.get(), data, size); | 465 memcpy(buffer->pixels.get(), data, size); |
| 474 | 466 |
| 475 peak_transfer_buffer_memory_used_bytes_ = | 467 peak_transfer_buffer_memory_used_bytes_ = |
| 476 std::max(peak_transfer_buffer_memory_used_bytes_, | 468 std::max(peak_transfer_buffer_memory_used_bytes_, |
| 477 GetTransferBufferMemoryUsedBytes()); | 469 GetTransferBufferMemoryUsedBytes()); |
| 478 } | 470 } |
| 479 | 471 |
| 480 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(blink::WGC3Denum target, | 472 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target, |
| 481 blink::WGC3Denum access) { | 473 GLenum access) { |
| 482 base::AutoLock lock(namespace_->lock); | 474 base::AutoLock lock(namespace_->lock); |
| 483 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; | 475 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
| 484 DCHECK_GT(buffers.count(bound_buffer_), 0u); | 476 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
| 485 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); | 477 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); |
| 486 if (times_map_buffer_chromium_succeeds_ >= 0) { | 478 if (times_map_buffer_chromium_succeeds_ >= 0) { |
| 487 if (!times_map_buffer_chromium_succeeds_) { | 479 if (!times_map_buffer_chromium_succeeds_) { |
| 488 return NULL; | 480 return NULL; |
| 489 } | 481 } |
| 490 --times_map_buffer_chromium_succeeds_; | 482 --times_map_buffer_chromium_succeeds_; |
| 491 } | 483 } |
| 492 | 484 |
| 493 peak_transfer_buffer_memory_used_bytes_ = | 485 peak_transfer_buffer_memory_used_bytes_ = |
| 494 std::max(peak_transfer_buffer_memory_used_bytes_, | 486 std::max(peak_transfer_buffer_memory_used_bytes_, |
| 495 GetTransferBufferMemoryUsedBytes()); | 487 GetTransferBufferMemoryUsedBytes()); |
| 496 | 488 |
| 497 return buffers.get(bound_buffer_)->pixels.get(); | 489 return buffers.get(bound_buffer_)->pixels.get(); |
| 498 } | 490 } |
| 499 | 491 |
| 500 blink::WGC3Dboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM( | 492 GLboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM( |
| 501 blink::WGC3Denum target) { | 493 GLenum target) { |
| 502 base::AutoLock lock(namespace_->lock); | 494 base::AutoLock lock(namespace_->lock); |
| 503 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; | 495 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
| 504 DCHECK_GT(buffers.count(bound_buffer_), 0u); | 496 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
| 505 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); | 497 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); |
| 506 buffers.get(bound_buffer_)->pixels.reset(); | 498 buffers.get(bound_buffer_)->pixels.reset(); |
| 507 return true; | 499 return true; |
| 508 } | 500 } |
| 509 | 501 |
| 510 blink::WGC3Duint TestWebGraphicsContext3D::createImageCHROMIUM( | 502 GLuint TestWebGraphicsContext3D::createImageCHROMIUM( |
| 511 blink::WGC3Dsizei width, blink::WGC3Dsizei height, | 503 GLsizei width, GLsizei height, |
| 512 blink::WGC3Denum internalformat) { | 504 GLenum internalformat) { |
| 513 DCHECK_EQ(GL_RGBA8_OES, static_cast<int>(internalformat)); | 505 DCHECK_EQ(GL_RGBA8_OES, static_cast<int>(internalformat)); |
| 514 blink::WGC3Duint image_id = NextImageId(); | 506 GLuint image_id = NextImageId(); |
| 515 base::AutoLock lock(namespace_->lock); | 507 base::AutoLock lock(namespace_->lock); |
| 516 base::ScopedPtrHashMap<unsigned, Image>& images = namespace_->images; | 508 base::ScopedPtrHashMap<unsigned, Image>& images = namespace_->images; |
| 517 images.set(image_id, make_scoped_ptr(new Image).Pass()); | 509 images.set(image_id, make_scoped_ptr(new Image).Pass()); |
| 518 images.get(image_id)->pixels.reset(new uint8[width * height * 4]); | 510 images.get(image_id)->pixels.reset(new uint8[width * height * 4]); |
| 519 return image_id; | 511 return image_id; |
| 520 } | 512 } |
| 521 | 513 |
| 522 void TestWebGraphicsContext3D::destroyImageCHROMIUM( | 514 void TestWebGraphicsContext3D::destroyImageCHROMIUM( |
| 523 blink::WGC3Duint id) { | 515 GLuint id) { |
| 524 RetireImageId(id); | 516 RetireImageId(id); |
| 525 } | 517 } |
| 526 | 518 |
| 527 void TestWebGraphicsContext3D::getImageParameterivCHROMIUM( | 519 void TestWebGraphicsContext3D::getImageParameterivCHROMIUM( |
| 528 blink::WGC3Duint image_id, | 520 GLuint image_id, |
| 529 blink::WGC3Denum pname, | 521 GLenum pname, |
| 530 blink::WGC3Dint* params) { | 522 GLint* params) { |
| 531 base::AutoLock lock(namespace_->lock); | 523 base::AutoLock lock(namespace_->lock); |
| 532 DCHECK_GT(namespace_->images.count(image_id), 0u); | 524 DCHECK_GT(namespace_->images.count(image_id), 0u); |
| 533 DCHECK_EQ(GL_IMAGE_ROWBYTES_CHROMIUM, static_cast<int>(pname)); | 525 DCHECK_EQ(GL_IMAGE_ROWBYTES_CHROMIUM, static_cast<int>(pname)); |
| 534 *params = 0; | 526 *params = 0; |
| 535 } | 527 } |
| 536 | 528 |
| 537 void* TestWebGraphicsContext3D::mapImageCHROMIUM(blink::WGC3Duint image_id, | 529 void* TestWebGraphicsContext3D::mapImageCHROMIUM(GLuint image_id, |
| 538 blink::WGC3Denum access) { | 530 GLenum access) { |
| 539 base::AutoLock lock(namespace_->lock); | 531 base::AutoLock lock(namespace_->lock); |
| 540 base::ScopedPtrHashMap<unsigned, Image>& images = namespace_->images; | 532 base::ScopedPtrHashMap<unsigned, Image>& images = namespace_->images; |
| 541 DCHECK_GT(images.count(image_id), 0u); | 533 DCHECK_GT(images.count(image_id), 0u); |
| 542 if (times_map_image_chromium_succeeds_ >= 0) { | 534 if (times_map_image_chromium_succeeds_ >= 0) { |
| 543 if (!times_map_image_chromium_succeeds_) { | 535 if (!times_map_image_chromium_succeeds_) { |
| 544 return NULL; | 536 return NULL; |
| 545 } | 537 } |
| 546 --times_map_image_chromium_succeeds_; | 538 --times_map_image_chromium_succeeds_; |
| 547 } | 539 } |
| 548 return images.get(image_id)->pixels.get(); | 540 return images.get(image_id)->pixels.get(); |
| 549 } | 541 } |
| 550 | 542 |
| 551 void TestWebGraphicsContext3D::unmapImageCHROMIUM( | 543 void TestWebGraphicsContext3D::unmapImageCHROMIUM( |
| 552 blink::WGC3Duint image_id) { | 544 GLuint image_id) { |
| 553 base::AutoLock lock(namespace_->lock); | 545 base::AutoLock lock(namespace_->lock); |
| 554 DCHECK_GT(namespace_->images.count(image_id), 0u); | 546 DCHECK_GT(namespace_->images.count(image_id), 0u); |
| 555 } | 547 } |
| 556 | 548 |
| 557 unsigned TestWebGraphicsContext3D::insertSyncPoint() { | 549 unsigned TestWebGraphicsContext3D::insertSyncPoint() { |
| 558 return next_insert_sync_point_++; | 550 return next_insert_sync_point_++; |
| 559 } | 551 } |
| 560 | 552 |
| 561 void TestWebGraphicsContext3D::waitSyncPoint(unsigned sync_point) { | 553 void TestWebGraphicsContext3D::waitSyncPoint(unsigned sync_point) { |
| 562 if (sync_point) | 554 if (sync_point) |
| 563 last_waited_sync_point_ = sync_point; | 555 last_waited_sync_point_ = sync_point; |
| 564 } | 556 } |
| 565 | 557 |
| 566 size_t TestWebGraphicsContext3D::NumTextures() const { | 558 size_t TestWebGraphicsContext3D::NumTextures() const { |
| 567 base::AutoLock lock(namespace_->lock); | 559 base::AutoLock lock(namespace_->lock); |
| 568 return namespace_->textures.Size(); | 560 return namespace_->textures.Size(); |
| 569 } | 561 } |
| 570 | 562 |
| 571 blink::WebGLId TestWebGraphicsContext3D::TextureAt(int i) const { | 563 GLuint TestWebGraphicsContext3D::TextureAt(int i) const { |
| 572 base::AutoLock lock(namespace_->lock); | 564 base::AutoLock lock(namespace_->lock); |
| 573 return namespace_->textures.IdAt(i); | 565 return namespace_->textures.IdAt(i); |
| 574 } | 566 } |
| 575 | 567 |
| 576 WebGLId TestWebGraphicsContext3D::NextTextureId() { | 568 GLuint TestWebGraphicsContext3D::NextTextureId() { |
| 577 base::AutoLock lock(namespace_->lock); | 569 base::AutoLock lock(namespace_->lock); |
| 578 WebGLId texture_id = namespace_->next_texture_id++; | 570 GLuint texture_id = namespace_->next_texture_id++; |
| 579 DCHECK(texture_id < (1 << 16)); | 571 DCHECK(texture_id < (1 << 16)); |
| 580 texture_id |= context_id_ << 16; | 572 texture_id |= context_id_ << 16; |
| 581 return texture_id; | 573 return texture_id; |
| 582 } | 574 } |
| 583 | 575 |
| 584 void TestWebGraphicsContext3D::RetireTextureId(WebGLId id) { | 576 void TestWebGraphicsContext3D::RetireTextureId(GLuint id) { |
| 585 base::AutoLock lock(namespace_->lock); | 577 base::AutoLock lock(namespace_->lock); |
| 586 unsigned context_id = id >> 16; | 578 unsigned context_id = id >> 16; |
| 587 unsigned texture_id = id & 0xffff; | 579 unsigned texture_id = id & 0xffff; |
| 588 DCHECK(texture_id); | 580 DCHECK(texture_id); |
| 589 DCHECK_LT(texture_id, namespace_->next_texture_id); | 581 DCHECK_LT(texture_id, namespace_->next_texture_id); |
| 590 DCHECK_EQ(context_id, context_id_); | 582 DCHECK_EQ(context_id, context_id_); |
| 591 } | 583 } |
| 592 | 584 |
| 593 WebGLId TestWebGraphicsContext3D::NextBufferId() { | 585 GLuint TestWebGraphicsContext3D::NextBufferId() { |
| 594 base::AutoLock lock(namespace_->lock); | 586 base::AutoLock lock(namespace_->lock); |
| 595 WebGLId buffer_id = namespace_->next_buffer_id++; | 587 GLuint buffer_id = namespace_->next_buffer_id++; |
| 596 DCHECK(buffer_id < (1 << 16)); | 588 DCHECK(buffer_id < (1 << 16)); |
| 597 buffer_id |= context_id_ << 16; | 589 buffer_id |= context_id_ << 16; |
| 598 return buffer_id; | 590 return buffer_id; |
| 599 } | 591 } |
| 600 | 592 |
| 601 void TestWebGraphicsContext3D::RetireBufferId(WebGLId id) { | 593 void TestWebGraphicsContext3D::RetireBufferId(GLuint id) { |
| 602 base::AutoLock lock(namespace_->lock); | 594 base::AutoLock lock(namespace_->lock); |
| 603 unsigned context_id = id >> 16; | 595 unsigned context_id = id >> 16; |
| 604 unsigned buffer_id = id & 0xffff; | 596 unsigned buffer_id = id & 0xffff; |
| 605 DCHECK(buffer_id); | 597 DCHECK(buffer_id); |
| 606 DCHECK_LT(buffer_id, namespace_->next_buffer_id); | 598 DCHECK_LT(buffer_id, namespace_->next_buffer_id); |
| 607 DCHECK_EQ(context_id, context_id_); | 599 DCHECK_EQ(context_id, context_id_); |
| 608 } | 600 } |
| 609 | 601 |
| 610 blink::WGC3Duint TestWebGraphicsContext3D::NextImageId() { | 602 GLuint TestWebGraphicsContext3D::NextImageId() { |
| 611 base::AutoLock lock(namespace_->lock); | 603 base::AutoLock lock(namespace_->lock); |
| 612 WGC3Duint image_id = namespace_->next_image_id++; | 604 GLuint image_id = namespace_->next_image_id++; |
| 613 DCHECK(image_id < (1 << 16)); | 605 DCHECK(image_id < (1 << 16)); |
| 614 image_id |= context_id_ << 16; | 606 image_id |= context_id_ << 16; |
| 615 return image_id; | 607 return image_id; |
| 616 } | 608 } |
| 617 | 609 |
| 618 void TestWebGraphicsContext3D::RetireImageId(WebGLId id) { | 610 void TestWebGraphicsContext3D::RetireImageId(GLuint id) { |
| 619 base::AutoLock lock(namespace_->lock); | 611 base::AutoLock lock(namespace_->lock); |
| 620 unsigned context_id = id >> 16; | 612 unsigned context_id = id >> 16; |
| 621 unsigned image_id = id & 0xffff; | 613 unsigned image_id = id & 0xffff; |
| 622 DCHECK(image_id); | 614 DCHECK(image_id); |
| 623 DCHECK_LT(image_id, namespace_->next_image_id); | 615 DCHECK_LT(image_id, namespace_->next_image_id); |
| 624 DCHECK_EQ(context_id, context_id_); | 616 DCHECK_EQ(context_id, context_id_); |
| 625 } | 617 } |
| 626 | 618 |
| 627 size_t TestWebGraphicsContext3D::GetTransferBufferMemoryUsedBytes() const { | 619 size_t TestWebGraphicsContext3D::GetTransferBufferMemoryUsedBytes() const { |
| 628 size_t total_bytes = 0; | 620 size_t total_bytes = 0; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 645 TestWebGraphicsContext3D::TextureTargets::TextureTargets() { | 637 TestWebGraphicsContext3D::TextureTargets::TextureTargets() { |
| 646 // Initialize default bindings. | 638 // Initialize default bindings. |
| 647 bound_textures_[GL_TEXTURE_2D] = 0; | 639 bound_textures_[GL_TEXTURE_2D] = 0; |
| 648 bound_textures_[GL_TEXTURE_EXTERNAL_OES] = 0; | 640 bound_textures_[GL_TEXTURE_EXTERNAL_OES] = 0; |
| 649 bound_textures_[GL_TEXTURE_RECTANGLE_ARB] = 0; | 641 bound_textures_[GL_TEXTURE_RECTANGLE_ARB] = 0; |
| 650 } | 642 } |
| 651 | 643 |
| 652 TestWebGraphicsContext3D::TextureTargets::~TextureTargets() {} | 644 TestWebGraphicsContext3D::TextureTargets::~TextureTargets() {} |
| 653 | 645 |
| 654 void TestWebGraphicsContext3D::TextureTargets::BindTexture( | 646 void TestWebGraphicsContext3D::TextureTargets::BindTexture( |
| 655 blink::WGC3Denum target, | 647 GLenum target, |
| 656 blink::WebGLId id) { | 648 GLuint id) { |
| 657 // Make sure this is a supported target by seeing if it was bound to before. | 649 // Make sure this is a supported target by seeing if it was bound to before. |
| 658 DCHECK(bound_textures_.find(target) != bound_textures_.end()); | 650 DCHECK(bound_textures_.find(target) != bound_textures_.end()); |
| 659 bound_textures_[target] = id; | 651 bound_textures_[target] = id; |
| 660 } | 652 } |
| 661 | 653 |
| 662 void TestWebGraphicsContext3D::texParameteri(blink::WGC3Denum target, | 654 void TestWebGraphicsContext3D::texParameteri(GLenum target, |
| 663 blink::WGC3Denum pname, | 655 GLenum pname, |
| 664 blink::WGC3Dint param) { | 656 GLint param) { |
| 665 CheckTextureIsBound(target); | 657 CheckTextureIsBound(target); |
| 666 base::AutoLock lock_for_texture_access(namespace_->lock); | 658 base::AutoLock lock_for_texture_access(namespace_->lock); |
| 667 scoped_refptr<TestTexture> texture = BoundTexture(target); | 659 scoped_refptr<TestTexture> texture = BoundTexture(target); |
| 668 DCHECK(texture->IsValidParameter(pname)); | 660 DCHECK(texture->IsValidParameter(pname)); |
| 669 texture->params[pname] = param; | 661 texture->params[pname] = param; |
| 670 } | 662 } |
| 671 | 663 |
| 672 void TestWebGraphicsContext3D::getTexParameteriv(blink::WGC3Denum target, | 664 void TestWebGraphicsContext3D::getTexParameteriv(GLenum target, |
| 673 blink::WGC3Denum pname, | 665 GLenum pname, |
| 674 blink::WGC3Dint* value) { | 666 GLint* value) { |
| 675 CheckTextureIsBound(target); | 667 CheckTextureIsBound(target); |
| 676 base::AutoLock lock_for_texture_access(namespace_->lock); | 668 base::AutoLock lock_for_texture_access(namespace_->lock); |
| 677 scoped_refptr<TestTexture> texture = BoundTexture(target); | 669 scoped_refptr<TestTexture> texture = BoundTexture(target); |
| 678 DCHECK(texture->IsValidParameter(pname)); | 670 DCHECK(texture->IsValidParameter(pname)); |
| 679 TestTexture::TextureParametersMap::iterator it = texture->params.find(pname); | 671 TestTexture::TextureParametersMap::iterator it = texture->params.find(pname); |
| 680 if (it != texture->params.end()) | 672 if (it != texture->params.end()) |
| 681 *value = it->second; | 673 *value = it->second; |
| 682 } | 674 } |
| 683 | 675 |
| 684 void TestWebGraphicsContext3D::TextureTargets::UnbindTexture( | 676 void TestWebGraphicsContext3D::TextureTargets::UnbindTexture( |
| 685 blink::WebGLId id) { | 677 GLuint id) { |
| 686 // Bind zero to any targets that the id is bound to. | 678 // Bind zero to any targets that the id is bound to. |
| 687 for (TargetTextureMap::iterator it = bound_textures_.begin(); | 679 for (TargetTextureMap::iterator it = bound_textures_.begin(); |
| 688 it != bound_textures_.end(); | 680 it != bound_textures_.end(); |
| 689 it++) { | 681 it++) { |
| 690 if (it->second == id) | 682 if (it->second == id) |
| 691 it->second = 0; | 683 it->second = 0; |
| 692 } | 684 } |
| 693 } | 685 } |
| 694 | 686 |
| 695 blink::WebGLId TestWebGraphicsContext3D::TextureTargets::BoundTexture( | 687 GLuint TestWebGraphicsContext3D::TextureTargets::BoundTexture( |
| 696 blink::WGC3Denum target) { | 688 GLenum target) { |
| 697 DCHECK(bound_textures_.find(target) != bound_textures_.end()); | 689 DCHECK(bound_textures_.find(target) != bound_textures_.end()); |
| 698 return bound_textures_[target]; | 690 return bound_textures_[target]; |
| 699 } | 691 } |
| 700 | 692 |
| 701 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} | 693 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} |
| 702 | 694 |
| 703 TestWebGraphicsContext3D::Buffer::~Buffer() {} | 695 TestWebGraphicsContext3D::Buffer::~Buffer() {} |
| 704 | 696 |
| 705 TestWebGraphicsContext3D::Image::Image() {} | 697 TestWebGraphicsContext3D::Image::Image() {} |
| 706 | 698 |
| 707 TestWebGraphicsContext3D::Image::~Image() {} | 699 TestWebGraphicsContext3D::Image::~Image() {} |
| 708 | 700 |
| 709 } // namespace cc | 701 } // namespace cc |
| OLD | NEW |