| 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 "cc/resources/video_resource_updater.h" | 5 #include "cc/resources/video_resource_updater.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bit_cast.h" | 13 #include "base/bit_cast.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "cc/base/math_util.h" | 15 #include "cc/base/math_util.h" |
| 16 #include "cc/output/gl_renderer.h" | 16 #include "cc/output/gl_renderer.h" |
| 17 #include "cc/resources/resource_provider.h" | 17 #include "cc/resources/resource_provider.h" |
| 18 #include "cc/resources/resource_util.h" | 18 #include "cc/resources/resource_util.h" |
| 19 #include "gpu/GLES2/gl2extchromium.h" | 19 #include "gpu/GLES2/gl2extchromium.h" |
| 20 #include "gpu/command_buffer/client/gles2_interface.h" | 20 #include "gpu/command_buffer/client/gles2_interface.h" |
| 21 #include "media/base/video_frame.h" | 21 #include "media/base/video_frame.h" |
| 22 #include "media/renderers/skcanvas_video_renderer.h" | 22 #include "media/renderers/skcanvas_video_renderer.h" |
| 23 #include "third_party/khronos/GLES2/gl2.h" | 23 #include "third_party/khronos/GLES2/gl2.h" |
| 24 #include "third_party/khronos/GLES2/gl2ext.h" | 24 #include "third_party/khronos/GLES2/gl2ext.h" |
| 25 #include "third_party/libyuv/include/libyuv.h" | 25 #include "third_party/libyuv/include/libyuv.h" |
| 26 #include "third_party/skia/include/core/SkCanvas.h" | 26 #include "third_party/skia/include/core/SkCanvas.h" |
| 27 #include "skia/ext/cdl_canvas.h" |
| 27 #include "ui/gfx/geometry/size_conversions.h" | 28 #include "ui/gfx/geometry/size_conversions.h" |
| 28 | 29 |
| 29 namespace cc { | 30 namespace cc { |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 const ResourceFormat kRGBResourceFormat = RGBA_8888; | 34 const ResourceFormat kRGBResourceFormat = RGBA_8888; |
| 34 | 35 |
| 35 VideoFrameExternalResources::ResourceType ResourceTypeForVideoFrame( | 36 VideoFrameExternalResources::ResourceType ResourceTypeForVideoFrame( |
| 36 media::VideoFrame* video_frame) { | 37 media::VideoFrame* video_frame) { |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 DCHECK_EQ(software_compositor, plane_resource.mailbox().IsZero()); | 532 DCHECK_EQ(software_compositor, plane_resource.mailbox().IsZero()); |
| 532 | 533 |
| 533 if (!plane_resource.Matches(video_frame->unique_id(), 0)) { | 534 if (!plane_resource.Matches(video_frame->unique_id(), 0)) { |
| 534 // We need to transfer data from |video_frame| to the plane resource. | 535 // We need to transfer data from |video_frame| to the plane resource. |
| 535 if (software_compositor) { | 536 if (software_compositor) { |
| 536 if (!video_renderer_) | 537 if (!video_renderer_) |
| 537 video_renderer_.reset(new media::SkCanvasVideoRenderer); | 538 video_renderer_.reset(new media::SkCanvasVideoRenderer); |
| 538 | 539 |
| 539 ResourceProvider::ScopedWriteLockSoftware lock( | 540 ResourceProvider::ScopedWriteLockSoftware lock( |
| 540 resource_provider_, plane_resource.resource_id()); | 541 resource_provider_, plane_resource.resource_id()); |
| 541 SkCanvas canvas(lock.sk_bitmap()); | 542 CdlCanvas canvas(lock.sk_bitmap()); |
| 542 // This is software path, so canvas and video_frame are always backed | 543 // This is software path, so canvas and video_frame are always backed |
| 543 // by software. | 544 // by software. |
| 544 video_renderer_->Copy(video_frame, &canvas, media::Context3D()); | 545 video_renderer_->Copy(video_frame, &canvas, media::Context3D()); |
| 545 } else { | 546 } else { |
| 546 size_t bytes_per_row = ResourceUtil::CheckedWidthInBytes<size_t>( | 547 size_t bytes_per_row = ResourceUtil::CheckedWidthInBytes<size_t>( |
| 547 video_frame->coded_size().width(), ResourceFormat::RGBA_8888); | 548 video_frame->coded_size().width(), ResourceFormat::RGBA_8888); |
| 548 size_t needed_size = bytes_per_row * video_frame->coded_size().height(); | 549 size_t needed_size = bytes_per_row * video_frame->coded_size().height(); |
| 549 if (upload_pixels_.size() < needed_size) | 550 if (upload_pixels_.size() < needed_size) |
| 550 upload_pixels_.resize(needed_size); | 551 upload_pixels_.resize(needed_size); |
| 551 | 552 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 if (lost_resource) { | 831 if (lost_resource) { |
| 831 resource_it->clear_refs(); | 832 resource_it->clear_refs(); |
| 832 updater->DeleteResource(resource_it); | 833 updater->DeleteResource(resource_it); |
| 833 return; | 834 return; |
| 834 } | 835 } |
| 835 | 836 |
| 836 resource_it->remove_ref(); | 837 resource_it->remove_ref(); |
| 837 } | 838 } |
| 838 | 839 |
| 839 } // namespace cc | 840 } // namespace cc |
| OLD | NEW |