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 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
16 #include "media/base/media_export.h" | 16 #include "media/base/media_export.h" |
17 #include "media/base/timestamp_constants.h" | 17 #include "media/base/timestamp_constants.h" |
18 #include "media/base/video_frame.h" | 18 #include "media/base/video_frame.h" |
19 #include "media/base/video_rotation.h" | 19 #include "media/base/video_rotation.h" |
20 #include "media/filters/context_3d.h" | 20 #include "media/filters/context_3d.h" |
21 #include "third_party/skia/include/core/SkImage.h" | 21 #include "third_party/skia/include/core/SkImage.h" |
22 #include "third_party/skia/include/core/SkRefCnt.h" | 22 #include "third_party/skia/include/core/SkRefCnt.h" |
23 #include "third_party/skia/include/core/SkXfermode.h" | 23 #include "third_party/skia/include/core/SkXfermode.h" |
24 | 24 |
25 class SkCanvas; | 25 class SkCanvas; |
26 class SkImage; | |
27 | 26 |
28 namespace gfx { | 27 namespace gfx { |
29 class RectF; | 28 class RectF; |
30 } | 29 } |
31 | 30 |
32 namespace media { | 31 namespace media { |
33 class VideoImageGenerator; | 32 class VideoImageGenerator; |
34 | 33 |
35 // Handles rendering of VideoFrames to SkCanvases. | 34 // Handles rendering of VideoFrames to SkCanvases. |
36 class MEDIA_EXPORT SkCanvasVideoRenderer { | 35 class MEDIA_EXPORT SkCanvasVideoRenderer { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. | 70 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. |
72 static void CopyVideoFrameSingleTextureToGLTexture( | 71 static void CopyVideoFrameSingleTextureToGLTexture( |
73 gpu::gles2::GLES2Interface* gl, | 72 gpu::gles2::GLES2Interface* gl, |
74 VideoFrame* video_frame, | 73 VideoFrame* video_frame, |
75 unsigned int texture, | 74 unsigned int texture, |
76 unsigned int internal_format, | 75 unsigned int internal_format, |
77 unsigned int type, | 76 unsigned int type, |
78 bool premultiply_alpha, | 77 bool premultiply_alpha, |
79 bool flip_y); | 78 bool flip_y); |
80 | 79 |
| 80 // Convert if needed and call tex(Sub)Image2D or tex(Sub)Image3D. |
| 81 // |format|, |internal_format|, |type| specify target texture |texture|. |
| 82 // |xoffset|, |yoffset|, |zoffset| are used when functionID defines sub image |
| 83 // calls. |
| 84 // Returns false if there is no implementation for given parameters or if the |
| 85 // call fails. |
| 86 static bool TexImageImpl(const char* functionID, |
| 87 unsigned target, |
| 88 gpu::gles2::GLES2Interface* gl, |
| 89 VideoFrame* video_frame, |
| 90 int level, |
| 91 int internalformat, |
| 92 unsigned format, |
| 93 unsigned type, |
| 94 int xoffset, |
| 95 int yoffset, |
| 96 int zoffset, |
| 97 bool flipY, |
| 98 bool premultiplyAlpha); |
| 99 |
81 // In general, We hold the most recently painted frame to increase the | 100 // 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 | 101 // 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 | 102 // repeatedly. Call this function if you are sure the most recent frame will |
84 // never be painted again, so we can release the resource. | 103 // never be painted again, so we can release the resource. |
85 void ResetCache(); | 104 void ResetCache(); |
86 | 105 |
87 private: | 106 private: |
88 // Last image used to draw to the canvas. | 107 // Last image used to draw to the canvas. |
89 sk_sp<SkImage> last_image_; | 108 sk_sp<SkImage> last_image_; |
90 // Timestamp of the videoframe used to generate |last_image_|. | 109 // Timestamp of the videoframe used to generate |last_image_|. |
91 base::TimeDelta last_timestamp_ = media::kNoTimestamp(); | 110 base::TimeDelta last_timestamp_ = media::kNoTimestamp(); |
92 // If |last_image_| is not used for a while, it's deleted to save memory. | 111 // If |last_image_| is not used for a while, it's deleted to save memory. |
93 base::DelayTimer last_image_deleting_timer_; | 112 base::DelayTimer last_image_deleting_timer_; |
94 | 113 |
95 // Used for DCHECKs to ensure method calls executed in the correct thread. | 114 // Used for DCHECKs to ensure method calls executed in the correct thread. |
96 base::ThreadChecker thread_checker_; | 115 base::ThreadChecker thread_checker_; |
97 | 116 |
98 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); | 117 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); |
99 }; | 118 }; |
100 | 119 |
101 } // namespace media | 120 } // namespace media |
102 | 121 |
103 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ | 122 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ |
OLD | NEW |