Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1123)

Unified Diff: cc/test/test_web_graphics_context_3d.cc

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/test/test_web_graphics_context_3d.h ('k') | cc/test/test_web_graphics_context_3d_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/test/test_web_graphics_context_3d.cc
diff --git a/cc/test/test_web_graphics_context_3d.cc b/cc/test/test_web_graphics_context_3d.cc
index 2d82f89a71cdd8005f69f41cecde3d8a6061e9f6..8aa392de290b6d7301b9d79d4ed6559d9f5a7f94 100644
--- a/cc/test/test_web_graphics_context_3d.cc
+++ b/cc/test/test_web_graphics_context_3d.cc
@@ -18,9 +18,6 @@
namespace cc {
-static const GLuint kFramebufferId = 1;
-static const GLuint kRenderbufferId = 2;
-
static unsigned s_context_id = 1;
const GLuint TestWebGraphicsContext3D::kExternalTextureId = 1337;
@@ -34,7 +31,8 @@ TestWebGraphicsContext3D::Namespace*
TestWebGraphicsContext3D::Namespace::Namespace()
: next_buffer_id(1),
next_image_id(1),
- next_texture_id(1) {
+ next_texture_id(1),
+ next_renderbuffer_id(1) {
}
TestWebGraphicsContext3D::Namespace::~Namespace() {
@@ -58,6 +56,8 @@ TestWebGraphicsContext3D::TestWebGraphicsContext3D()
max_used_transfer_buffer_usage_bytes_(0),
next_program_id_(1000),
next_shader_id_(2000),
+ next_framebuffer_id_(1),
+ current_framebuffer_(0),
max_texture_size_(2048),
reshape_called_(false),
width_(0),
@@ -162,13 +162,13 @@ void TestWebGraphicsContext3D::genBuffers(GLsizei count, GLuint* ids) {
void TestWebGraphicsContext3D::genFramebuffers(
GLsizei count, GLuint* ids) {
for (int i = 0; i < count; ++i)
- ids[i] = kFramebufferId | context_id_ << 16;
+ ids[i] = NextFramebufferId();
}
void TestWebGraphicsContext3D::genRenderbuffers(
GLsizei count, GLuint* ids) {
for (int i = 0; i < count; ++i)
- ids[i] = kRenderbufferId | context_id_ << 16;
+ ids[i] = NextRenderbufferId();
}
void TestWebGraphicsContext3D::genTextures(GLsizei count, GLuint* ids) {
@@ -188,14 +188,19 @@ void TestWebGraphicsContext3D::deleteBuffers(GLsizei count, GLuint* ids) {
void TestWebGraphicsContext3D::deleteFramebuffers(
GLsizei count, GLuint* ids) {
- for (int i = 0; i < count; ++i)
- DCHECK_EQ(kFramebufferId | context_id_ << 16, ids[i]);
+ for (int i = 0; i < count; ++i) {
+ if (ids[i]) {
+ RetireFramebufferId(ids[i]);
+ if (ids[i] == current_framebuffer_)
+ current_framebuffer_ = 0;
+ }
+ }
}
void TestWebGraphicsContext3D::deleteRenderbuffers(
GLsizei count, GLuint* ids) {
for (int i = 0; i < count; ++i)
- DCHECK_EQ(kRenderbufferId | context_id_ << 16, ids[i]);
+ RetireRenderbufferId(ids[i]);
}
void TestWebGraphicsContext3D::deleteTextures(GLsizei count, GLuint* ids) {
@@ -294,16 +299,31 @@ void TestWebGraphicsContext3D::useProgram(GLuint program) {
void TestWebGraphicsContext3D::bindFramebuffer(
GLenum target, GLuint framebuffer) {
- if (!framebuffer)
- return;
- DCHECK_EQ(kFramebufferId | context_id_ << 16, framebuffer);
+ base::AutoLock lock_for_framebuffer_access(namespace_->lock);
+ if (framebuffer != 0 &&
+ framebuffer_set_.find(framebuffer) == framebuffer_set_.end()) {
+ ADD_FAILURE() << "bindFramebuffer called with unknown framebuffer";
+ } else if (framebuffer != 0 && (framebuffer >> 16) != context_id_) {
+ ADD_FAILURE()
+ << "bindFramebuffer called with framebuffer from other context";
+ } else {
+ current_framebuffer_ = framebuffer;
+ }
}
void TestWebGraphicsContext3D::bindRenderbuffer(
GLenum target, GLuint renderbuffer) {
if (!renderbuffer)
return;
- DCHECK_EQ(kRenderbufferId | context_id_ << 16, renderbuffer);
+ base::AutoLock lock_for_renderbuffer_access(namespace_->lock);
+ if (renderbuffer != 0 &&
+ namespace_->renderbuffer_set.find(renderbuffer) ==
+ namespace_->renderbuffer_set.end()) {
+ ADD_FAILURE() << "bindRenderbuffer called with unknown renderbuffer";
+ } else if ((renderbuffer >> 16) != context_id_) {
+ ADD_FAILURE()
+ << "bindRenderbuffer called with renderbuffer from other context";
+ }
}
void TestWebGraphicsContext3D::bindTexture(
@@ -370,6 +390,8 @@ void TestWebGraphicsContext3D::getIntegerv(
*value = GL_TEXTURE0;
else if (pname == GL_UNPACK_ALIGNMENT)
*value = unpack_alignment_;
+ else if (pname == GL_FRAMEBUFFER_BINDING)
+ *value = current_framebuffer_;
}
void TestWebGraphicsContext3D::getProgramiv(GLuint program,
@@ -674,6 +696,37 @@ void TestWebGraphicsContext3D::RetireImageId(GLuint id) {
DCHECK_EQ(context_id, context_id_);
}
+GLuint TestWebGraphicsContext3D::NextFramebufferId() {
+ base::AutoLock lock_for_framebuffer_access(namespace_->lock);
+ GLuint id = next_framebuffer_id_++;
+ DCHECK(id < (1 << 16));
+ id |= context_id_ << 16;
+ framebuffer_set_.insert(id);
+ return id;
+}
+
+void TestWebGraphicsContext3D::RetireFramebufferId(GLuint id) {
+ base::AutoLock lock_for_framebuffer_access(namespace_->lock);
+ DCHECK(framebuffer_set_.find(id) != framebuffer_set_.end());
+ framebuffer_set_.erase(id);
+}
+
+GLuint TestWebGraphicsContext3D::NextRenderbufferId() {
+ base::AutoLock lock_for_renderbuffer_access(namespace_->lock);
+ GLuint id = namespace_->next_renderbuffer_id++;
+ DCHECK(id < (1 << 16));
+ id |= context_id_ << 16;
+ namespace_->renderbuffer_set.insert(id);
+ return id;
+}
+
+void TestWebGraphicsContext3D::RetireRenderbufferId(GLuint id) {
+ base::AutoLock lock_for_renderbuffer_access(namespace_->lock);
+ DCHECK(namespace_->renderbuffer_set.find(id) !=
+ namespace_->renderbuffer_set.end());
+ namespace_->renderbuffer_set.erase(id);
+}
+
void TestWebGraphicsContext3D::SetMaxTransferBufferUsageBytes(
size_t max_transfer_buffer_usage_bytes) {
test_capabilities_.max_transfer_buffer_usage_bytes =
« no previous file with comments | « cc/test/test_web_graphics_context_3d.h ('k') | cc/test/test_web_graphics_context_3d_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698