| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "remoting/client/software_video_renderer.h" | 5 #include "remoting/client/software_video_renderer.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // This class wraps a VideoDecoder and byte-swaps the pixels for compatibility | 30 // This class wraps a VideoDecoder and byte-swaps the pixels for compatibility |
| 31 // with the android.graphics.Bitmap class. | 31 // with the android.graphics.Bitmap class. |
| 32 // TODO(lambroslambrou): Refactor so that the VideoDecoder produces data | 32 // TODO(lambroslambrou): Refactor so that the VideoDecoder produces data |
| 33 // in the right byte-order, instead of swapping it here. | 33 // in the right byte-order, instead of swapping it here. |
| 34 class RgbToBgrVideoDecoderFilter : public VideoDecoder { | 34 class RgbToBgrVideoDecoderFilter : public VideoDecoder { |
| 35 public: | 35 public: |
| 36 RgbToBgrVideoDecoderFilter(scoped_ptr<VideoDecoder> parent) | 36 RgbToBgrVideoDecoderFilter(scoped_ptr<VideoDecoder> parent) |
| 37 : parent_(parent.Pass()) { | 37 : parent_(parent.Pass()) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 virtual void Initialize(const webrtc::DesktopSize& screen_size) OVERRIDE { | 40 virtual void Initialize(const webrtc::DesktopSize& screen_size) override { |
| 41 parent_->Initialize(screen_size); | 41 parent_->Initialize(screen_size); |
| 42 } | 42 } |
| 43 | 43 |
| 44 virtual bool DecodePacket(const VideoPacket& packet) OVERRIDE { | 44 virtual bool DecodePacket(const VideoPacket& packet) override { |
| 45 return parent_->DecodePacket(packet); | 45 return parent_->DecodePacket(packet); |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual void Invalidate(const webrtc::DesktopSize& view_size, | 48 virtual void Invalidate(const webrtc::DesktopSize& view_size, |
| 49 const webrtc::DesktopRegion& region) OVERRIDE { | 49 const webrtc::DesktopRegion& region) override { |
| 50 return parent_->Invalidate(view_size, region); | 50 return parent_->Invalidate(view_size, region); |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual void RenderFrame(const webrtc::DesktopSize& view_size, | 53 virtual void RenderFrame(const webrtc::DesktopSize& view_size, |
| 54 const webrtc::DesktopRect& clip_area, | 54 const webrtc::DesktopRect& clip_area, |
| 55 uint8* image_buffer, | 55 uint8* image_buffer, |
| 56 int image_stride, | 56 int image_stride, |
| 57 webrtc::DesktopRegion* output_region) OVERRIDE { | 57 webrtc::DesktopRegion* output_region) override { |
| 58 parent_->RenderFrame(view_size, clip_area, image_buffer, image_stride, | 58 parent_->RenderFrame(view_size, clip_area, image_buffer, image_stride, |
| 59 output_region); | 59 output_region); |
| 60 | 60 |
| 61 for (webrtc::DesktopRegion::Iterator i(*output_region); !i.IsAtEnd(); | 61 for (webrtc::DesktopRegion::Iterator i(*output_region); !i.IsAtEnd(); |
| 62 i.Advance()) { | 62 i.Advance()) { |
| 63 webrtc::DesktopRect rect = i.rect(); | 63 webrtc::DesktopRect rect = i.rect(); |
| 64 uint8* pixels = image_buffer + (rect.top() * image_stride) + | 64 uint8* pixels = image_buffer + (rect.top() * image_stride) + |
| 65 (rect.left() * kBytesPerPixel); | 65 (rect.left() * kBytesPerPixel); |
| 66 libyuv::ABGRToARGB(pixels, image_stride, pixels, image_stride, | 66 libyuv::ABGRToARGB(pixels, image_stride, pixels, image_stride, |
| 67 rect.width(), rect.height()); | 67 rect.width(), rect.height()); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 virtual const webrtc::DesktopRegion* GetImageShape() OVERRIDE { | 71 virtual const webrtc::DesktopRegion* GetImageShape() override { |
| 72 return parent_->GetImageShape(); | 72 return parent_->GetImageShape(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 scoped_ptr<VideoDecoder> parent_; | 76 scoped_ptr<VideoDecoder> parent_; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 class SoftwareVideoRenderer::Core { | 79 class SoftwareVideoRenderer::Core { |
| 80 public: | 80 public: |
| 81 Core(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 81 Core(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 DCHECK(CalledOnValidThread()); | 416 DCHECK(CalledOnValidThread()); |
| 417 | 417 |
| 418 // Record the latency between the packet being received and presented. | 418 // Record the latency between the packet being received and presented. |
| 419 stats_.video_decode_ms()->Record( | 419 stats_.video_decode_ms()->Record( |
| 420 (base::Time::Now() - decode_start).InMilliseconds()); | 420 (base::Time::Now() - decode_start).InMilliseconds()); |
| 421 | 421 |
| 422 done.Run(); | 422 done.Run(); |
| 423 } | 423 } |
| 424 | 424 |
| 425 } // namespace remoting | 425 } // namespace remoting |
| OLD | NEW |