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

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

Issue 1320613003: media: Remove SkCanvasVideoRenderer cache invalidation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/blink/skcanvas_video_renderer.h" 5 #include "media/blink/skcanvas_video_renderer.h"
6 6
7 #include "gpu/GLES2/gl2extchromium.h" 7 #include "gpu/GLES2/gl2extchromium.h"
8 #include "gpu/command_buffer/client/gles2_interface.h" 8 #include "gpu/command_buffer/client/gles2_interface.h"
9 #include "gpu/command_buffer/common/mailbox_holder.h" 9 #include "gpu/command_buffer/common/mailbox_holder.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 color_space = kRec709_SkYUVColorSpace; 120 color_space = kRec709_SkYUVColorSpace;
121 121
122 SkImage* img = SkImage::NewFromYUVTexturesCopy(context_3d.gr_context, 122 SkImage* img = SkImage::NewFromYUVTexturesCopy(context_3d.gr_context,
123 color_space, handles, yuvSizes, 123 color_space, handles, yuvSizes,
124 kTopLeft_GrSurfaceOrigin); 124 kTopLeft_GrSurfaceOrigin);
125 DCHECK(img); 125 DCHECK(img);
126 gl->DeleteTextures(3, source_textures); 126 gl->DeleteTextures(3, source_textures);
127 return skia::AdoptRef(img); 127 return skia::AdoptRef(img);
128 } 128 }
129 129
130 bool ShouldCacheVideoFrameSkImage(const VideoFrame* video_frame) {
131 return !video_frame->HasTextures() ||
132 media::VideoFrame::NumPlanes(video_frame->format()) != 1 ||
133 video_frame->mailbox_holder(0).texture_target != GL_TEXTURE_2D;
134 }
135
136 // Creates a SkImage from a |video_frame| backed by native resources. 130 // Creates a SkImage from a |video_frame| backed by native resources.
137 // The SkImage will take ownership of the underlying resource. 131 // The SkImage will take ownership of the underlying resource.
138 skia::RefPtr<SkImage> NewSkImageFromVideoFrameNative( 132 skia::RefPtr<SkImage> NewSkImageFromVideoFrameNative(
139 VideoFrame* video_frame, 133 VideoFrame* video_frame,
140 const Context3D& context_3d) { 134 const Context3D& context_3d) {
141 DCHECK(PIXEL_FORMAT_ARGB == video_frame->format() || 135 DCHECK(PIXEL_FORMAT_ARGB == video_frame->format() ||
142 PIXEL_FORMAT_UYVY == video_frame->format()); 136 PIXEL_FORMAT_UYVY == video_frame->format());
143 137
144 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(0); 138 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(0);
145 DCHECK(mailbox_holder.texture_target == GL_TEXTURE_2D || 139 DCHECK(mailbox_holder.texture_target == GL_TEXTURE_2D ||
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 canvas->translate(-SkFloatToScalar(last_image_->width() * 0.5f), 375 canvas->translate(-SkFloatToScalar(last_image_->width() * 0.5f),
382 -SkFloatToScalar(last_image_->height() * 0.5f)); 376 -SkFloatToScalar(last_image_->height() * 0.5f));
383 } 377 }
384 canvas->drawImage(last_image_.get(), 0, 0, &paint); 378 canvas->drawImage(last_image_.get(), 0, 0, &paint);
385 379
386 if (need_transform) 380 if (need_transform)
387 canvas->restore(); 381 canvas->restore();
388 // Make sure to flush so we can remove the videoframe from the generator. 382 // Make sure to flush so we can remove the videoframe from the generator.
389 canvas->flush(); 383 canvas->flush();
390 384
391 if (!ShouldCacheVideoFrameSkImage(video_frame.get()))
392 ResetCache();
393
394 if (video_frame->HasTextures()) { 385 if (video_frame->HasTextures()) {
395 DCHECK(gl); 386 DCHECK(gl);
396 SyncPointClientImpl client(gl); 387 SyncPointClientImpl client(gl);
397 video_frame->UpdateReleaseSyncPoint(&client); 388 video_frame->UpdateReleaseSyncPoint(&client);
398 } 389 }
399 } 390 }
400 391
401 void SkCanvasVideoRenderer::Copy(const scoped_refptr<VideoFrame>& video_frame, 392 void SkCanvasVideoRenderer::Copy(const scoped_refptr<VideoFrame>& video_frame,
402 SkCanvas* canvas, 393 SkCanvas* canvas,
403 const Context3D& context_3d) { 394 const Context3D& context_3d) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 video_frame->UpdateReleaseSyncPoint(&client); 585 video_frame->UpdateReleaseSyncPoint(&client);
595 } 586 }
596 587
597 void SkCanvasVideoRenderer::ResetCache() { 588 void SkCanvasVideoRenderer::ResetCache() {
598 // Clear cached values. 589 // Clear cached values.
599 last_image_ = nullptr; 590 last_image_ = nullptr;
600 last_timestamp_ = kNoTimestamp(); 591 last_timestamp_ = kNoTimestamp();
601 } 592 }
602 593
603 } // namespace media 594 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698