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

Side by Side Diff: components/test_runner/test_plugin.cc

Issue 1807103002: Move simple methods [A-E] from WebGraphicsContext3D to GLES2Interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@work
Patch Set: bindFoo: ALLthetests Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/compositor/gl_helper_benchmark.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 "components/test_runner/test_plugin.h" 5 #include "components/test_runner/test_plugin.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 bool is_visible) { 236 bool is_visible) {
237 if (clip_rect == rect_) 237 if (clip_rect == rect_)
238 return; 238 return;
239 rect_ = clip_rect; 239 rect_ = clip_rect;
240 240
241 if (rect_.isEmpty()) { 241 if (rect_.isEmpty()) {
242 texture_mailbox_ = cc::TextureMailbox(); 242 texture_mailbox_ = cc::TextureMailbox();
243 } else if (context_) { 243 } else if (context_) {
244 context_->viewport(0, 0, rect_.width, rect_.height); 244 context_->viewport(0, 0, rect_.width, rect_.height);
245 245
246 context_->bindTexture(GL_TEXTURE_2D, color_texture_); 246 gl_->BindTexture(GL_TEXTURE_2D, color_texture_);
247 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 247 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
248 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 248 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
249 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 249 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
250 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 250 context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
251 context_->texImage2D(GL_TEXTURE_2D, 251 context_->texImage2D(GL_TEXTURE_2D,
252 0, 252 0,
253 GL_RGBA, 253 GL_RGBA,
254 rect_.width, 254 rect_.width,
255 rect_.height, 255 rect_.height,
256 0, 256 0,
257 GL_RGBA, 257 GL_RGBA,
258 GL_UNSIGNED_BYTE, 258 GL_UNSIGNED_BYTE,
259 0); 259 0);
260 context_->bindFramebuffer(GL_FRAMEBUFFER, framebuffer_); 260 gl_->BindFramebuffer(GL_FRAMEBUFFER, framebuffer_);
261 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 261 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
262 GL_TEXTURE_2D, color_texture_, 0); 262 GL_TEXTURE_2D, color_texture_, 0);
263 263
264 DrawSceneGL(); 264 DrawSceneGL();
265 265
266 gpu::Mailbox mailbox; 266 gpu::Mailbox mailbox;
267 context_->genMailboxCHROMIUM(mailbox.name); 267 context_->genMailboxCHROMIUM(mailbox.name);
268 context_->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 268 context_->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
269 const blink::WGC3Duint64 fence_sync = context_->insertFenceSyncCHROMIUM(); 269 const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM();
270 context_->flush(); 270 context_->flush();
271 271
272 gpu::SyncToken sync_token; 272 gpu::SyncToken sync_token;
273 context_->genSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); 273 context_->genSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
274 texture_mailbox_ = cc::TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D); 274 texture_mailbox_ = cc::TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D);
275 } else { 275 } else {
276 scoped_ptr<cc::SharedBitmap> bitmap = 276 scoped_ptr<cc::SharedBitmap> bitmap =
277 delegate_->GetSharedBitmapManager()->AllocateSharedBitmap( 277 delegate_->GetSharedBitmapManager()->AllocateSharedBitmap(
278 gfx::Rect(rect_).size()); 278 gfx::Rect(rect_).size());
279 if (!bitmap) { 279 if (!bitmap) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 if (!context_) 369 if (!context_)
370 return true; 370 return true;
371 371
372 float color[4]; 372 float color[4];
373 PremultiplyAlpha(scene_.background_color, scene_.opacity, color); 373 PremultiplyAlpha(scene_.background_color, scene_.opacity, color);
374 374
375 color_texture_ = context_->createTexture(); 375 color_texture_ = context_->createTexture();
376 framebuffer_ = context_->createFramebuffer(); 376 framebuffer_ = context_->createFramebuffer();
377 377
378 context_->viewport(0, 0, rect_.width, rect_.height); 378 context_->viewport(0, 0, rect_.width, rect_.height);
379 context_->disable(GL_DEPTH_TEST); 379 gl_->Disable(GL_DEPTH_TEST);
380 context_->disable(GL_SCISSOR_TEST); 380 gl_->Disable(GL_SCISSOR_TEST);
381 381
382 context_->clearColor(color[0], color[1], color[2], color[3]); 382 gl_->ClearColor(color[0], color[1], color[2], color[3]);
383 383
384 context_->enable(GL_BLEND); 384 gl_->Enable(GL_BLEND);
385 context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 385 gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
386 386
387 return scene_.primitive != PrimitiveNone ? InitProgram() && InitPrimitive() 387 return scene_.primitive != PrimitiveNone ? InitProgram() && InitPrimitive()
388 : true; 388 : true;
389 } 389 }
390 390
391 void TestPlugin::DrawSceneGL() { 391 void TestPlugin::DrawSceneGL() {
392 context_->viewport(0, 0, rect_.width, rect_.height); 392 context_->viewport(0, 0, rect_.width, rect_.height);
393 context_->clear(GL_COLOR_BUFFER_BIT); 393 gl_->Clear(GL_COLOR_BUFFER_BIT);
394 394
395 if (scene_.primitive != PrimitiveNone) 395 if (scene_.primitive != PrimitiveNone)
396 DrawPrimitive(); 396 DrawPrimitive();
397 } 397 }
398 398
399 void TestPlugin::DrawSceneSoftware(void* memory) { 399 void TestPlugin::DrawSceneSoftware(void* memory) {
400 SkColor background_color = SkColorSetARGB( 400 SkColor background_color = SkColorSetARGB(
401 static_cast<uint8_t>(scene_.opacity * 255), scene_.background_color[0], 401 static_cast<uint8_t>(scene_.opacity * 255), scene_.background_color[0],
402 scene_.background_color[1], scene_.background_color[2]); 402 scene_.background_color[1], scene_.background_color[2]);
403 403
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 471
472 bool TestPlugin::InitPrimitive() { 472 bool TestPlugin::InitPrimitive() {
473 DCHECK_EQ(scene_.primitive, PrimitiveTriangle); 473 DCHECK_EQ(scene_.primitive, PrimitiveTriangle);
474 474
475 scene_.vbo = context_->createBuffer(); 475 scene_.vbo = context_->createBuffer();
476 if (!scene_.vbo) 476 if (!scene_.vbo)
477 return false; 477 return false;
478 478
479 const float vertices[] = {0.0f, 0.8f, 0.0f, -0.8f, -0.8f, 479 const float vertices[] = {0.0f, 0.8f, 0.0f, -0.8f, -0.8f,
480 0.0f, 0.8f, -0.8f, 0.0f}; 480 0.0f, 0.8f, -0.8f, 0.0f};
481 context_->bindBuffer(GL_ARRAY_BUFFER, scene_.vbo); 481 gl_->BindBuffer(GL_ARRAY_BUFFER, scene_.vbo);
482 context_->bufferData(GL_ARRAY_BUFFER, sizeof(vertices), 0, GL_STATIC_DRAW); 482 gl_->BufferData(GL_ARRAY_BUFFER, sizeof(vertices), 0, GL_STATIC_DRAW);
483 context_->bufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); 483 gl_->BufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
484 return true; 484 return true;
485 } 485 }
486 486
487 void TestPlugin::DrawPrimitive() { 487 void TestPlugin::DrawPrimitive() {
488 DCHECK_EQ(scene_.primitive, PrimitiveTriangle); 488 DCHECK_EQ(scene_.primitive, PrimitiveTriangle);
489 DCHECK(scene_.vbo); 489 DCHECK(scene_.vbo);
490 DCHECK(scene_.program); 490 DCHECK(scene_.program);
491 491
492 context_->useProgram(scene_.program); 492 context_->useProgram(scene_.program);
493 493
494 // Bind primitive color. 494 // Bind primitive color.
495 float color[4]; 495 float color[4];
496 PremultiplyAlpha(scene_.primitive_color, scene_.opacity, color); 496 PremultiplyAlpha(scene_.primitive_color, scene_.opacity, color);
497 context_->uniform4f( 497 context_->uniform4f(
498 scene_.color_location, color[0], color[1], color[2], color[3]); 498 scene_.color_location, color[0], color[1], color[2], color[3]);
499 499
500 // Bind primitive vertices. 500 // Bind primitive vertices.
501 context_->bindBuffer(GL_ARRAY_BUFFER, scene_.vbo); 501 gl_->BindBuffer(GL_ARRAY_BUFFER, scene_.vbo);
502 context_->enableVertexAttribArray(scene_.position_location); 502 gl_->EnableVertexAttribArray(scene_.position_location);
503 context_->vertexAttribPointer( 503 context_->vertexAttribPointer(
504 scene_.position_location, 3, GL_FLOAT, GL_FALSE, 0, 0); 504 scene_.position_location, 3, GL_FLOAT, GL_FALSE, 0, 0);
505 context_->drawArrays(GL_TRIANGLES, 0, 3); 505 gl_->DrawArrays(GL_TRIANGLES, 0, 3);
506 } 506 }
507 507
508 unsigned TestPlugin::LoadShader(unsigned type, const std::string& source) { 508 unsigned TestPlugin::LoadShader(unsigned type, const std::string& source) {
509 unsigned shader = context_->createShader(type); 509 unsigned shader = context_->createShader(type);
510 if (shader) { 510 if (shader) {
511 context_->shaderSource(shader, source.data()); 511 context_->shaderSource(shader, source.data());
512 context_->compileShader(shader); 512 gl_->CompileShader(shader);
513 513
514 int compiled = 0; 514 int compiled = 0;
515 context_->getShaderiv(shader, GL_COMPILE_STATUS, &compiled); 515 context_->getShaderiv(shader, GL_COMPILE_STATUS, &compiled);
516 if (!compiled) { 516 if (!compiled) {
517 context_->deleteShader(shader); 517 context_->deleteShader(shader);
518 shader = 0; 518 shader = 0;
519 } 519 }
520 } 520 }
521 return shader; 521 return shader;
522 } 522 }
523 523
524 unsigned TestPlugin::LoadProgram(const std::string& vertex_source, 524 unsigned TestPlugin::LoadProgram(const std::string& vertex_source,
525 const std::string& fragment_source) { 525 const std::string& fragment_source) {
526 unsigned vertex_shader = LoadShader(GL_VERTEX_SHADER, vertex_source); 526 unsigned vertex_shader = LoadShader(GL_VERTEX_SHADER, vertex_source);
527 unsigned fragment_shader = LoadShader(GL_FRAGMENT_SHADER, fragment_source); 527 unsigned fragment_shader = LoadShader(GL_FRAGMENT_SHADER, fragment_source);
528 unsigned program = context_->createProgram(); 528 unsigned program = context_->createProgram();
529 if (vertex_shader && fragment_shader && program) { 529 if (vertex_shader && fragment_shader && program) {
530 context_->attachShader(program, vertex_shader); 530 gl_->AttachShader(program, vertex_shader);
531 context_->attachShader(program, fragment_shader); 531 gl_->AttachShader(program, fragment_shader);
532 context_->linkProgram(program); 532 context_->linkProgram(program);
533 533
534 int linked = 0; 534 int linked = 0;
535 context_->getProgramiv(program, GL_LINK_STATUS, &linked); 535 context_->getProgramiv(program, GL_LINK_STATUS, &linked);
536 if (!linked) { 536 if (!linked) {
537 context_->deleteProgram(program); 537 context_->deleteProgram(program);
538 program = 0; 538 program = 0;
539 } 539 }
540 } 540 }
541 if (vertex_shader) 541 if (vertex_shader)
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 return kPluginPersistsMimeType; 732 return kPluginPersistsMimeType;
733 } 733 }
734 734
735 bool TestPlugin::IsSupportedMimeType(const blink::WebString& mime_type) { 735 bool TestPlugin::IsSupportedMimeType(const blink::WebString& mime_type) {
736 return mime_type == TestPlugin::MimeType() || 736 return mime_type == TestPlugin::MimeType() ||
737 mime_type == PluginPersistsMimeType() || 737 mime_type == PluginPersistsMimeType() ||
738 mime_type == CanCreateWithoutRendererMimeType(); 738 mime_type == CanCreateWithoutRendererMimeType();
739 } 739 }
740 740
741 } // namespace test_runner 741 } // namespace test_runner
OLDNEW
« no previous file with comments | « no previous file | content/browser/compositor/gl_helper_benchmark.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698