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 // CopyTexture uses CopyTextureCHROMIUM internally; CopySubTexture |
| 68 // uses CopySubTextureCHROMIUM. The two options are provided because |
| 69 // this is on the performance-critical path, and CopyTextureCHROMIUM |
| 70 // is more efficient in the situation where new textures are being |
| 71 // allocated often. (This currently happens on macOS where the |
| 72 // source textures are rectangular.) |
| 73 enum SingleFrameCopyMode { |
| 74 SingleFrameCopyTexture, |
| 75 SingleFrameCopySubTexture |
| 76 }; |
| 77 |
67 // Copy the contents of texture of |video_frame| to texture |texture|. | 78 // Copy the contents of texture of |video_frame| to texture |texture|. |
68 // |level|, |internal_format|, |type| specify target texture |texture|. | 79 // |level|, |internal_format|, |type| specify target texture |texture|. |
69 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. | 80 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. |
70 // Assumes |texture| has already been allocated with the appropriate | 81 // |
71 // size and a compatible format, internal format and type; this is | 82 // |internal_format| and |type| are used if |mode| is |
72 // effectively a "TexSubImage" operation. | 83 // SingleFrameCopyTexture. Otherwise assumes |texture| has already |
| 84 // been allocated with the appropriate size and a compatible format, |
| 85 // internal format and type, and is effectively a "TexSubImage" |
| 86 // operation. |
73 static void CopyVideoFrameSingleTextureToGLTexture( | 87 static void CopyVideoFrameSingleTextureToGLTexture( |
74 gpu::gles2::GLES2Interface* gl, | 88 gpu::gles2::GLES2Interface* gl, |
75 VideoFrame* video_frame, | 89 VideoFrame* video_frame, |
| 90 SingleFrameCopyMode mode, |
76 unsigned int texture, | 91 unsigned int texture, |
| 92 unsigned int internal_format, |
| 93 unsigned int type, |
77 bool premultiply_alpha, | 94 bool premultiply_alpha, |
78 bool flip_y); | 95 bool flip_y); |
79 | 96 |
80 // Copy the contents of texture of |video_frame| to texture |texture| in | 97 // Copy the contents of texture of |video_frame| to texture |texture| in |
81 // context |destination_gl|. | 98 // context |destination_gl|. |
82 // |level|, |internal_format|, |type| specify target texture |texture|. | 99 // |level|, |internal_format|, |type| specify target texture |texture|. |
83 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. | 100 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. |
84 // |context_3d| has a GrContext that may be used during the copy. | 101 // |context_3d| has a GrContext that may be used during the copy. |
85 // Assumes |texture| has already been allocated with the appropriate | 102 // Assumes |texture| has already been allocated with the appropriate |
86 // size and a compatible format, internal format and type; this is | 103 // size and a compatible format, internal format and type; this is |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 171 |
155 // Used for unit test. | 172 // Used for unit test. |
156 SkISize last_image_dimensions_for_testing_; | 173 SkISize last_image_dimensions_for_testing_; |
157 | 174 |
158 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); | 175 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); |
159 }; | 176 }; |
160 | 177 |
161 } // namespace media | 178 } // namespace media |
162 | 179 |
163 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ | 180 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ |
OLD | NEW |