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

Side by Side Diff: content/shell/renderer/test_runner/WebTestProxy.cpp

Issue 266243002: Make displayAsyncThen use the CompositeAndReadbackAsync path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: displayasync: Created 6 years, 7 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
« no previous file with comments | « content/shell/renderer/test_runner/WebTestProxy.h ('k') | no next file » | 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 "content/shell/renderer/test_runner/WebTestProxy.h" 5 #include "content/shell/renderer/test_runner/WebTestProxy.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 477
478 void WebTestProxyBase::didCompositeAndReadback(const SkBitmap& bitmap) { 478 void WebTestProxyBase::didCompositeAndReadback(const SkBitmap& bitmap) {
479 TRACE_EVENT2("shell", 479 TRACE_EVENT2("shell",
480 "WebTestProxyBase::didCompositeAndReadback", 480 "WebTestProxyBase::didCompositeAndReadback",
481 "x", 481 "x",
482 bitmap.info().fWidth, 482 bitmap.info().fWidth,
483 "y", 483 "y",
484 bitmap.info().fHeight); 484 bitmap.info().fHeight);
485 SkCanvas canvas(bitmap); 485 SkCanvas canvas(bitmap);
486 DrawSelectionRect(&canvas); 486 DrawSelectionRect(&canvas);
487 base::ResetAndReturn(&m_compositeAndReadbackCallback).Run(bitmap); 487 m_compositeAndReadbackCallbacks.front().Run(bitmap);
488 m_compositeAndReadbackCallbacks.pop_front();
488 } 489 }
489 490
490 void WebTestProxyBase::CapturePixelsAsync( 491 void WebTestProxyBase::CapturePixelsAsync(
491 base::Callback<void(const SkBitmap&)> callback) { 492 base::Callback<void(const SkBitmap&)> callback) {
492 m_compositeAndReadbackCallback = callback;
493 TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixelsAsync"); 493 TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixelsAsync");
494 494
495 m_compositeAndReadbackCallbacks.push_back(callback);
496
495 // Do a layout here because it might leave compositing mode! x.x 497 // Do a layout here because it might leave compositing mode! x.x
496 // TODO(danakj): Remove this when we have kForceCompositingMode everywhere. 498 // TODO(danakj): Remove this when we have kForceCompositingMode everywhere.
497 webWidget()->layout(); 499 webWidget()->layout();
498 500
499 if (!webWidget()->compositeAndReadbackAsync(this)) { 501 if (!webWidget()->isAcceleratedCompositingActive()) {
500 TRACE_EVENT0("shell", 502 TRACE_EVENT0("shell",
501 "WebTestProxyBase::CapturePixelsAsync " 503 "WebTestProxyBase::CapturePixelsAsync "
502 "compositeAndReadbackAsync failed"); 504 "isAcceleratedCompositingActive false");
503 didCompositeAndReadback(SkBitmap()); 505 didCompositeAndReadback(SkBitmap());
506 return;
504 } 507 }
508
509 webWidget()->compositeAndReadbackAsync(this);
505 } 510 }
506 511
507 void WebTestProxyBase::setLogConsoleOutput(bool enabled) 512 void WebTestProxyBase::setLogConsoleOutput(bool enabled)
508 { 513 {
509 m_logConsoleOutput = enabled; 514 m_logConsoleOutput = enabled;
510 } 515 }
511 516
512 void WebTestProxyBase::paintRect(const WebRect& rect) 517 void WebTestProxyBase::paintRect(const WebRect& rect)
513 { 518 {
514 DCHECK(!m_isPainting); 519 DCHECK(!m_isPainting);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 float deviceScaleFactor = webView()->deviceScaleFactor(); 595 float deviceScaleFactor = webView()->deviceScaleFactor();
591 int scaledWidth = static_cast<int>(ceil(static_cast<float>(widgetSize.width) * deviceScaleFactor)); 596 int scaledWidth = static_cast<int>(ceil(static_cast<float>(widgetSize.width) * deviceScaleFactor));
592 int scaledHeight = static_cast<int>(ceil(static_cast<float>(widgetSize.heigh t) * deviceScaleFactor)); 597 int scaledHeight = static_cast<int>(ceil(static_cast<float>(widgetSize.heigh t) * deviceScaleFactor));
593 // We're allocating the canvas to be non-opaque (third parameter), so we 598 // We're allocating the canvas to be non-opaque (third parameter), so we
594 // don't end up with uninitialized memory if a layout test doesn't damage 599 // don't end up with uninitialized memory if a layout test doesn't damage
595 // the entire view. 600 // the entire view.
596 m_canvas.reset(skia::CreateBitmapCanvas(scaledWidth, scaledHeight, false)); 601 m_canvas.reset(skia::CreateBitmapCanvas(scaledWidth, scaledHeight, false));
597 return m_canvas.get(); 602 return m_canvas.get();
598 } 603 }
599 604
600 void WebTestProxyBase::display(base::Closure callback) 605 void WebTestProxyBase::DisplayForSoftwareMode(const base::Closure& callback) {
601 {
602 const blink::WebSize& size = webWidget()->size(); 606 const blink::WebSize& size = webWidget()->size();
603 WebRect rect(0, 0, size.width, size.height); 607 WebRect rect(0, 0, size.width, size.height);
604 m_paintRect = rect; 608 m_paintRect = rect;
605 paintInvalidatedRegion(); 609 paintInvalidatedRegion();
606 610
607 if (!callback.is_null()) 611 if (!callback.is_null())
608 callback.Run(); 612 callback.Run();
609 } 613 }
610 614
615 void WebTestProxyBase::DidDisplayAsync(const base::Closure& callback,
616 const SkBitmap& bitmap) {
617 if (!callback.is_null())
618 callback.Run();
619 }
620
611 void WebTestProxyBase::displayAsyncThen(base::Closure callback) 621 void WebTestProxyBase::displayAsyncThen(base::Closure callback)
612 { 622 {
613 // TODO(enne): When compositing, this should invoke a real rAF, paint, 623 TRACE_EVENT0("shell", "WebTestProxyBase::displayAsyncThen");
614 // and commit. For now, just make sure that displayAsync is actually 624
615 // async so that callers can't depend on synchronous behavior. 625 // TODO(danakj): Just call CapturePixelsAsyc when we have
616 m_delegate->postTask(new ClosureTask( 626 // kForceCompositingMode everywhere.
617 this, 627
618 base::Bind( 628 // Do a layout here because it might leave compositing mode! x.x
619 &WebTestProxyBase::display, base::Unretained(this), callback))); 629 webWidget()->layout();
abarth-chromium 2014/05/05 22:37:43 Will this change what we're testing by introducing
danakj 2014/05/05 22:46:55 This does add one additional layout.
630
631 if (!webWidget()->isAcceleratedCompositingActive()) {
632 TRACE_EVENT0("shell",
633 "WebTestProxyBase::displayAsyncThen "
634 "isAcceleratedCompositingActive false");
635 m_delegate->postTask(
636 new ClosureTask(this,
637 base::Bind(&WebTestProxyBase::DisplayForSoftwareMode,
638 base::Unretained(this),
639 callback)));
640 return;
641 }
642
643 m_compositeAndReadbackCallbacks.push_back(base::Bind(
644 &WebTestProxyBase::DidDisplayAsync, base::Unretained(this), callback));
645 webWidget()->compositeAndReadbackAsync(this);
620 } 646 }
621 647
622 void WebTestProxyBase::discardBackingStore() 648 void WebTestProxyBase::discardBackingStore()
623 { 649 {
624 m_canvas.reset(); 650 m_canvas.reset();
625 } 651 }
626 652
627 WebMIDIClientMock* WebTestProxyBase::midiClientMock() 653 WebMIDIClientMock* WebTestProxyBase::midiClientMock()
628 { 654 {
629 if (!m_midiClient.get()) 655 if (!m_midiClient.get())
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 1322
1297 void WebTestProxyBase::resetInputMethod() 1323 void WebTestProxyBase::resetInputMethod()
1298 { 1324 {
1299 // If a composition text exists, then we need to let the browser process 1325 // If a composition text exists, then we need to let the browser process
1300 // to cancel the input method's ongoing composition session. 1326 // to cancel the input method's ongoing composition session.
1301 if (m_webWidget) 1327 if (m_webWidget)
1302 m_webWidget->confirmComposition(); 1328 m_webWidget->confirmComposition();
1303 } 1329 }
1304 1330
1305 } // namespace content 1331 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/WebTestProxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698