}
TestWebGraphicsContext3D::TestWebGraphicsContext3D()
- : FakeWebGraphicsContext3D(),
- context_id_(s_context_id++),
+ : context_id_(s_context_id++),
times_bind_texture_succeeds_(-1),
times_end_query_succeeds_(-1),
- times_gen_mailbox_succeeds_(-1),
context_lost_(false),
times_map_image_chromium_succeeds_(-1),
times_map_buffer_chromium_succeeds_(-1),
+ current_used_transfer_buffer_usage_bytes_(0),
+ max_used_transfer_buffer_usage_bytes_(0),
next_program_id_(1000),
next_shader_id_(2000),
max_texture_size_(2048),
next_insert_sync_point_(1),
last_waited_sync_point_(0),
bound_buffer_(0),
- peak_transfer_buffer_memory_used_bytes_(0),
weak_ptr_factory_(this) {
CreateNamespace();
}
DCHECK(BoundTextureId(target));
}
+GLuint TestWebGraphicsContext3D::createQueryEXT() { return 1u; }
+
void TestWebGraphicsContext3D::endQueryEXT(GLenum target) {
if (times_end_query_succeeds_ >= 0) {
if (!times_end_query_succeeds_) {
*value = GL_TEXTURE0;
}
-void TestWebGraphicsContext3D::genMailboxCHROMIUM(GLbyte* mailbox) {
- if (times_gen_mailbox_succeeds_ >= 0) {
- if (!times_gen_mailbox_succeeds_) {
- loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
- GL_INNOCENT_CONTEXT_RESET_ARB);
- }
- --times_gen_mailbox_succeeds_;
- }
- if (context_lost_) {
- memset(mailbox, 0, 64);
- return;
+void TestWebGraphicsContext3D::getProgramiv(GLuint program,
+ GLenum pname,
+ GLint* value) {
+ if (pname == GL_LINK_STATUS)
+ *value = 1;
+}
+
+void TestWebGraphicsContext3D::getShaderiv(GLuint shader,
+ GLenum pname,
+ GLint* value) {
+ if (pname == GL_COMPILE_STATUS)
+ *value = 1;
+}
+
+void TestWebGraphicsContext3D::getShaderPrecisionFormat(GLenum shadertype,
+ GLenum precisiontype,
+ GLint* range,
+ GLint* precision) {
+ // Return the minimum precision requirements of the GLES2
+ // specification.
+ switch (precisiontype) {
+ case GL_LOW_INT:
+ range[0] = 8;
+ range[1] = 8;
+ *precision = 0;
+ break;
+ case GL_MEDIUM_INT:
+ range[0] = 10;
+ range[1] = 10;
+ *precision = 0;
+ break;
+ case GL_HIGH_INT:
+ range[0] = 16;
+ range[1] = 16;
+ *precision = 0;
+ break;
+ case GL_LOW_FLOAT:
+ range[0] = 8;
+ range[1] = 8;
+ *precision = 8;
+ break;
+ case GL_MEDIUM_FLOAT:
+ range[0] = 14;
+ range[1] = 14;
+ *precision = 10;
+ break;
+ case GL_HIGH_FLOAT:
+ range[0] = 62;
+ range[1] = 62;
+ *precision = 16;
+ break;
+ default:
+ NOTREACHED();
+ break;
}
+}
+void TestWebGraphicsContext3D::genMailboxCHROMIUM(GLbyte* mailbox) {
static char mailbox_name1 = '1';
static char mailbox_name2 = '1';
mailbox[0] = mailbox_name1;
}
}
+GLuint TestWebGraphicsContext3D::createAndConsumeTextureCHROMIUM(
+ GLenum target,
+ const GLbyte* mailbox) {
+ return createTexture();
+}
+
void TestWebGraphicsContext3D::loseContextCHROMIUM(GLenum current,
GLenum other) {
if (context_lost_)
test_support_->CallAllSyncPointCallbacks();
}
+GLint TestWebGraphicsContext3D::getAttribLocation(GLuint program,
+ const GLchar* name) {
+ return 0;
+}
+
+GLenum TestWebGraphicsContext3D::getError() { return GL_NO_ERROR; }
+
void TestWebGraphicsContext3D::bindBuffer(GLenum target,
GLuint buffer) {
bound_buffer_ = buffer;
return;
}
+ size_t old_size = buffer->size;
+
buffer->pixels.reset(new uint8[size]);
buffer->size = size;
if (data != NULL)
memcpy(buffer->pixels.get(), data, size);
-
- peak_transfer_buffer_memory_used_bytes_ =
- std::max(peak_transfer_buffer_memory_used_bytes_,
- GetTransferBufferMemoryUsedBytes());
+ if (buffer->target == GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM)
+ current_used_transfer_buffer_usage_bytes_ += buffer->size - old_size;
+ max_used_transfer_buffer_usage_bytes_ =
+ std::max(max_used_transfer_buffer_usage_bytes_,
+ current_used_transfer_buffer_usage_bytes_);
}
void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target,
--times_map_buffer_chromium_succeeds_;
}
- peak_transfer_buffer_memory_used_bytes_ =
- std::max(peak_transfer_buffer_memory_used_bytes_,
- GetTransferBufferMemoryUsedBytes());
-
return buffers.get(bound_buffer_)->pixels.get();
}
return true;
}
-GLuint TestWebGraphicsContext3D::createImageCHROMIUM(
- GLsizei width, GLsizei height,
- GLenum internalformat) {
+GLuint TestWebGraphicsContext3D::createImageCHROMIUM(GLsizei width,
+ GLsizei height,
+ GLenum internalformat,
+ GLenum usage) {
DCHECK_EQ(GL_RGBA8_OES, static_cast<int>(internalformat));
GLuint image_id = NextImageId();
base::AutoLock lock(namespace_->lock);
*params = 0;
}
-void* TestWebGraphicsContext3D::mapImageCHROMIUM(GLuint image_id,
- GLenum access) {
+void* TestWebGraphicsContext3D::mapImageCHROMIUM(GLuint image_id) {
base::AutoLock lock(namespace_->lock);
base::ScopedPtrHashMap<unsigned, Image>& images = namespace_->images;
DCHECK_GT(images.count(image_id), 0u);
DCHECK_EQ(context_id, context_id_);
}
-size_t TestWebGraphicsContext3D::GetTransferBufferMemoryUsedBytes() const {
- size_t total_bytes = 0;
- base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers;
- base::ScopedPtrHashMap<unsigned, Buffer>::iterator it = buffers.begin();
- for (; it != buffers.end(); ++it) {
- Buffer* buffer = it->second;
- if (buffer->target == GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM)
- total_bytes += buffer->size;
- }
- return total_bytes;
-}
-
void TestWebGraphicsContext3D::SetMaxTransferBufferUsageBytes(
size_t max_transfer_buffer_usage_bytes) {
test_capabilities_.max_transfer_buffer_usage_bytes =