| 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 #ifndef MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ | 5 #ifndef MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ |
| 6 #define MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ | 6 #define MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 cc::PaintCanvas* canvas, | 57 cc::PaintCanvas* canvas, |
| 58 const Context3D& context_3d); | 58 const Context3D& context_3d); |
| 59 | 59 |
| 60 // Convert the contents of |video_frame| to raw RGB pixels. |rgb_pixels| | 60 // Convert the contents of |video_frame| to raw RGB pixels. |rgb_pixels| |
| 61 // should point into a buffer large enough to hold as many 32 bit RGBA pixels | 61 // should point into a buffer large enough to hold as many 32 bit RGBA pixels |
| 62 // as are in the visible_rect() area of the frame. | 62 // as are in the visible_rect() area of the frame. |
| 63 static void ConvertVideoFrameToRGBPixels(const media::VideoFrame* video_frame, | 63 static void ConvertVideoFrameToRGBPixels(const media::VideoFrame* video_frame, |
| 64 void* rgb_pixels, | 64 void* rgb_pixels, |
| 65 size_t row_bytes); | 65 size_t row_bytes); |
| 66 | 66 |
| 67 enum SingleFrameCopyMode { | |
| 68 SingleFrameForVideoElementOrCanvas, | |
| 69 SingleFrameForWebGL | |
| 70 }; | |
| 71 | |
| 72 // Copy the contents of texture of |video_frame| to texture |texture|. | 67 // Copy the contents of texture of |video_frame| to texture |texture|. |
| 73 // |level|, |internal_format|, |type| specify target texture |texture|. | 68 // |level|, |internal_format|, |type| specify target texture |texture|. |
| 74 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. | 69 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. |
| 75 // |copy_mode| alters how the copy is done, and takes into consideration | 70 // Assumes |texture| has already been allocated with the appropriate |
| 76 // whether the caller will clip the texture to the frame's |visible_rect|, | 71 // size and a compatible format, internal format and type; this is |
| 77 // or expects this to be done internally. | 72 // effectively a "TexSubImage" operation. |
| 78 static void CopyVideoFrameSingleTextureToGLTexture( | 73 static void CopyVideoFrameSingleTextureToGLTexture( |
| 79 gpu::gles2::GLES2Interface* gl, | 74 gpu::gles2::GLES2Interface* gl, |
| 80 VideoFrame* video_frame, | 75 VideoFrame* video_frame, |
| 81 SingleFrameCopyMode copy_mode, | |
| 82 unsigned int texture, | 76 unsigned int texture, |
| 83 unsigned int internal_format, | |
| 84 unsigned int format, | |
| 85 unsigned int type, | |
| 86 bool premultiply_alpha, | 77 bool premultiply_alpha, |
| 87 bool flip_y); | 78 bool flip_y); |
| 88 | 79 |
| 89 // Copy the contents of texture of |video_frame| to texture |texture| in | 80 // Copy the contents of texture of |video_frame| to texture |texture| in |
| 90 // context |destination_gl|. | 81 // context |destination_gl|. |
| 91 // |level|, |internal_format|, |type| specify target texture |texture|. | 82 // |level|, |internal_format|, |type| specify target texture |texture|. |
| 92 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. | 83 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. |
| 93 // |context_3d| has a GrContext that may be used during the copy. | 84 // |context_3d| has a GrContext that may be used during the copy. |
| 85 // Assumes |texture| has already been allocated with the appropriate |
| 86 // size and a compatible format, internal format and type; this is |
| 87 // effectively a "TexSubImage" operation. |
| 94 // Returns true on success. | 88 // Returns true on success. |
| 95 bool CopyVideoFrameTexturesToGLTexture( | 89 bool CopyVideoFrameTexturesToGLTexture( |
| 96 const Context3D& context_3d, | 90 const Context3D& context_3d, |
| 97 gpu::gles2::GLES2Interface* destination_gl, | 91 gpu::gles2::GLES2Interface* destination_gl, |
| 98 const scoped_refptr<VideoFrame>& video_frame, | 92 const scoped_refptr<VideoFrame>& video_frame, |
| 99 unsigned int texture, | 93 unsigned int texture, |
| 100 unsigned int internal_format, | |
| 101 unsigned int format, | |
| 102 unsigned int type, | |
| 103 bool premultiply_alpha, | 94 bool premultiply_alpha, |
| 104 bool flip_y); | 95 bool flip_y); |
| 105 | 96 |
| 106 // Converts unsigned 16-bit value to target |format| for Y16 format and | 97 // Converts unsigned 16-bit value to target |format| for Y16 format and |
| 107 // calls WebGL texImage2D. | 98 // calls WebGL texImage2D. |
| 108 // |level|, |internal_format|, |format|, |type| are WebGL texImage2D | 99 // |level|, |internal_format|, |format|, |type| are WebGL texImage2D |
| 109 // parameters. | 100 // parameters. |
| 110 // Returns false if there is no implementation for given parameters. | 101 // Returns false if there is no implementation for given parameters. |
| 111 static bool TexImage2D(unsigned target, | 102 static bool TexImage2D(unsigned target, |
| 112 gpu::gles2::GLES2Interface* gl, | 103 gpu::gles2::GLES2Interface* gl, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 154 |
| 164 // Used for unit test. | 155 // Used for unit test. |
| 165 SkISize last_image_dimensions_for_testing_; | 156 SkISize last_image_dimensions_for_testing_; |
| 166 | 157 |
| 167 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); | 158 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); |
| 168 }; | 159 }; |
| 169 | 160 |
| 170 } // namespace media | 161 } // namespace media |
| 171 | 162 |
| 172 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ | 163 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ |
| OLD | NEW |