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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. | 71 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. |
72 static void CopyVideoFrameSingleTextureToGLTexture( | 72 static void CopyVideoFrameSingleTextureToGLTexture( |
73 gpu::gles2::GLES2Interface* gl, | 73 gpu::gles2::GLES2Interface* gl, |
74 VideoFrame* video_frame, | 74 VideoFrame* video_frame, |
75 unsigned int texture, | 75 unsigned int texture, |
76 unsigned int internal_format, | 76 unsigned int internal_format, |
77 unsigned int type, | 77 unsigned int type, |
78 bool premultiply_alpha, | 78 bool premultiply_alpha, |
79 bool flip_y); | 79 bool flip_y); |
80 | 80 |
| 81 // Copy the contents of texture of |video_frame| to texture |texture| in |
| 82 // context |destination_gl|. |
| 83 // |level|, |internal_format|, |type| specify target texture |texture|. |
| 84 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. |
| 85 // |context_3d| has a GrContext that may be used during the copy. |
| 86 // Returns true on success. |
| 87 bool CopyVideoFrameTexturesToGLTexture( |
| 88 const Context3D& context_3d, |
| 89 gpu::gles2::GLES2Interface* destination_gl, |
| 90 const scoped_refptr<VideoFrame>& video_frame, |
| 91 unsigned int texture, |
| 92 unsigned int internal_format, |
| 93 unsigned int type, |
| 94 bool premultiply_alpha, |
| 95 bool flip_y); |
| 96 |
81 // In general, We hold the most recently painted frame to increase the | 97 // In general, We hold the most recently painted frame to increase the |
82 // performance for the case that the same frame needs to be painted | 98 // performance for the case that the same frame needs to be painted |
83 // repeatedly. Call this function if you are sure the most recent frame will | 99 // repeatedly. Call this function if you are sure the most recent frame will |
84 // never be painted again, so we can release the resource. | 100 // never be painted again, so we can release the resource. |
85 void ResetCache(); | 101 void ResetCache(); |
86 | 102 |
87 private: | 103 private: |
| 104 // Update the cache holding the most-recently-painted frame. |
| 105 void UpdateLastImage(const scoped_refptr<VideoFrame>& video_frame, |
| 106 const Context3D& context_3d); |
| 107 |
88 // Last image used to draw to the canvas. | 108 // Last image used to draw to the canvas. |
89 sk_sp<SkImage> last_image_; | 109 sk_sp<SkImage> last_image_; |
90 // Timestamp of the videoframe used to generate |last_image_|. | 110 // Timestamp of the videoframe used to generate |last_image_|. |
91 base::TimeDelta last_timestamp_ = media::kNoTimestamp(); | 111 base::TimeDelta last_timestamp_ = media::kNoTimestamp(); |
92 // If |last_image_| is not used for a while, it's deleted to save memory. | 112 // If |last_image_| is not used for a while, it's deleted to save memory. |
93 base::DelayTimer last_image_deleting_timer_; | 113 base::DelayTimer last_image_deleting_timer_; |
94 | 114 |
95 // Used for DCHECKs to ensure method calls executed in the correct thread. | 115 // Used for DCHECKs to ensure method calls executed in the correct thread. |
96 base::ThreadChecker thread_checker_; | 116 base::ThreadChecker thread_checker_; |
97 | 117 |
98 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); | 118 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); |
99 }; | 119 }; |
100 | 120 |
101 } // namespace media | 121 } // namespace media |
102 | 122 |
103 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ | 123 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ |
OLD | NEW |