| 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 "media/renderers/skcanvas_video_renderer.h" | 5 #include "media/renderers/skcanvas_video_renderer.h" |
| 6 | 6 |
| 7 #include <GLES3/gl3.h> | 7 #include <GLES3/gl3.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 scoped_refptr<VideoFrame> frame_; | 338 scoped_refptr<VideoFrame> frame_; |
| 339 | 339 |
| 340 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoImageGenerator); | 340 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoImageGenerator); |
| 341 }; | 341 }; |
| 342 | 342 |
| 343 SkCanvasVideoRenderer::SkCanvasVideoRenderer() | 343 SkCanvasVideoRenderer::SkCanvasVideoRenderer() |
| 344 : last_image_deleting_timer_( | 344 : last_image_deleting_timer_( |
| 345 FROM_HERE, | 345 FROM_HERE, |
| 346 base::TimeDelta::FromSeconds(kTemporaryResourceDeletionDelay), | 346 base::TimeDelta::FromSeconds(kTemporaryResourceDeletionDelay), |
| 347 this, | 347 this, |
| 348 &SkCanvasVideoRenderer::ResetCache) {} | 348 &SkCanvasVideoRenderer::ResetCache), |
| 349 renderer_stable_id_(cc::PaintImage::GetNextId()) {} |
| 349 | 350 |
| 350 SkCanvasVideoRenderer::~SkCanvasVideoRenderer() { | 351 SkCanvasVideoRenderer::~SkCanvasVideoRenderer() { |
| 351 ResetCache(); | 352 ResetCache(); |
| 352 } | 353 } |
| 353 | 354 |
| 354 void SkCanvasVideoRenderer::Paint(const scoped_refptr<VideoFrame>& video_frame, | 355 void SkCanvasVideoRenderer::Paint(const scoped_refptr<VideoFrame>& video_frame, |
| 355 cc::PaintCanvas* canvas, | 356 cc::PaintCanvas* canvas, |
| 356 const gfx::RectF& dest_rect, | 357 const gfx::RectF& dest_rect, |
| 357 cc::PaintFlags& flags, | 358 cc::PaintFlags& flags, |
| 358 VideoRotation video_rotation, | 359 VideoRotation video_rotation, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 // safe to access on another thread or GL context. So if we're drawing into a | 432 // safe to access on another thread or GL context. So if we're drawing into a |
| 432 // recording canvas we read the texture back into CPU memory and record that | 433 // recording canvas we read the texture back into CPU memory and record that |
| 433 // sw image into the SkPicture. The long term solution is for Skia to provide | 434 // sw image into the SkPicture. The long term solution is for Skia to provide |
| 434 // a SkPicture filter that makes a picture safe for multiple CPU raster | 435 // a SkPicture filter that makes a picture safe for multiple CPU raster |
| 435 // threads. (skbug.com/4321). | 436 // threads. (skbug.com/4321). |
| 436 sk_sp<SkImage> image; | 437 sk_sp<SkImage> image; |
| 437 if (canvas->imageInfo().colorType() == kUnknown_SkColorType) | 438 if (canvas->imageInfo().colorType() == kUnknown_SkColorType) |
| 438 image = last_image_->makeNonTextureImage(); | 439 image = last_image_->makeNonTextureImage(); |
| 439 else | 440 else |
| 440 image = last_image_; | 441 image = last_image_; |
| 441 canvas->drawImage( | 442 canvas->drawImage(cc::PaintImage(renderer_stable_id_, std::move(image), |
| 442 cc::PaintImage(std::move(image), cc::PaintImage::AnimationType::VIDEO, | 443 cc::PaintImage::AnimationType::VIDEO, |
| 443 cc::PaintImage::CompletionState::DONE), | 444 cc::PaintImage::CompletionState::DONE), |
| 444 0, 0, &video_flags); | 445 0, 0, &video_flags); |
| 445 | 446 |
| 446 if (need_transform) | 447 if (need_transform) |
| 447 canvas->restore(); | 448 canvas->restore(); |
| 448 // Make sure to flush so we can remove the videoframe from the generator. | 449 // Make sure to flush so we can remove the videoframe from the generator. |
| 449 canvas->flush(); | 450 canvas->flush(); |
| 450 | 451 |
| 451 if (video_frame->HasTextures()) { | 452 if (video_frame->HasTextures()) { |
| 452 DCHECK(gl); | 453 DCHECK(gl); |
| 453 SyncTokenClientImpl client(gl); | 454 SyncTokenClientImpl client(gl); |
| 454 video_frame->UpdateReleaseSyncToken(&client); | 455 video_frame->UpdateReleaseSyncToken(&client); |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 last_image_->bounds().contains(visible_rect)) { | 1090 last_image_->bounds().contains(visible_rect)) { |
| 1090 last_image_ = last_image_->makeSubset(visible_rect); | 1091 last_image_ = last_image_->makeSubset(visible_rect); |
| 1091 } | 1092 } |
| 1092 } | 1093 } |
| 1093 | 1094 |
| 1094 SkISize SkCanvasVideoRenderer::LastImageDimensionsForTesting() { | 1095 SkISize SkCanvasVideoRenderer::LastImageDimensionsForTesting() { |
| 1095 return last_image_dimensions_for_testing_; | 1096 return last_image_dimensions_for_testing_; |
| 1096 } | 1097 } |
| 1097 | 1098 |
| 1098 } // namespace media | 1099 } // namespace media |
| OLD | NEW |