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