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/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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 SkYUVColorSpace color_space = kRec601_SkYUVColorSpace; | 119 SkYUVColorSpace color_space = kRec601_SkYUVColorSpace; |
120 if (CheckColorSpace(video_frame, media::COLOR_SPACE_JPEG)) | 120 if (CheckColorSpace(video_frame, media::COLOR_SPACE_JPEG)) |
121 color_space = kJPEG_SkYUVColorSpace; | 121 color_space = kJPEG_SkYUVColorSpace; |
122 else if (CheckColorSpace(video_frame, media::COLOR_SPACE_HD_REC709)) | 122 else if (CheckColorSpace(video_frame, media::COLOR_SPACE_HD_REC709)) |
123 color_space = kRec709_SkYUVColorSpace; | 123 color_space = kRec709_SkYUVColorSpace; |
124 | 124 |
125 SkImage* img = SkImage::NewFromYUVTexturesCopy(context_3d.gr_context, | 125 SkImage* img = SkImage::NewFromYUVTexturesCopy(context_3d.gr_context, |
126 color_space, handles, yuvSizes, | 126 color_space, handles, yuvSizes, |
127 kTopLeft_GrSurfaceOrigin); | 127 kTopLeft_GrSurfaceOrigin); |
128 DCHECK(img); | |
129 gl->DeleteTextures(3, source_textures); | 128 gl->DeleteTextures(3, source_textures); |
130 return skia::AdoptRef(img); | 129 return skia::AdoptRef(img); |
131 } | 130 } |
132 | 131 |
133 // Creates a SkImage from a |video_frame| backed by native resources. | 132 // Creates a SkImage from a |video_frame| backed by native resources. |
134 // The SkImage will take ownership of the underlying resource. | 133 // The SkImage will take ownership of the underlying resource. |
135 skia::RefPtr<SkImage> NewSkImageFromVideoFrameNative( | 134 skia::RefPtr<SkImage> NewSkImageFromVideoFrameNative( |
136 VideoFrame* video_frame, | 135 VideoFrame* video_frame, |
137 const Context3D& context_3d) { | 136 const Context3D& context_3d) { |
138 DCHECK(PIXEL_FORMAT_ARGB == video_frame->format() || | 137 DCHECK(PIXEL_FORMAT_ARGB == video_frame->format() || |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 last_image_ = | 326 last_image_ = |
328 NewSkImageFromVideoFrameNative(video_frame.get(), context_3d); | 327 NewSkImageFromVideoFrameNative(video_frame.get(), context_3d); |
329 } else { | 328 } else { |
330 last_image_ = | 329 last_image_ = |
331 NewSkImageFromVideoFrameYUVTextures(video_frame.get(), context_3d); | 330 NewSkImageFromVideoFrameYUVTextures(video_frame.get(), context_3d); |
332 } | 331 } |
333 } else { | 332 } else { |
334 auto video_generator = new VideoImageGenerator(video_frame); | 333 auto video_generator = new VideoImageGenerator(video_frame); |
335 last_image_ = skia::AdoptRef(SkImage::NewFromGenerator(video_generator)); | 334 last_image_ = skia::AdoptRef(SkImage::NewFromGenerator(video_generator)); |
336 } | 335 } |
| 336 if (!last_image_) // Couldn't create the SkImage. |
| 337 return; |
337 last_timestamp_ = video_frame->timestamp(); | 338 last_timestamp_ = video_frame->timestamp(); |
338 } | 339 } |
339 last_image_deleting_timer_.Reset(); | 340 last_image_deleting_timer_.Reset(); |
340 | 341 |
341 paint.setXfermodeMode(mode); | 342 paint.setXfermodeMode(mode); |
342 paint.setFilterQuality(kLow_SkFilterQuality); | 343 paint.setFilterQuality(kLow_SkFilterQuality); |
343 | 344 |
344 const bool need_transform = | 345 const bool need_transform = |
345 video_rotation != VIDEO_ROTATION_0 || | 346 video_rotation != VIDEO_ROTATION_0 || |
346 dest_rect.size() != video_frame->visible_rect().size() || | 347 dest_rect.size() != video_frame->visible_rect().size() || |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 video_frame->UpdateReleaseSyncPoint(&client); | 570 video_frame->UpdateReleaseSyncPoint(&client); |
570 } | 571 } |
571 | 572 |
572 void SkCanvasVideoRenderer::ResetCache() { | 573 void SkCanvasVideoRenderer::ResetCache() { |
573 // Clear cached values. | 574 // Clear cached values. |
574 last_image_ = nullptr; | 575 last_image_ = nullptr; |
575 last_timestamp_ = kNoTimestamp(); | 576 last_timestamp_ = kNoTimestamp(); |
576 } | 577 } |
577 | 578 |
578 } // namespace media | 579 } // namespace media |
OLD | NEW |