OLD | NEW |
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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 | 481 |
482 void WebTestProxyBase::didCompositeAndReadback(const SkBitmap& bitmap) { | 482 void WebTestProxyBase::didCompositeAndReadback(const SkBitmap& bitmap) { |
483 TRACE_EVENT2("shell", | 483 TRACE_EVENT2("shell", |
484 "WebTestProxyBase::didCompositeAndReadback", | 484 "WebTestProxyBase::didCompositeAndReadback", |
485 "x", | 485 "x", |
486 bitmap.info().fWidth, | 486 bitmap.info().fWidth, |
487 "y", | 487 "y", |
488 bitmap.info().fHeight); | 488 bitmap.info().fHeight); |
489 SkCanvas canvas(bitmap); | 489 SkCanvas canvas(bitmap); |
490 DrawSelectionRect(&canvas); | 490 DrawSelectionRect(&canvas); |
| 491 DCHECK(!m_compositeAndReadbackCallback.is_null()); |
491 base::ResetAndReturn(&m_compositeAndReadbackCallback).Run(bitmap); | 492 base::ResetAndReturn(&m_compositeAndReadbackCallback).Run(bitmap); |
492 } | 493 } |
493 | 494 |
494 void WebTestProxyBase::CapturePixelsAsync( | 495 void WebTestProxyBase::CapturePixelsAsync( |
495 base::Callback<void(const SkBitmap&)> callback) { | 496 base::Callback<void(const SkBitmap&)> callback) { |
496 m_compositeAndReadbackCallback = callback; | |
497 TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixelsAsync"); | 497 TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixelsAsync"); |
498 | 498 |
499 // Do a layout here because it might leave compositing mode! x.x | 499 // Do a layout here because it might leave compositing mode! x.x |
500 // TODO(danakj): Remove this when we have kForceCompositingMode everywhere. | 500 // TODO(danakj): Remove this when we have kForceCompositingMode everywhere. |
501 webWidget()->layout(); | 501 webWidget()->layout(); |
502 | 502 |
503 if (!webWidget()->compositeAndReadbackAsync(this)) { | 503 if (!webWidget()->isAcceleratedCompositingActive()) { |
504 TRACE_EVENT0("shell", | 504 TRACE_EVENT0("shell", |
505 "WebTestProxyBase::CapturePixelsAsync " | 505 "WebTestProxyBase::CapturePixelsAsync " |
506 "compositeAndReadbackAsync failed"); | 506 "isAcceleratedCompositingActive false"); |
507 didCompositeAndReadback(SkBitmap()); | 507 callback.Run(SkBitmap()); |
| 508 return; |
508 } | 509 } |
| 510 |
| 511 DCHECK(!callback.is_null()); |
| 512 DCHECK(m_compositeAndReadbackCallback.is_null()); |
| 513 m_compositeAndReadbackCallback = callback; |
| 514 webWidget()->compositeAndReadbackAsync(this); |
509 } | 515 } |
510 | 516 |
511 void WebTestProxyBase::setLogConsoleOutput(bool enabled) | 517 void WebTestProxyBase::setLogConsoleOutput(bool enabled) |
512 { | 518 { |
513 m_logConsoleOutput = enabled; | 519 m_logConsoleOutput = enabled; |
514 } | 520 } |
515 | 521 |
516 void WebTestProxyBase::paintRect(const WebRect& rect) | 522 void WebTestProxyBase::paintRect(const WebRect& rect) |
517 { | 523 { |
518 DCHECK(!m_isPainting); | 524 DCHECK(!m_isPainting); |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 | 1306 |
1301 void WebTestProxyBase::resetInputMethod() | 1307 void WebTestProxyBase::resetInputMethod() |
1302 { | 1308 { |
1303 // If a composition text exists, then we need to let the browser process | 1309 // If a composition text exists, then we need to let the browser process |
1304 // to cancel the input method's ongoing composition session. | 1310 // to cancel the input method's ongoing composition session. |
1305 if (m_webWidget) | 1311 if (m_webWidget) |
1306 m_webWidget->confirmComposition(); | 1312 m_webWidget->confirmComposition(); |
1307 } | 1313 } |
1308 | 1314 |
1309 } // namespace content | 1315 } // namespace content |
OLD | NEW |