| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 host->Send(new ViewMsg_ImeEventAck(host->GetRoutingID())); | 90 host->Send(new ViewMsg_ImeEventAck(host->GetRoutingID())); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void CopyFromCompositingSurfaceFinished( | 93 void CopyFromCompositingSurfaceFinished( |
| 94 const base::Callback<void(bool, const SkBitmap&)>& callback, | 94 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 95 scoped_ptr<cc::SingleReleaseCallback> release_callback, | 95 scoped_ptr<cc::SingleReleaseCallback> release_callback, |
| 96 scoped_ptr<SkBitmap> bitmap, | 96 scoped_ptr<SkBitmap> bitmap, |
| 97 const base::TimeTicks& start_time, | 97 const base::TimeTicks& start_time, |
| 98 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, | 98 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, |
| 99 bool result) { | 99 bool result) { |
| 100 TRACE_EVENT0( |
| 101 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished"); |
| 100 bitmap_pixels_lock.reset(); | 102 bitmap_pixels_lock.reset(); |
| 101 release_callback->Run(0, false); | 103 release_callback->Run(0, false); |
| 102 UMA_HISTOGRAM_TIMES(kAsyncReadBackString, | 104 UMA_HISTOGRAM_TIMES(kAsyncReadBackString, |
| 103 base::TimeTicks::Now() - start_time); | 105 base::TimeTicks::Now() - start_time); |
| 104 callback.Run(result, *bitmap); | 106 callback.Run(result, *bitmap); |
| 105 } | 107 } |
| 106 | 108 |
| 107 ui::LatencyInfo CreateLatencyInfo(const blink::WebInputEvent& event) { | 109 ui::LatencyInfo CreateLatencyInfo(const blink::WebInputEvent& event) { |
| 108 ui::LatencyInfo latency_info; | 110 ui::LatencyInfo latency_info; |
| 109 // The latency number should only be added if the timestamp is valid. | 111 // The latency number should only be added if the timestamp is valid. |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 void RenderWidgetHostViewAndroid::SetBackgroundOpaque(bool opaque) { | 726 void RenderWidgetHostViewAndroid::SetBackgroundOpaque(bool opaque) { |
| 725 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque); | 727 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque); |
| 726 host_->SetBackgroundOpaque(opaque); | 728 host_->SetBackgroundOpaque(opaque); |
| 727 } | 729 } |
| 728 | 730 |
| 729 void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( | 731 void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( |
| 730 const gfx::Rect& src_subrect, | 732 const gfx::Rect& src_subrect, |
| 731 const gfx::Size& dst_size, | 733 const gfx::Size& dst_size, |
| 732 const base::Callback<void(bool, const SkBitmap&)>& callback, | 734 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 733 const SkColorType color_type) { | 735 const SkColorType color_type) { |
| 736 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurface"); |
| 734 if ((!host_ || host_->is_hidden()) || | 737 if ((!host_ || host_->is_hidden()) || |
| 735 !IsReadbackConfigSupported(color_type)) { | 738 !IsReadbackConfigSupported(color_type)) { |
| 736 callback.Run(false, SkBitmap()); | 739 callback.Run(false, SkBitmap()); |
| 737 return; | 740 return; |
| 738 } | 741 } |
| 739 base::TimeTicks start_time = base::TimeTicks::Now(); | 742 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 740 if (!using_synchronous_compositor_ && !IsSurfaceAvailableForCopy()) { | 743 if (!using_synchronous_compositor_ && !IsSurfaceAvailableForCopy()) { |
| 741 callback.Run(false, SkBitmap()); | 744 callback.Run(false, SkBitmap()); |
| 742 return; | 745 return; |
| 743 } | 746 } |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 | 1539 |
| 1537 // static | 1540 // static |
| 1538 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( | 1541 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
| 1539 const gfx::Size& dst_size_in_pixel, | 1542 const gfx::Size& dst_size_in_pixel, |
| 1540 const SkColorType color_type, | 1543 const SkColorType color_type, |
| 1541 const base::TimeTicks& start_time, | 1544 const base::TimeTicks& start_time, |
| 1542 const base::Callback<void(bool, const SkBitmap&)>& callback, | 1545 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 1543 scoped_ptr<cc::CopyOutputResult> result) { | 1546 scoped_ptr<cc::CopyOutputResult> result) { |
| 1544 base::ScopedClosureRunner scoped_callback_runner( | 1547 base::ScopedClosureRunner scoped_callback_runner( |
| 1545 base::Bind(callback, false, SkBitmap())); | 1548 base::Bind(callback, false, SkBitmap())); |
| 1549 TRACE_EVENT0("cc", |
| 1550 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult"); |
| 1546 | 1551 |
| 1547 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) | 1552 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) |
| 1548 return; | 1553 return; |
| 1549 | 1554 |
| 1550 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 1555 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
| 1551 if (!bitmap->allocPixels(SkImageInfo::Make(dst_size_in_pixel.width(), | 1556 if (!bitmap->allocPixels(SkImageInfo::Make(dst_size_in_pixel.width(), |
| 1552 dst_size_in_pixel.height(), | 1557 dst_size_in_pixel.height(), |
| 1553 color_type, | 1558 color_type, |
| 1554 kOpaque_SkAlphaType))) | 1559 kOpaque_SkAlphaType))) |
| 1555 return; | 1560 return; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1650 results->orientationAngle = display.RotationAsDegree(); | 1655 results->orientationAngle = display.RotationAsDegree(); |
| 1651 results->orientationType = | 1656 results->orientationType = |
| 1652 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 1657 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
| 1653 gfx::DeviceDisplayInfo info; | 1658 gfx::DeviceDisplayInfo info; |
| 1654 results->depth = info.GetBitsPerPixel(); | 1659 results->depth = info.GetBitsPerPixel(); |
| 1655 results->depthPerComponent = info.GetBitsPerComponent(); | 1660 results->depthPerComponent = info.GetBitsPerComponent(); |
| 1656 results->isMonochrome = (results->depthPerComponent == 0); | 1661 results->isMonochrome = (results->depthPerComponent == 0); |
| 1657 } | 1662 } |
| 1658 | 1663 |
| 1659 } // namespace content | 1664 } // namespace content |
| OLD | NEW |