Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: media/renderers/skcanvas_video_renderer.h

Issue 2121043002: 16 bpp video stream capture, render and WebGL usage - Realsense R200 & SR300 support. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 bool CopyVideoFrameTexturesToGLTexture( 85 bool CopyVideoFrameTexturesToGLTexture(
87 const Context3D& context_3d, 86 const Context3D& context_3d,
88 gpu::gles2::GLES2Interface* destination_gl, 87 gpu::gles2::GLES2Interface* destination_gl,
89 const scoped_refptr<VideoFrame>& video_frame, 88 const scoped_refptr<VideoFrame>& video_frame,
90 unsigned int texture, 89 unsigned int texture,
91 unsigned int internal_format, 90 unsigned int internal_format,
92 unsigned int type, 91 unsigned int type,
93 bool premultiply_alpha, 92 bool premultiply_alpha,
94 bool flip_y); 93 bool flip_y);
95 94
95 // Method handles reinterpreting two components RG8 as 16 bit value for Y16
96 // format and optimizing upload-to-texture for some video frame and texture
97 // formats. If needed, there is a conversion followed by a tex(Sub)Image2D or
98 // tex(Sub)Image3D call.
99 // |format|, |internal_format|, |type| specify target texture |texture|.
100 // |xoffset|, |yoffset|, |zoffset| are used when functionID defines sub image
101 // calls.
102 // Returns false if there is no implementation for given parameters or if the
103 // call fails.
104 static bool TexImageImpl(const char* functionID,
105 unsigned target,
106 gpu::gles2::GLES2Interface* gl,
107 VideoFrame* video_frame,
108 int level,
109 int internalformat,
110 unsigned format,
111 unsigned type,
112 int xoffset,
113 int yoffset,
114 int zoffset,
115 bool flipY,
116 bool premultiplyAlpha);
117
96 // In general, We hold the most recently painted frame to increase the 118 // In general, We hold the most recently painted frame to increase the
97 // performance for the case that the same frame needs to be painted 119 // performance for the case that the same frame needs to be painted
98 // repeatedly. Call this function if you are sure the most recent frame will 120 // repeatedly. Call this function if you are sure the most recent frame will
99 // never be painted again, so we can release the resource. 121 // never be painted again, so we can release the resource.
100 void ResetCache(); 122 void ResetCache();
101 123
102 void CorrectLastImageDimensions(const SkIRect& visible_rect); 124 void CorrectLastImageDimensions(const SkIRect& visible_rect);
103 125
104 // Used for unit test. 126 // Used for unit test.
105 SkISize LastImageDimensionsForTesting(); 127 SkISize LastImageDimensionsForTesting();
106 128
107 private: 129 private:
108 // Update the cache holding the most-recently-painted frame. Returns false 130 // Update the cache holding the most-recently-painted frame. Returns false
109 // if the image couldn't be updated. 131 // if the image couldn't be updated.
110 bool UpdateLastImage(const scoped_refptr<VideoFrame>& video_frame, 132 bool UpdateLastImage(const scoped_refptr<VideoFrame>& video_frame,
111 const Context3D& context_3d); 133 const Context3D& context_3d);
112 134
135 // Reinterpret the content of RG8 texture as R16 (normalized value) to float
136 // intermediate texture and then copy to texture. All the available RGB color
137 // components in the texture get the same value.
138 // Reinterpretting texture happens on canvas gl (context_3d) to enable caching
139 // resources for following calls. Target |texture| should live on |target_gl|
140 // after the call.
141 void CopyRG8ToTexture(const Context3D& context_3d,
142 gpu::gles2::GLES2Interface* target_gl,
143 VideoFrame* video_frame,
144 unsigned texture,
145 unsigned internal_format,
146 unsigned type,
147 bool flip_y);
148
149 // Helper method used by CopyRG8ToTexture. Target used for both
150 // |source_texture| and |target_texture| is GL_TEXTURE_2D.
151 void DoCopyRG8ToTexture(const Context3D& context_3d,
152 unsigned source_texture,
153 unsigned target_texture,
154 unsigned format,
155 unsigned internal_format,
156 unsigned type,
157 unsigned width,
158 unsigned height,
159 bool flip_y);
160
113 // Last image used to draw to the canvas. 161 // Last image used to draw to the canvas.
114 sk_sp<SkImage> last_image_; 162 sk_sp<SkImage> last_image_;
115 // Timestamp of the videoframe used to generate |last_image_|. 163 // Timestamp of the videoframe used to generate |last_image_|.
116 base::TimeDelta last_timestamp_ = media::kNoTimestamp; 164 base::TimeDelta last_timestamp_ = media::kNoTimestamp;
117 // If |last_image_| is not used for a while, it's deleted to save memory. 165 // If |last_image_| is not used for a while, it's deleted to save memory.
118 base::DelayTimer last_image_deleting_timer_; 166 base::DelayTimer last_image_deleting_timer_;
119 167
120 // Used for DCHECKs to ensure method calls executed in the correct thread. 168 // Used for DCHECKs to ensure method calls executed in the correct thread.
121 base::ThreadChecker thread_checker_; 169 base::ThreadChecker thread_checker_;
170 // Resources rg8_to_texture_* are used for RG8 to float texture GPU
171 // conversion.
172 unsigned rg8_to_texture_program_ = 0;
173 unsigned rg8_to_texture_vertices_buffer_ = 0;
174 // Used for cached GL resources (e.g. rg8_to_texture_program) lifecycle
175 // management.
176 unsigned cached_gl_resources_gr_context_id_ = 0;
122 177
123 // Used for unit test. 178 // Used for unit test.
124 SkISize last_image_dimensions_for_testing_; 179 SkISize last_image_dimensions_for_testing_;
125 180
126 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); 181 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer);
127 }; 182 };
128 183
129 } // namespace media 184 } // namespace media
130 185
131 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ 186 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_
OLDNEW
« no previous file with comments | « media/renderers/mock_gpu_video_accelerator_factories.h ('k') | media/renderers/skcanvas_video_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698