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 <limits> |
| 8 |
7 #include "gpu/GLES2/gl2extchromium.h" | 9 #include "gpu/GLES2/gl2extchromium.h" |
8 #include "gpu/command_buffer/client/gles2_interface.h" | 10 #include "gpu/command_buffer/client/gles2_interface.h" |
9 #include "gpu/command_buffer/common/mailbox_holder.h" | 11 #include "gpu/command_buffer/common/mailbox_holder.h" |
10 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
11 #include "media/base/yuv_convert.h" | 13 #include "media/base/yuv_convert.h" |
12 #include "skia/ext/refptr.h" | 14 #include "skia/ext/refptr.h" |
13 #include "third_party/libyuv/include/libyuv.h" | 15 #include "third_party/libyuv/include/libyuv.h" |
14 #include "third_party/skia/include/core/SkCanvas.h" | 16 #include "third_party/skia/include/core/SkCanvas.h" |
15 #include "third_party/skia/include/core/SkImage.h" | 17 #include "third_party/skia/include/core/SkImage.h" |
16 #include "third_party/skia/include/core/SkImageGenerator.h" | 18 #include "third_party/skia/include/core/SkImageGenerator.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 gl->GenTextures(1, &texture_copy); | 114 gl->GenTextures(1, &texture_copy); |
113 DCHECK(texture_copy); | 115 DCHECK(texture_copy); |
114 gl->BindTexture(GL_TEXTURE_2D, texture_copy); | 116 gl->BindTexture(GL_TEXTURE_2D, texture_copy); |
115 gl->CopyTextureCHROMIUM(GL_TEXTURE_2D, source_textures[i], texture_copy, | 117 gl->CopyTextureCHROMIUM(GL_TEXTURE_2D, source_textures[i], texture_copy, |
116 GL_RGB, GL_UNSIGNED_BYTE, false, true, false); | 118 GL_RGB, GL_UNSIGNED_BYTE, false, true, false); |
117 | 119 |
118 gl->DeleteTextures(1, &source_textures[i]); | 120 gl->DeleteTextures(1, &source_textures[i]); |
119 source_textures[i] = texture_copy; | 121 source_textures[i] = texture_copy; |
120 } | 122 } |
121 } | 123 } |
122 GrBackendObject handles[3] = {source_textures[0], source_textures[1], | 124 DCHECK_LE(source_textures[0], |
123 source_textures[2]}; | 125 static_cast<unsigned>(std::numeric_limits<int>::max())); |
| 126 DCHECK_LE(source_textures[1], |
| 127 static_cast<unsigned>(std::numeric_limits<int>::max())); |
| 128 DCHECK_LE(source_textures[2], |
| 129 static_cast<unsigned>(std::numeric_limits<int>::max())); |
| 130 GrBackendObject handles[3] = {static_cast<int>(source_textures[0]), |
| 131 static_cast<int>(source_textures[1]), |
| 132 static_cast<int>(source_textures[2])}; |
124 | 133 |
125 SkISize yuvSizes[] = { | 134 SkISize yuvSizes[] = { |
126 {ya_tex_size.width(), ya_tex_size.height()}, | 135 {ya_tex_size.width(), ya_tex_size.height()}, |
127 {uv_tex_size.width(), uv_tex_size.height()}, | 136 {uv_tex_size.width(), uv_tex_size.height()}, |
128 {uv_tex_size.width(), uv_tex_size.height()}, | 137 {uv_tex_size.width(), uv_tex_size.height()}, |
129 }; | 138 }; |
130 | 139 |
131 SkYUVColorSpace color_space = kRec601_SkYUVColorSpace; | 140 SkYUVColorSpace color_space = kRec601_SkYUVColorSpace; |
132 if (CheckColorSpace(video_frame, media::COLOR_SPACE_JPEG)) | 141 if (CheckColorSpace(video_frame, media::COLOR_SPACE_JPEG)) |
133 color_space = kJPEG_SkYUVColorSpace; | 142 color_space = kJPEG_SkYUVColorSpace; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); | 182 gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData()); |
174 source_texture = gl->CreateAndConsumeTextureCHROMIUM( | 183 source_texture = gl->CreateAndConsumeTextureCHROMIUM( |
175 mailbox_holder.texture_target, mailbox_holder.mailbox.name); | 184 mailbox_holder.texture_target, mailbox_holder.mailbox.name); |
176 } | 185 } |
177 GrBackendTextureDesc desc; | 186 GrBackendTextureDesc desc; |
178 desc.fFlags = kRenderTarget_GrBackendTextureFlag; | 187 desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
179 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 188 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
180 desc.fWidth = video_frame->coded_size().width(); | 189 desc.fWidth = video_frame->coded_size().width(); |
181 desc.fHeight = video_frame->coded_size().height(); | 190 desc.fHeight = video_frame->coded_size().height(); |
182 desc.fConfig = kRGBA_8888_GrPixelConfig; | 191 desc.fConfig = kRGBA_8888_GrPixelConfig; |
183 desc.fTextureHandle = source_texture; | 192 DCHECK_LE(source_texture, |
| 193 static_cast<unsigned>(std::numeric_limits<int>::max())); |
| 194 desc.fTextureHandle = static_cast<int>(source_texture); |
184 return skia::AdoptRef( | 195 return skia::AdoptRef( |
185 SkImage::NewFromAdoptedTexture(context_3d.gr_context, desc)); | 196 SkImage::NewFromAdoptedTexture(context_3d.gr_context, desc)); |
186 } | 197 } |
187 | 198 |
188 } // anonymous namespace | 199 } // anonymous namespace |
189 | 200 |
190 // Generates an RGB image from a VideoFrame. Convert YUV to RGB plain on GPU. | 201 // Generates an RGB image from a VideoFrame. Convert YUV to RGB plain on GPU. |
191 class VideoImageGenerator : public SkImageGenerator { | 202 class VideoImageGenerator : public SkImageGenerator { |
192 public: | 203 public: |
193 VideoImageGenerator(const scoped_refptr<VideoFrame>& frame) | 204 VideoImageGenerator(const scoped_refptr<VideoFrame>& frame) |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 } | 593 } |
583 | 594 |
584 void SkCanvasVideoRenderer::ResetCache() { | 595 void SkCanvasVideoRenderer::ResetCache() { |
585 DCHECK(thread_checker_.CalledOnValidThread()); | 596 DCHECK(thread_checker_.CalledOnValidThread()); |
586 // Clear cached values. | 597 // Clear cached values. |
587 last_image_ = nullptr; | 598 last_image_ = nullptr; |
588 last_timestamp_ = kNoTimestamp(); | 599 last_timestamp_ = kNoTimestamp(); |
589 } | 600 } |
590 | 601 |
591 } // namespace media | 602 } // namespace media |
OLD | NEW |