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

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: scoping Y8 out. 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 private: 124 private:
103 // Update the cache holding the most-recently-painted frame. Returns false 125 // Update the cache holding the most-recently-painted frame. Returns false
104 // if the image couldn't be updated. 126 // if the image couldn't be updated.
105 bool UpdateLastImage(const scoped_refptr<VideoFrame>& video_frame, 127 bool UpdateLastImage(const scoped_refptr<VideoFrame>& video_frame,
106 const Context3D& context_3d); 128 const Context3D& context_3d);
107 129
130 // Reinterpret the content of RG8 texture as R16 (normalized value) to float
131 // intermediate texture and then copy to texture. All the available RGB color
132 // components in the texture get the same value.
133 // Reinterpretting texture happens on canvas gl (context_3d) to enable caching
134 // resources for following calls. Target |texture| should live on |target_gl|
135 // after the call.
136 void CopyRG8ToTexture(const Context3D& context_3d,
137 gpu::gles2::GLES2Interface* target_gl,
138 VideoFrame* video_frame,
139 unsigned texture,
140 unsigned internal_format,
141 unsigned type,
142 bool flip_y);
143
144 // Helper method used by CopyRG8ToTexture. Target used for both
145 // |source_texture| and |target_texture| is GL_TEXTURE_2D.
146 void DoCopyRG8ToTexture(const Context3D& context_3d,
147 unsigned source_texture,
148 unsigned target_texture,
149 unsigned format,
150 unsigned internal_format,
151 unsigned type,
152 unsigned width,
153 unsigned height,
154 bool flip_y);
155
108 // Last image used to draw to the canvas. 156 // Last image used to draw to the canvas.
109 sk_sp<SkImage> last_image_; 157 sk_sp<SkImage> last_image_;
110 // Timestamp of the videoframe used to generate |last_image_|. 158 // Timestamp of the videoframe used to generate |last_image_|.
111 base::TimeDelta last_timestamp_ = media::kNoTimestamp; 159 base::TimeDelta last_timestamp_ = media::kNoTimestamp;
112 // If |last_image_| is not used for a while, it's deleted to save memory. 160 // If |last_image_| is not used for a while, it's deleted to save memory.
113 base::DelayTimer last_image_deleting_timer_; 161 base::DelayTimer last_image_deleting_timer_;
114 162
115 // Used for DCHECKs to ensure method calls executed in the correct thread. 163 // Used for DCHECKs to ensure method calls executed in the correct thread.
116 base::ThreadChecker thread_checker_; 164 base::ThreadChecker thread_checker_;
165 // Resources rg8_to_texture_* are used for RG8 to float texture GPU
166 // conversion.
167 unsigned rg8_to_texture_program_ = 0;
168 unsigned rg8_to_texture_vertices_buffer_ = 0;
169 // Used for cached GL resources (e.g. rg8_to_texture_program) lifecycle
170 // management.
171 unsigned cached_gl_resources_gr_context_id_ = 0;
117 172
118 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); 173 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer);
119 }; 174 };
120 175
121 } // namespace media 176 } // namespace media
122 177
123 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ 178 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698