Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: media/renderers/skcanvas_video_renderer.cc

Issue 2873003002: Add stable id to PaintImage. (Closed)
Patch Set: update Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 scoped_refptr<VideoFrame> frame_; 337 scoped_refptr<VideoFrame> frame_;
338 338
339 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoImageGenerator); 339 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoImageGenerator);
340 }; 340 };
341 341
342 SkCanvasVideoRenderer::SkCanvasVideoRenderer() 342 SkCanvasVideoRenderer::SkCanvasVideoRenderer()
343 : last_image_deleting_timer_( 343 : last_image_deleting_timer_(
344 FROM_HERE, 344 FROM_HERE,
345 base::TimeDelta::FromSeconds(kTemporaryResourceDeletionDelay), 345 base::TimeDelta::FromSeconds(kTemporaryResourceDeletionDelay),
346 this, 346 this,
347 &SkCanvasVideoRenderer::ResetCache) {} 347 &SkCanvasVideoRenderer::ResetCache),
348 renderer_stable_id_(cc::PaintImage::GetNextId()) {}
348 349
349 SkCanvasVideoRenderer::~SkCanvasVideoRenderer() { 350 SkCanvasVideoRenderer::~SkCanvasVideoRenderer() {
350 ResetCache(); 351 ResetCache();
351 } 352 }
352 353
353 void SkCanvasVideoRenderer::Paint(const scoped_refptr<VideoFrame>& video_frame, 354 void SkCanvasVideoRenderer::Paint(const scoped_refptr<VideoFrame>& video_frame,
354 cc::PaintCanvas* canvas, 355 cc::PaintCanvas* canvas,
355 const gfx::RectF& dest_rect, 356 const gfx::RectF& dest_rect,
356 cc::PaintFlags& flags, 357 cc::PaintFlags& flags,
357 VideoRotation video_rotation, 358 VideoRotation video_rotation,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // safe to access on another thread or GL context. So if we're drawing into a 431 // safe to access on another thread or GL context. So if we're drawing into a
431 // recording canvas we read the texture back into CPU memory and record that 432 // recording canvas we read the texture back into CPU memory and record that
432 // sw image into the SkPicture. The long term solution is for Skia to provide 433 // sw image into the SkPicture. The long term solution is for Skia to provide
433 // a SkPicture filter that makes a picture safe for multiple CPU raster 434 // a SkPicture filter that makes a picture safe for multiple CPU raster
434 // threads. (skbug.com/4321). 435 // threads. (skbug.com/4321).
435 sk_sp<SkImage> image; 436 sk_sp<SkImage> image;
436 if (canvas->imageInfo().colorType() == kUnknown_SkColorType) 437 if (canvas->imageInfo().colorType() == kUnknown_SkColorType)
437 image = last_image_->makeNonTextureImage(); 438 image = last_image_->makeNonTextureImage();
438 else 439 else
439 image = last_image_; 440 image = last_image_;
440 canvas->drawImage( 441 canvas->drawImage(cc::PaintImage(renderer_stable_id_, std::move(image),
441 cc::PaintImage(std::move(image), cc::PaintImage::AnimationType::VIDEO, 442 cc::PaintImage::AnimationType::VIDEO,
442 cc::PaintImage::CompletionState::DONE), 443 cc::PaintImage::CompletionState::DONE),
443 0, 0, &video_flags); 444 0, 0, &video_flags);
444 445
445 if (need_transform) 446 if (need_transform)
446 canvas->restore(); 447 canvas->restore();
447 // Make sure to flush so we can remove the videoframe from the generator. 448 // Make sure to flush so we can remove the videoframe from the generator.
448 canvas->flush(); 449 canvas->flush();
449 450
450 if (video_frame->HasTextures()) { 451 if (video_frame->HasTextures()) {
451 DCHECK(gl); 452 DCHECK(gl);
452 SyncTokenClientImpl client(gl); 453 SyncTokenClientImpl client(gl);
453 video_frame->UpdateReleaseSyncToken(&client); 454 video_frame->UpdateReleaseSyncToken(&client);
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 last_image_->bounds().contains(visible_rect)) { 1085 last_image_->bounds().contains(visible_rect)) {
1085 last_image_ = last_image_->makeSubset(visible_rect); 1086 last_image_ = last_image_->makeSubset(visible_rect);
1086 } 1087 }
1087 } 1088 }
1088 1089
1089 SkISize SkCanvasVideoRenderer::LastImageDimensionsForTesting() { 1090 SkISize SkCanvasVideoRenderer::LastImageDimensionsForTesting() {
1090 return last_image_dimensions_for_testing_; 1091 return last_image_dimensions_for_testing_;
1091 } 1092 }
1092 1093
1093 } // namespace media 1094 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698