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 type, |
77 bool premultiply_alpha, | 85 bool premultiply_alpha, |
78 bool flip_y); | 86 bool flip_y); |
79 | 87 |
80 // Copy the contents of texture of |video_frame| to texture |texture| in | 88 // Copy the contents of texture of |video_frame| to texture |texture| in |
81 // context |destination_gl|. | 89 // context |destination_gl|. |
82 // |level|, |internal_format|, |type| specify target texture |texture|. | 90 // |level|, |internal_format|, |type| specify target texture |texture|. |
83 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. | 91 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. |
84 // |context_3d| has a GrContext that may be used during the copy. | 92 // |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. | 93 // Returns true on success. |
89 bool CopyVideoFrameTexturesToGLTexture( | 94 bool CopyVideoFrameTexturesToGLTexture( |
90 const Context3D& context_3d, | 95 const Context3D& context_3d, |
91 gpu::gles2::GLES2Interface* destination_gl, | 96 gpu::gles2::GLES2Interface* destination_gl, |
92 const scoped_refptr<VideoFrame>& video_frame, | 97 const scoped_refptr<VideoFrame>& video_frame, |
93 unsigned int texture, | 98 unsigned int texture, |
| 99 unsigned int internal_format, |
| 100 unsigned int type, |
94 bool premultiply_alpha, | 101 bool premultiply_alpha, |
95 bool flip_y); | 102 bool flip_y); |
96 | 103 |
97 // Converts unsigned 16-bit value to target |format| for Y16 format and | 104 // Converts unsigned 16-bit value to target |format| for Y16 format and |
98 // calls WebGL texImage2D. | 105 // calls WebGL texImage2D. |
99 // |level|, |internal_format|, |format|, |type| are WebGL texImage2D | 106 // |level|, |internal_format|, |format|, |type| are WebGL texImage2D |
100 // parameters. | 107 // parameters. |
101 // Returns false if there is no implementation for given parameters. | 108 // Returns false if there is no implementation for given parameters. |
102 static bool TexImage2D(unsigned target, | 109 static bool TexImage2D(unsigned target, |
103 gpu::gles2::GLES2Interface* gl, | 110 gpu::gles2::GLES2Interface* gl, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 161 |
155 // Used for unit test. | 162 // Used for unit test. |
156 SkISize last_image_dimensions_for_testing_; | 163 SkISize last_image_dimensions_for_testing_; |
157 | 164 |
158 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); | 165 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); |
159 }; | 166 }; |
160 | 167 |
161 } // namespace media | 168 } // namespace media |
162 | 169 |
163 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ | 170 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ |
OLD | NEW |