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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_browsertest.cc

Issue 22293003: Clean up compositor initialization/destruction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanupcompositor: UseRealGLBindings in NetInternalsTest Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/message_loop/message_loop_proxy.h" 6 #include "base/message_loop/message_loop_proxy.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "content/browser/gpu/gpu_data_manager_impl.h" 9 #include "content/browser/gpu/gpu_data_manager_impl.h"
10 #include "content/browser/renderer_host/dip_util.h" 10 #include "content/browser/renderer_host/dip_util.h"
(...skipping 10 matching lines...) Expand all
21 #include "content/shell/shell.h" 21 #include "content/shell/shell.h"
22 #include "content/test/content_browser_test.h" 22 #include "content/test/content_browser_test.h"
23 #include "content/test/content_browser_test_utils.h" 23 #include "content/test/content_browser_test_utils.h"
24 #include "media/base/video_frame.h" 24 #include "media/base/video_frame.h"
25 #include "media/filters/skcanvas_video_renderer.h" 25 #include "media/filters/skcanvas_video_renderer.h"
26 #include "net/base/net_util.h" 26 #include "net/base/net_util.h"
27 #include "third_party/skia/include/core/SkBitmap.h" 27 #include "third_party/skia/include/core/SkBitmap.h"
28 #include "third_party/skia/include/core/SkCanvas.h" 28 #include "third_party/skia/include/core/SkCanvas.h"
29 #include "third_party/skia/include/core/SkDevice.h" 29 #include "third_party/skia/include/core/SkDevice.h"
30 #include "ui/base/ui_base_switches.h" 30 #include "ui/base/ui_base_switches.h"
31 #include "ui/compositor/compositor_setup.h"
32 #include "ui/gfx/size_conversions.h" 31 #include "ui/gfx/size_conversions.h"
33 #include "ui/gl/gl_switches.h" 32 #include "ui/gl/gl_switches.h"
34 33
35 #if defined(OS_MACOSX) 34 #if defined(OS_MACOSX)
36 #include "ui/gl/io_surface_support_mac.h" 35 #include "ui/gl/io_surface_support_mac.h"
37 #endif 36 #endif
38 37
39 #if defined(OS_WIN) 38 #if defined(OS_WIN)
40 #include "ui/base/win/dpi.h" 39 #include "ui/base/win/dpi.h"
41 #endif 40 #endif
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 private: 204 private:
206 const gfx::Size frame_size_; 205 const gfx::Size frame_size_;
207 base::FilePath test_dir_; 206 base::FilePath test_dir_;
208 int callback_invoke_count_; 207 int callback_invoke_count_;
209 int frames_captured_; 208 int frames_captured_;
210 }; 209 };
211 210
212 class CompositingRenderWidgetHostViewBrowserTest 211 class CompositingRenderWidgetHostViewBrowserTest
213 : public RenderWidgetHostViewBrowserTest { 212 : public RenderWidgetHostViewBrowserTest {
214 public: 213 public:
214 virtual void SetUp() OVERRIDE {
215 // We expect real pixel output for these tests.
216 UseRealGLContexts();
217
218 // On legacy windows, these tests need real GL bindings to pass.
219 #if defined(OS_WIN) && !defined(USE_AURA)
220 UseRealGLBindings();
221 #endif
222
223 RenderWidgetHostViewBrowserTest::SetUp();
224 }
225
215 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 226 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
216 // Note: Not appending kForceCompositingMode switch here, since not all bots 227 // Note: Not appending kForceCompositingMode switch here, since not all bots
217 // support compositing. Some bots will run with compositing on, and others 228 // support compositing. Some bots will run with compositing on, and others
218 // won't. Therefore, the call to SetUpSourceSurface() later on will detect 229 // won't. Therefore, the call to SetUpSourceSurface() later on will detect
219 // whether compositing mode is actually on or not. If not, the tests will 230 // whether compositing mode is actually on or not. If not, the tests will
220 // pass blindly, logging a warning message, since we cannot test what the 231 // pass blindly, logging a warning message, since we cannot test what the
221 // platform/implementation does not support. 232 // platform/implementation does not support.
222 RenderWidgetHostViewBrowserTest::SetUpCommandLine(command_line); 233 RenderWidgetHostViewBrowserTest::SetUpCommandLine(command_line);
223 } 234 }
224 235
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 }; 334 };
324 335
325 // Disable tests for Android and IOS as these platforms have incomplete 336 // Disable tests for Android and IOS as these platforms have incomplete
326 // implementation. 337 // implementation.
327 #if !defined(OS_ANDROID) && !defined(OS_IOS) 338 #if !defined(OS_ANDROID) && !defined(OS_IOS)
328 339
329 // The CopyFromBackingStore() API should work on all platforms when compositing 340 // The CopyFromBackingStore() API should work on all platforms when compositing
330 // is enabled. 341 // is enabled.
331 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, 342 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest,
332 CopyFromBackingStore) { 343 CopyFromBackingStore) {
333 #if defined(USE_AURA)
334 if (ui::IsTestCompositorEnabled()) {
335 LOG(WARNING) << ("Blindly passing this test: Aura test compositor doesn't "
336 "support copying from backing store.");
337 // TODO(jbauman): Aura test compositor should support copying from backing
338 // store. http://crbug.com/268644
339 return;
340 }
341 #endif
342 RunBasicCopyFromBackingStoreTest(); 344 RunBasicCopyFromBackingStoreTest();
343 } 345 }
344 346
345 // The CopyFromBackingStore() API should work on all platforms when compositing 347 // The CopyFromBackingStore() API should work on all platforms when compositing
346 // is disabled. 348 // is disabled.
347 IN_PROC_BROWSER_TEST_F(NonCompositingRenderWidgetHostViewBrowserTest, 349 IN_PROC_BROWSER_TEST_F(NonCompositingRenderWidgetHostViewBrowserTest,
348 CopyFromBackingStore) { 350 CopyFromBackingStore) {
349 RunBasicCopyFromBackingStoreTest(); 351 RunBasicCopyFromBackingStoreTest();
350 } 352 }
351 353
(...skipping 22 matching lines...) Expand all
374 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, 376 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest,
375 CopyFromCompositingSurface_CallbackDespiteDelete) { 377 CopyFromCompositingSurface_CallbackDespiteDelete) {
376 SET_UP_SURFACE_OR_PASS_TEST(NULL); 378 SET_UP_SURFACE_OR_PASS_TEST(NULL);
377 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); 379 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort();
378 if (!view->CanCopyToVideoFrame()) { 380 if (!view->CanCopyToVideoFrame()) {
379 LOG(WARNING) << 381 LOG(WARNING) <<
380 ("Blindly passing this test: CopyFromCompositingSurfaceToVideoFrame() " 382 ("Blindly passing this test: CopyFromCompositingSurfaceToVideoFrame() "
381 "not supported on this platform."); 383 "not supported on this platform.");
382 return; 384 return;
383 } 385 }
386
384 base::RunLoop run_loop; 387 base::RunLoop run_loop;
385 scoped_refptr<media::VideoFrame> dest = 388 scoped_refptr<media::VideoFrame> dest =
386 media::VideoFrame::CreateBlackFrame(frame_size()); 389 media::VideoFrame::CreateBlackFrame(frame_size());
387 view->CopyFromCompositingSurfaceToVideoFrame( 390 view->CopyFromCompositingSurfaceToVideoFrame(
388 gfx::Rect(view->GetViewBounds().size()), dest, base::Bind( 391 gfx::Rect(view->GetViewBounds().size()), dest, base::Bind(
389 &RenderWidgetHostViewBrowserTest::FinishCopyFromCompositingSurface, 392 &RenderWidgetHostViewBrowserTest::FinishCopyFromCompositingSurface,
390 base::Unretained(this), run_loop.QuitClosure())); 393 base::Unretained(this), run_loop.QuitClosure()));
391 // Delete the surface before the callback is run. 394 // Delete the surface before the callback is run.
392 view->AcceleratedSurfaceRelease(); 395 view->AcceleratedSurfaceRelease();
393 run_loop.Run(); 396 run_loop.Run();
(...skipping 13 matching lines...) Expand all
407 // until at least one DeliverFrameCallback has been invoked. 410 // until at least one DeliverFrameCallback has been invoked.
408 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, 411 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest,
409 FrameSubscriberTest) { 412 FrameSubscriberTest) {
410 SET_UP_SURFACE_OR_PASS_TEST(NULL); 413 SET_UP_SURFACE_OR_PASS_TEST(NULL);
411 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); 414 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort();
412 if (!view->CanSubscribeFrame()) { 415 if (!view->CanSubscribeFrame()) {
413 LOG(WARNING) << ("Blindly passing this test: Frame subscription not " 416 LOG(WARNING) << ("Blindly passing this test: Frame subscription not "
414 "supported on this platform."); 417 "supported on this platform.");
415 return; 418 return;
416 } 419 }
417 #if defined(USE_AURA)
418 if (ui::IsTestCompositorEnabled()) {
419 LOG(WARNING) << ("Blindly passing this test: Aura test compositor doesn't "
420 "support frame subscription.");
421 // TODO(miu): Aura test compositor should support frame subscription for
422 // testing. http://crbug.com/240572
423 return;
424 }
425 #endif
426 420
427 base::RunLoop run_loop; 421 base::RunLoop run_loop;
428 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber( 422 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber(
429 new FakeFrameSubscriber( 423 new FakeFrameSubscriber(
430 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered, 424 base::Bind(&RenderWidgetHostViewBrowserTest::FrameDelivered,
431 base::Unretained(this), 425 base::Unretained(this),
432 base::MessageLoopProxy::current(), 426 base::MessageLoopProxy::current(),
433 run_loop.QuitClosure()))); 427 run_loop.QuitClosure())));
434 view->BeginFrameSubscription(subscriber.Pass()); 428 view->BeginFrameSubscription(subscriber.Pass());
435 run_loop.Run(); 429 run_loop.Run();
436 view->EndFrameSubscription(); 430 view->EndFrameSubscription();
437 431
438 EXPECT_LE(1, callback_invoke_count()); 432 EXPECT_LE(1, callback_invoke_count());
439 EXPECT_LE(1, frames_captured()); 433 EXPECT_LE(1, frames_captured());
440 } 434 }
441 435
442 // Test that we can copy twice from an accelerated composited page. 436 // Test that we can copy twice from an accelerated composited page.
443 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, CopyTwice) { 437 IN_PROC_BROWSER_TEST_F(CompositingRenderWidgetHostViewBrowserTest, CopyTwice) {
444 SET_UP_SURFACE_OR_PASS_TEST(NULL); 438 SET_UP_SURFACE_OR_PASS_TEST(NULL);
445 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort(); 439 RenderWidgetHostViewPort* const view = GetRenderWidgetHostViewPort();
446 if (!view->CanCopyToVideoFrame()) { 440 if (!view->CanCopyToVideoFrame()) {
447 LOG(WARNING) << ("Blindly passing this test: " 441 LOG(WARNING) << ("Blindly passing this test: "
448 "CopyFromCompositingSurfaceToVideoFrame() not supported " 442 "CopyFromCompositingSurfaceToVideoFrame() not supported "
449 "on this platform."); 443 "on this platform.");
450 return; 444 return;
451 } 445 }
452 446
453 #if defined(USE_AURA)
454 if (ui::IsTestCompositorEnabled()) {
455 LOG(WARNING) << ("Blindly passing this test: Aura test compositor doesn't "
456 "support copying to video frame.");
457 // TODO(jbauman): Aura test compositor should support copying to video
458 // frame. http://crbug.com/268644
459 return;
460 }
461 #endif
462
463 base::RunLoop run_loop; 447 base::RunLoop run_loop;
464 scoped_refptr<media::VideoFrame> first_output = 448 scoped_refptr<media::VideoFrame> first_output =
465 media::VideoFrame::CreateBlackFrame(frame_size()); 449 media::VideoFrame::CreateBlackFrame(frame_size());
466 ASSERT_TRUE(first_output.get()); 450 ASSERT_TRUE(first_output.get());
467 scoped_refptr<media::VideoFrame> second_output = 451 scoped_refptr<media::VideoFrame> second_output =
468 media::VideoFrame::CreateBlackFrame(frame_size()); 452 media::VideoFrame::CreateBlackFrame(frame_size());
469 ASSERT_TRUE(second_output.get()); 453 ASSERT_TRUE(second_output.get());
470 view->CopyFromCompositingSurfaceToVideoFrame( 454 view->CopyFromCompositingSurfaceToVideoFrame(
471 gfx::Rect(view->GetViewBounds().size()), 455 gfx::Rect(view->GetViewBounds().size()),
472 first_output, 456 first_output,
(...skipping 16 matching lines...) Expand all
489 } 473 }
490 474
491 class CompositingRenderWidgetHostViewBrowserTestTabCapture 475 class CompositingRenderWidgetHostViewBrowserTestTabCapture
492 : public CompositingRenderWidgetHostViewBrowserTest { 476 : public CompositingRenderWidgetHostViewBrowserTest {
493 public: 477 public:
494 CompositingRenderWidgetHostViewBrowserTestTabCapture() 478 CompositingRenderWidgetHostViewBrowserTestTabCapture()
495 : expected_copy_from_compositing_surface_result_(false), 479 : expected_copy_from_compositing_surface_result_(false),
496 allowable_error_(0), 480 allowable_error_(0),
497 test_url_("data:text/html,<!doctype html>") {} 481 test_url_("data:text/html,<!doctype html>") {}
498 482
499 virtual void SetUp() OVERRIDE {
500 ui::DisableTestCompositor();
501 CompositingRenderWidgetHostViewBrowserTest::SetUp();
502 }
503
504 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
505 // TODO(Hubbe): This code is very similar to some code in
506 // gpu_feature_browsertest.cc, and should really be shared in a common
507 // location.
508 if (!command_line->HasSwitch(switches::kUseGpuInTests)) {
509 CHECK(!command_line->HasSwitch(switches::kUseGL))
510 << "kUseGL must not be set by test framework code!";
511 command_line->AppendSwitchASCII(switches::kUseGL,
512 gfx::kGLImplementationOSMesaName);
513 }
514 }
515
516 void CopyFromCompositingSurfaceCallback(base::Closure quit_callback, 483 void CopyFromCompositingSurfaceCallback(base::Closure quit_callback,
517 bool result, 484 bool result,
518 const SkBitmap& bitmap) { 485 const SkBitmap& bitmap) {
519 EXPECT_EQ(expected_copy_from_compositing_surface_result_, result); 486 EXPECT_EQ(expected_copy_from_compositing_surface_result_, result);
520 if (!result) { 487 if (!result) {
521 quit_callback.Run(); 488 quit_callback.Run();
522 return; 489 return;
523 } 490 }
524 491
525 const SkBitmap& expected_bitmap = 492 const SkBitmap& expected_bitmap =
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 copy_rect, 871 copy_rect,
905 output_size, 872 output_size,
906 expected_bitmap_size, 873 expected_bitmap_size,
907 video_frame); 874 video_frame);
908 } 875 }
909 876
910 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 877 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
911 878
912 } // namespace 879 } // namespace
913 } // namespace content 880 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698