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_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1234 ConvertRectToPixel(current_device_scale_factor_, src_subrect); | 1234 ConvertRectToPixel(current_device_scale_factor_, src_subrect); |
1235 request->set_area(src_subrect_in_pixel); | 1235 request->set_area(src_subrect_in_pixel); |
1236 window_->layer()->RequestCopyOfOutput(request.Pass()); | 1236 window_->layer()->RequestCopyOfOutput(request.Pass()); |
1237 } | 1237 } |
1238 | 1238 |
1239 bool RenderWidgetHostViewAura::CanCopyToBitmap() const { | 1239 bool RenderWidgetHostViewAura::CanCopyToBitmap() const { |
1240 return GetCompositor() && window_->layer()->has_external_content(); | 1240 return GetCompositor() && window_->layer()->has_external_content(); |
1241 } | 1241 } |
1242 | 1242 |
1243 bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const { | 1243 bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const { |
1244 // TODO(skaslev): Implement this path for s/w compositing by handling software | |
1245 // CopyOutputResult in CopyFromCompositingSurfaceHasResultForVideo(). | |
1246 return GetCompositor() && | 1244 return GetCompositor() && |
1247 window_->layer()->has_external_content() && | 1245 window_->layer()->has_external_content() && |
1248 host_->is_accelerated_compositing_active(); | 1246 host_->is_accelerated_compositing_active(); |
1249 } | 1247 } |
1250 | 1248 |
1251 bool RenderWidgetHostViewAura::CanSubscribeFrame() const { | 1249 bool RenderWidgetHostViewAura::CanSubscribeFrame() const { |
1252 return true; | 1250 return true; |
1253 } | 1251 } |
1254 | 1252 |
1255 void RenderWidgetHostViewAura::BeginFrameSubscription( | 1253 void RenderWidgetHostViewAura::BeginFrameSubscription( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1379 } | 1377 } |
1380 | 1378 |
1381 void RenderWidgetHostViewAura::DidReceiveFrameFromRenderer() { | 1379 void RenderWidgetHostViewAura::DidReceiveFrameFromRenderer() { |
1382 if (frame_subscriber() && CanCopyToVideoFrame()) { | 1380 if (frame_subscriber() && CanCopyToVideoFrame()) { |
1383 const base::Time present_time = base::Time::Now(); | 1381 const base::Time present_time = base::Time::Now(); |
1384 scoped_refptr<media::VideoFrame> frame; | 1382 scoped_refptr<media::VideoFrame> frame; |
1385 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; | 1383 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; |
1386 if (frame_subscriber()->ShouldCaptureFrame(present_time, | 1384 if (frame_subscriber()->ShouldCaptureFrame(present_time, |
1387 &frame, &callback)) { | 1385 &frame, &callback)) { |
1388 CopyFromCompositingSurfaceToVideoFrame( | 1386 CopyFromCompositingSurfaceToVideoFrame( |
1389 gfx::Rect(ConvertSizeToDIP(current_surface_->device_scale_factor(), | 1387 gfx::Rect(current_frame_size_), |
danakj
2013/08/06 15:25:03
Why this change? We want to copy the full layer's
| |
1390 current_surface_->size())), | |
1391 frame, | 1388 frame, |
1392 base::Bind(callback, present_time)); | 1389 base::Bind(callback, present_time)); |
1393 } | 1390 } |
1394 } | 1391 } |
1395 } | 1392 } |
1396 | 1393 |
1397 #if defined(OS_WIN) | 1394 #if defined(OS_WIN) |
1398 void RenderWidgetHostViewAura::UpdateTransientRects( | 1395 void RenderWidgetHostViewAura::UpdateTransientRects( |
1399 const std::vector<gfx::Rect>& rects) { | 1396 const std::vector<gfx::Rect>& rects) { |
1400 transient_rects_ = rects; | 1397 transient_rects_ = rects; |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1880 result->size()); | 1877 result->size()); |
1881 region_in_frame = gfx::Rect(region_in_frame.x() & ~1, | 1878 region_in_frame = gfx::Rect(region_in_frame.x() & ~1, |
1882 region_in_frame.y() & ~1, | 1879 region_in_frame.y() & ~1, |
1883 region_in_frame.width() & ~1, | 1880 region_in_frame.width() & ~1, |
1884 region_in_frame.height() & ~1); | 1881 region_in_frame.height() & ~1); |
1885 if (region_in_frame.IsEmpty()) | 1882 if (region_in_frame.IsEmpty()) |
1886 return; | 1883 return; |
1887 | 1884 |
1888 // We only handle texture readbacks for now. If the compositor is in software | 1885 // We only handle texture readbacks for now. If the compositor is in software |
1889 // mode, we could produce a software-backed VideoFrame here as well. | 1886 // mode, we could produce a software-backed VideoFrame here as well. |
1890 if (!result->HasTexture()) | 1887 if (!result->HasTexture()) { |
1888 DCHECK(result->HasBitmap()); | |
1889 scoped_ptr<SkBitmap> bitmap = result->TakeBitmap(); | |
1890 // Scale the bitmap to the required size, if necessary. | |
1891 SkBitmap scaled_bitmap; | |
1892 if (result->size().width() != region_in_frame.width() || | |
1893 result->size().height() != region_in_frame.height()) { | |
1894 skia::ImageOperations::ResizeMethod method = | |
1895 skia::ImageOperations::RESIZE_GOOD; | |
1896 scaled_bitmap = skia::ImageOperations::Resize(*bitmap.get(), method, | |
1897 region_in_frame.width(), | |
1898 region_in_frame.height()); | |
1899 } else { | |
1900 scaled_bitmap = *bitmap.get(); | |
1901 } | |
1902 | |
1903 { | |
1904 SkAutoLockPixels scaled_bitmap_locker(scaled_bitmap); | |
1905 | |
1906 media::CopyRGBToVideoFrame( | |
1907 reinterpret_cast<uint8*>(scaled_bitmap.getPixels()), | |
1908 scaled_bitmap.rowBytes(), | |
1909 region_in_frame, | |
1910 video_frame.get()); | |
1911 } | |
1912 scoped_callback_runner.Release(); | |
1913 callback.Run(true); | |
1891 return; | 1914 return; |
1915 } | |
1892 | 1916 |
1893 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1917 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
1894 GLHelper* gl_helper = factory->GetGLHelper(); | 1918 GLHelper* gl_helper = factory->GetGLHelper(); |
1895 if (!gl_helper) | 1919 if (!gl_helper) |
1896 return; | 1920 return; |
1897 | 1921 |
1898 scoped_ptr<cc::TextureMailbox> texture_mailbox = result->TakeTexture(); | 1922 scoped_ptr<cc::TextureMailbox> texture_mailbox = result->TakeTexture(); |
1899 DCHECK(texture_mailbox->IsTexture()); | 1923 DCHECK(texture_mailbox->IsTexture()); |
1900 if (!texture_mailbox->IsTexture()) | 1924 if (!texture_mailbox->IsTexture()) |
1901 return; | 1925 return; |
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3208 RenderWidgetHost* widget) { | 3232 RenderWidgetHost* widget) { |
3209 return new RenderWidgetHostViewAura(widget); | 3233 return new RenderWidgetHostViewAura(widget); |
3210 } | 3234 } |
3211 | 3235 |
3212 // static | 3236 // static |
3213 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3237 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3214 GetScreenInfoForWindow(results, NULL); | 3238 GetScreenInfoForWindow(results, NULL); |
3215 } | 3239 } |
3216 | 3240 |
3217 } // namespace content | 3241 } // namespace content |
OLD | NEW |