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

Side by Side Diff: cc/test/test_web_graphics_context_3d.cc

Issue 46163003: Consolidate test contexts and remove unused ones (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/test/test_web_graphics_context_3d.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "third_party/khronos/GLES2/gl2ext.h" 17 #include "third_party/khronos/GLES2/gl2ext.h"
17 18
18 using WebKit::WGC3Dboolean; 19 using WebKit::WGC3Dboolean;
19 using WebKit::WGC3Dchar; 20 using WebKit::WGC3Dchar;
20 using WebKit::WGC3Denum; 21 using WebKit::WGC3Denum;
21 using WebKit::WGC3Dint; 22 using WebKit::WGC3Dint;
22 using WebKit::WGC3Dsizei; 23 using WebKit::WGC3Dsizei;
23 using WebKit::WGC3Dsizeiptr; 24 using WebKit::WGC3Dsizeiptr;
24 using WebKit::WGC3Duint; 25 using WebKit::WGC3Duint;
25 using WebKit::WebGLId; 26 using WebKit::WebGLId;
26 using WebKit::WebGraphicsContext3D; 27 using WebKit::WebGraphicsContext3D;
27 28
28 namespace cc { 29 namespace cc {
29 30
30 static const WebGLId kFramebufferId = 1; 31 static const WebGLId kFramebufferId = 1;
31 static const WebGLId kProgramId = 2; 32 static const WebGLId kRenderbufferId = 2;
32 static const WebGLId kRenderbufferId = 3;
33 static const WebGLId kShaderId = 4;
34 33
35 static unsigned s_context_id = 1; 34 static unsigned s_context_id = 1;
36 35
37 const WebGLId TestWebGraphicsContext3D::kExternalTextureId = 1337; 36 const WebGLId TestWebGraphicsContext3D::kExternalTextureId = 1337;
38 37
39 static base::LazyInstance<base::Lock>::Leaky 38 static base::LazyInstance<base::Lock>::Leaky
40 g_shared_namespace_lock = LAZY_INSTANCE_INITIALIZER; 39 g_shared_namespace_lock = LAZY_INSTANCE_INITIALIZER;
41 40
42 TestWebGraphicsContext3D::Namespace* 41 TestWebGraphicsContext3D::Namespace*
43 TestWebGraphicsContext3D::shared_namespace_ = NULL; 42 TestWebGraphicsContext3D::shared_namespace_ = NULL;
(...skipping 20 matching lines...) Expand all
64 context_id_(s_context_id++), 63 context_id_(s_context_id++),
65 times_make_current_succeeds_(-1), 64 times_make_current_succeeds_(-1),
66 times_bind_texture_succeeds_(-1), 65 times_bind_texture_succeeds_(-1),
67 times_end_query_succeeds_(-1), 66 times_end_query_succeeds_(-1),
68 times_gen_mailbox_succeeds_(-1), 67 times_gen_mailbox_succeeds_(-1),
69 context_lost_(false), 68 context_lost_(false),
70 times_map_image_chromium_succeeds_(-1), 69 times_map_image_chromium_succeeds_(-1),
71 times_map_buffer_chromium_succeeds_(-1), 70 times_map_buffer_chromium_succeeds_(-1),
72 context_lost_callback_(NULL), 71 context_lost_callback_(NULL),
73 swap_buffers_callback_(NULL), 72 swap_buffers_callback_(NULL),
73 next_program_id_(1000),
74 next_shader_id_(2000),
74 max_texture_size_(2048), 75 max_texture_size_(2048),
76 reshape_called_(false),
75 width_(0), 77 width_(0),
76 height_(0), 78 height_(0),
79 scale_factor_(-1.f),
77 test_support_(NULL), 80 test_support_(NULL),
81 last_update_type_(NoUpdate),
78 bound_buffer_(0), 82 bound_buffer_(0),
79 weak_ptr_factory_(this) { 83 weak_ptr_factory_(this) {
80 CreateNamespace(); 84 CreateNamespace();
81 test_capabilities_.swapbuffers_complete_callback = true; 85 test_capabilities_.swapbuffers_complete_callback = true;
82 } 86 }
83 87
84 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() { 88 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() {
85 base::AutoLock lock(g_shared_namespace_lock.Get()); 89 base::AutoLock lock(g_shared_namespace_lock.Get());
86 namespace_ = NULL; 90 namespace_ = NULL;
87 } 91 }
(...skipping 18 matching lines...) Expand all
106 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, 110 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
107 GL_INNOCENT_CONTEXT_RESET_ARB); 111 GL_INNOCENT_CONTEXT_RESET_ARB);
108 } 112 }
109 --times_make_current_succeeds_; 113 --times_make_current_succeeds_;
110 } 114 }
111 return !context_lost_; 115 return !context_lost_;
112 } 116 }
113 117
114 void TestWebGraphicsContext3D::reshapeWithScaleFactor( 118 void TestWebGraphicsContext3D::reshapeWithScaleFactor(
115 int width, int height, float scale_factor) { 119 int width, int height, float scale_factor) {
120 reshape_called_ = true;
116 width_ = width; 121 width_ = width;
117 height_ = height; 122 height_ = height;
123 scale_factor_ = scale_factor;
118 } 124 }
119 125
120 bool TestWebGraphicsContext3D::isContextLost() { 126 bool TestWebGraphicsContext3D::isContextLost() {
121 return context_lost_; 127 return context_lost_;
122 } 128 }
123 129
124 WGC3Denum TestWebGraphicsContext3D::getGraphicsResetStatusARB() { 130 WGC3Denum TestWebGraphicsContext3D::getGraphicsResetStatusARB() {
125 return context_lost_ ? GL_UNKNOWN_CONTEXT_RESET_ARB : GL_NO_ERROR; 131 return context_lost_ ? GL_UNKNOWN_CONTEXT_RESET_ARB : GL_NO_ERROR;
126 } 132 }
127 133
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 281 }
276 282
277 void TestWebGraphicsContext3D::deleteRenderbuffer(WebGLId id) { 283 void TestWebGraphicsContext3D::deleteRenderbuffer(WebGLId id) {
278 deleteRenderbuffers(1, &id); 284 deleteRenderbuffers(1, &id);
279 } 285 }
280 286
281 void TestWebGraphicsContext3D::deleteTexture(WebGLId id) { 287 void TestWebGraphicsContext3D::deleteTexture(WebGLId id) {
282 deleteTextures(1, &id); 288 deleteTextures(1, &id);
283 } 289 }
284 290
285 WebGLId TestWebGraphicsContext3D::createProgram() { 291 unsigned TestWebGraphicsContext3D::createProgram() {
286 return kProgramId | context_id_ << 16; 292 unsigned program = next_program_id_++ | context_id_ << 16;
293 program_set_.insert(program);
294 return program;
287 } 295 }
288 296
289 WebGLId TestWebGraphicsContext3D::createShader(WGC3Denum) { 297 WebGLId TestWebGraphicsContext3D::createShader(WGC3Denum) {
290 return kShaderId | context_id_ << 16; 298 unsigned shader = next_shader_id_++ | context_id_ << 16;
299 shader_set_.insert(shader);
300 return shader;
291 } 301 }
292 302
293 WebGLId TestWebGraphicsContext3D::createExternalTexture() { 303 WebGLId TestWebGraphicsContext3D::createExternalTexture() {
294 base::AutoLock lock(namespace_->lock); 304 base::AutoLock lock(namespace_->lock);
295 namespace_->textures.Append(kExternalTextureId, new TestTexture()); 305 namespace_->textures.Append(kExternalTextureId, new TestTexture());
296 return kExternalTextureId; 306 return kExternalTextureId;
297 } 307 }
298 308
299 void TestWebGraphicsContext3D::deleteProgram(WebGLId id) { 309 void TestWebGraphicsContext3D::deleteProgram(WebGLId id) {
300 DCHECK_EQ(kProgramId | context_id_ << 16, id); 310 if (!program_set_.count(id))
311 ADD_FAILURE() << "deleteProgram called on unknown program " << id;
312 program_set_.erase(id);
301 } 313 }
302 314
303 void TestWebGraphicsContext3D::deleteShader(WebGLId id) { 315 void TestWebGraphicsContext3D::deleteShader(WebGLId id) {
304 DCHECK_EQ(kShaderId | context_id_ << 16, id); 316 if (!shader_set_.count(id))
317 ADD_FAILURE() << "deleteShader called on unknown shader " << id;
318 shader_set_.erase(id);
305 } 319 }
306 320
307 void TestWebGraphicsContext3D::attachShader(WebGLId program, WebGLId shader) { 321 void TestWebGraphicsContext3D::attachShader(WebGLId program, WebGLId shader) {
308 DCHECK_EQ(kProgramId | context_id_ << 16, program); 322 if (!program_set_.count(program))
309 DCHECK_EQ(kShaderId | context_id_ << 16, shader); 323 ADD_FAILURE() << "attachShader called with unknown program " << program;
324 if (!shader_set_.count(shader))
325 ADD_FAILURE() << "attachShader called with unknown shader " << shader;
310 } 326 }
311 327
312 void TestWebGraphicsContext3D::useProgram(WebGLId program) { 328 void TestWebGraphicsContext3D::useProgram(WebGLId program) {
313 if (!program) 329 if (!program)
314 return; 330 return;
315 DCHECK_EQ(kProgramId | context_id_ << 16, program); 331 if (!program_set_.count(program))
332 ADD_FAILURE() << "useProgram called on unknown program " << program;
316 } 333 }
317 334
318 void TestWebGraphicsContext3D::bindFramebuffer( 335 void TestWebGraphicsContext3D::bindFramebuffer(
319 WGC3Denum target, WebGLId framebuffer) { 336 WGC3Denum target, WebGLId framebuffer) {
320 if (!framebuffer) 337 if (!framebuffer)
321 return; 338 return;
322 DCHECK_EQ(kFramebufferId | context_id_ << 16, framebuffer); 339 DCHECK_EQ(kFramebufferId | context_id_ << 16, framebuffer);
323 } 340 }
324 341
325 void TestWebGraphicsContext3D::bindRenderbuffer( 342 void TestWebGraphicsContext3D::bindRenderbuffer(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 shared_contexts_.clear(); 439 shared_contexts_.clear();
423 } 440 }
424 441
425 void TestWebGraphicsContext3D::setSwapBuffersCompleteCallbackCHROMIUM( 442 void TestWebGraphicsContext3D::setSwapBuffersCompleteCallbackCHROMIUM(
426 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) { 443 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) {
427 if (test_capabilities_.swapbuffers_complete_callback) 444 if (test_capabilities_.swapbuffers_complete_callback)
428 swap_buffers_callback_ = callback; 445 swap_buffers_callback_ = callback;
429 } 446 }
430 447
431 void TestWebGraphicsContext3D::prepareTexture() { 448 void TestWebGraphicsContext3D::prepareTexture() {
449 update_rect_ = gfx::Rect(width_, height_);
450 last_update_type_ = PrepareTexture;
451
432 // TODO(jamesr): This should implemented as ContextSupport::SwapBuffers(). 452 // TODO(jamesr): This should implemented as ContextSupport::SwapBuffers().
433 if (swap_buffers_callback_) { 453 if (swap_buffers_callback_) {
434 base::MessageLoop::current()->PostTask( 454 base::MessageLoop::current()->PostTask(
435 FROM_HERE, base::Bind(&TestWebGraphicsContext3D::SwapBuffersComplete, 455 FROM_HERE, base::Bind(&TestWebGraphicsContext3D::SwapBuffersComplete,
436 weak_ptr_factory_.GetWeakPtr())); 456 weak_ptr_factory_.GetWeakPtr()));
437 } 457 }
438 test_support_->CallAllSyncPointCallbacks(); 458 test_support_->CallAllSyncPointCallbacks();
439 } 459 }
440 460
461 void TestWebGraphicsContext3D::postSubBufferCHROMIUM(
462 int x, int y, int width, int height) {
463 update_rect_ = gfx::Rect(x, y, width, height);
464 last_update_type_ = PostSubBuffer;
465 }
466
441 void TestWebGraphicsContext3D::finish() { 467 void TestWebGraphicsContext3D::finish() {
442 test_support_->CallAllSyncPointCallbacks(); 468 test_support_->CallAllSyncPointCallbacks();
443 } 469 }
444 470
445 void TestWebGraphicsContext3D::flush() { 471 void TestWebGraphicsContext3D::flush() {
446 test_support_->CallAllSyncPointCallbacks(); 472 test_support_->CallAllSyncPointCallbacks();
447 } 473 }
448 474
449 void TestWebGraphicsContext3D::SwapBuffersComplete() { 475 void TestWebGraphicsContext3D::SwapBuffersComplete() {
450 if (swap_buffers_callback_) 476 if (swap_buffers_callback_)
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 703
678 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} 704 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {}
679 705
680 TestWebGraphicsContext3D::Buffer::~Buffer() {} 706 TestWebGraphicsContext3D::Buffer::~Buffer() {}
681 707
682 TestWebGraphicsContext3D::Image::Image() {} 708 TestWebGraphicsContext3D::Image::Image() {}
683 709
684 TestWebGraphicsContext3D::Image::~Image() {} 710 TestWebGraphicsContext3D::Image::~Image() {}
685 711
686 } // namespace cc 712 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_web_graphics_context_3d.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698