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

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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 284 }
279 285
280 void TestWebGraphicsContext3D::deleteRenderbuffer(WebGLId id) { 286 void TestWebGraphicsContext3D::deleteRenderbuffer(WebGLId id) {
281 deleteRenderbuffers(1, &id); 287 deleteRenderbuffers(1, &id);
282 } 288 }
283 289
284 void TestWebGraphicsContext3D::deleteTexture(WebGLId id) { 290 void TestWebGraphicsContext3D::deleteTexture(WebGLId id) {
285 deleteTextures(1, &id); 291 deleteTextures(1, &id);
286 } 292 }
287 293
288 WebGLId TestWebGraphicsContext3D::createProgram() { 294 unsigned TestWebGraphicsContext3D::createProgram() {
289 return kProgramId | context_id_ << 16; 295 unsigned program = next_program_id_++ | context_id_ << 16;
296 program_set_.insert(program);
297 return program;
290 } 298 }
291 299
292 WebGLId TestWebGraphicsContext3D::createShader(WGC3Denum) { 300 WebGLId TestWebGraphicsContext3D::createShader(WGC3Denum) {
293 return kShaderId | context_id_ << 16; 301 unsigned shader = next_shader_id_++ | context_id_ << 16;
302 shader_set_.insert(shader);
303 return shader;
294 } 304 }
295 305
296 WebGLId TestWebGraphicsContext3D::createExternalTexture() { 306 WebGLId TestWebGraphicsContext3D::createExternalTexture() {
297 base::AutoLock lock(namespace_->lock); 307 base::AutoLock lock(namespace_->lock);
298 namespace_->textures.Append(kExternalTextureId, new TestTexture()); 308 namespace_->textures.Append(kExternalTextureId, new TestTexture());
299 return kExternalTextureId; 309 return kExternalTextureId;
300 } 310 }
301 311
302 void TestWebGraphicsContext3D::deleteProgram(WebGLId id) { 312 void TestWebGraphicsContext3D::deleteProgram(WebGLId id) {
303 DCHECK_EQ(kProgramId | context_id_ << 16, id); 313 if (!program_set_.count(id))
314 ADD_FAILURE() << "deleteProgram called on unknown program " << id;
315 program_set_.erase(id);
304 } 316 }
305 317
306 void TestWebGraphicsContext3D::deleteShader(WebGLId id) { 318 void TestWebGraphicsContext3D::deleteShader(WebGLId id) {
307 DCHECK_EQ(kShaderId | context_id_ << 16, id); 319 if (!shader_set_.count(id))
320 ADD_FAILURE() << "deleteShader called on unknown shader " << id;
321 shader_set_.erase(id);
308 } 322 }
309 323
310 void TestWebGraphicsContext3D::attachShader(WebGLId program, WebGLId shader) { 324 void TestWebGraphicsContext3D::attachShader(WebGLId program, WebGLId shader) {
311 DCHECK_EQ(kProgramId | context_id_ << 16, program); 325 if (!program_set_.count(program))
312 DCHECK_EQ(kShaderId | context_id_ << 16, shader); 326 ADD_FAILURE() << "attachShader called with unknown program " << program;
327 if (!shader_set_.count(shader))
328 ADD_FAILURE() << "attachShader called with unknown shader " << shader;
313 } 329 }
314 330
315 void TestWebGraphicsContext3D::useProgram(WebGLId program) { 331 void TestWebGraphicsContext3D::useProgram(WebGLId program) {
316 if (!program) 332 if (!program)
317 return; 333 return;
318 DCHECK_EQ(kProgramId | context_id_ << 16, program); 334 if (!program_set_.count(program))
335 ADD_FAILURE() << "useProgram called on unknown program " << program;
319 } 336 }
320 337
321 void TestWebGraphicsContext3D::bindFramebuffer( 338 void TestWebGraphicsContext3D::bindFramebuffer(
322 WGC3Denum target, WebGLId framebuffer) { 339 WGC3Denum target, WebGLId framebuffer) {
323 if (!framebuffer) 340 if (!framebuffer)
324 return; 341 return;
325 DCHECK_EQ(kFramebufferId | context_id_ << 16, framebuffer); 342 DCHECK_EQ(kFramebufferId | context_id_ << 16, framebuffer);
326 } 343 }
327 344
328 void TestWebGraphicsContext3D::bindRenderbuffer( 345 void TestWebGraphicsContext3D::bindRenderbuffer(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 shared_contexts_.clear(); 442 shared_contexts_.clear();
426 } 443 }
427 444
428 void TestWebGraphicsContext3D::setSwapBuffersCompleteCallbackCHROMIUM( 445 void TestWebGraphicsContext3D::setSwapBuffersCompleteCallbackCHROMIUM(
429 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) { 446 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) {
430 if (test_capabilities_.swapbuffers_complete_callback) 447 if (test_capabilities_.swapbuffers_complete_callback)
431 swap_buffers_callback_ = callback; 448 swap_buffers_callback_ = callback;
432 } 449 }
433 450
434 void TestWebGraphicsContext3D::prepareTexture() { 451 void TestWebGraphicsContext3D::prepareTexture() {
452 update_rect_ = gfx::Rect(width_, height_);
453 last_update_type_ = PrepareTexture;
454
435 // TODO(jamesr): This should implemented as ContextSupport::SwapBuffers(). 455 // TODO(jamesr): This should implemented as ContextSupport::SwapBuffers().
436 if (swap_buffers_callback_) { 456 if (swap_buffers_callback_) {
437 base::MessageLoop::current()->PostTask( 457 base::MessageLoop::current()->PostTask(
438 FROM_HERE, base::Bind(&TestWebGraphicsContext3D::SwapBuffersComplete, 458 FROM_HERE, base::Bind(&TestWebGraphicsContext3D::SwapBuffersComplete,
439 weak_ptr_factory_.GetWeakPtr())); 459 weak_ptr_factory_.GetWeakPtr()));
440 } 460 }
441 test_support_->CallAllSyncPointCallbacks(); 461 test_support_->CallAllSyncPointCallbacks();
442 } 462 }
443 463
464 void TestWebGraphicsContext3D::postSubBufferCHROMIUM(
465 int x, int y, int width, int height) {
466 update_rect_ = gfx::Rect(x, y, width, height);
467 last_update_type_ = PostSubBuffer;
468 }
469
470 void TestWebGraphicsContext3D::enable(GLenum cap) {}
danakj 2013/10/31 18:20:02 why override these and do nothing? remove these?
471 void TestWebGraphicsContext3D::disable(GLenum cap) {}
472
444 void TestWebGraphicsContext3D::finish() { 473 void TestWebGraphicsContext3D::finish() {
445 test_support_->CallAllSyncPointCallbacks(); 474 test_support_->CallAllSyncPointCallbacks();
446 } 475 }
447 476
448 void TestWebGraphicsContext3D::flush() { 477 void TestWebGraphicsContext3D::flush() {
449 test_support_->CallAllSyncPointCallbacks(); 478 test_support_->CallAllSyncPointCallbacks();
450 } 479 }
451 480
452 void TestWebGraphicsContext3D::SwapBuffersComplete() { 481 void TestWebGraphicsContext3D::SwapBuffersComplete() {
453 if (swap_buffers_callback_) 482 if (swap_buffers_callback_)
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 685
657 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} 686 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {}
658 687
659 TestWebGraphicsContext3D::Buffer::~Buffer() {} 688 TestWebGraphicsContext3D::Buffer::~Buffer() {}
660 689
661 TestWebGraphicsContext3D::Image::Image() {} 690 TestWebGraphicsContext3D::Image::Image() {}
662 691
663 TestWebGraphicsContext3D::Image::~Image() {} 692 TestWebGraphicsContext3D::Image::~Image() {}
664 693
665 } // namespace cc 694 } // 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