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

Unified 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: Tests: cc, skcanvas_video_renderer, wrtcrecorder... Fake capture supports Y16. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: media/renderers/skcanvas_video_renderer.h
diff --git a/media/renderers/skcanvas_video_renderer.h b/media/renderers/skcanvas_video_renderer.h
index ff2a9195db5d7dc22fe4b44526642c27f735d119..cbb157b327521ad39ff6294c4bb86ec25680306e 100644
--- a/media/renderers/skcanvas_video_renderer.h
+++ b/media/renderers/skcanvas_video_renderer.h
@@ -23,7 +23,6 @@
#include "third_party/skia/include/core/SkXfermode.h"
class SkCanvas;
-class SkImage;
namespace gfx {
class RectF;
@@ -94,6 +93,29 @@ class MEDIA_EXPORT SkCanvasVideoRenderer {
bool premultiply_alpha,
bool flip_y);
+ // Method handles reinterpreting two components RG8 as 16 bit value for Y16
+ // format and optimizing upload-to-texture for some video frame and texture
+ // formats. If needed, there is a conversion followed by a tex(Sub)Image2D or
+ // tex(Sub)Image3D call.
+ // |format|, |internal_format|, |type| specify target texture |texture|.
+ // |xoffset|, |yoffset|, |zoffset| are used when functionID defines sub image
+ // calls.
+ // Returns false if there is no implementation for given parameters or if the
+ // call fails.
+ static bool TexImageImpl(const char* functionID,
+ unsigned target,
+ gpu::gles2::GLES2Interface* gl,
+ VideoFrame* video_frame,
+ int level,
+ int internalformat,
+ unsigned format,
+ unsigned type,
+ int xoffset,
+ int yoffset,
+ int zoffset,
+ bool flipY,
+ bool premultiplyAlpha);
+
// In general, We hold the most recently painted frame to increase the
// performance for the case that the same frame needs to be painted
// repeatedly. Call this function if you are sure the most recent frame will
@@ -106,6 +128,31 @@ class MEDIA_EXPORT SkCanvasVideoRenderer {
bool UpdateLastImage(const scoped_refptr<VideoFrame>& video_frame,
const Context3D& context_3d);
+ // Reinterpret the content of RG8 texture as R16 (normalized value) and then
+ // copy to single red component (both float and integer formats are supported)
+ // texture.
+ // Reinterpretting texture happens on canvas gl (context_3d) to enable caching
+ // resources for following calls. Target |texture| should live on |target_gl|
+ // after the call.
+ void CopyRG8ToRedTextureData(const Context3D& context_3d,
+ gpu::gles2::GLES2Interface* target_gl,
+ VideoFrame* video_frame,
+ unsigned texture,
+ unsigned internal_format,
+ unsigned type,
+ bool flip_y);
+
+ // Helper method used by CopyRG8ToRedTextureData. Target used for both
+ // |source_texture| and |target_texture| is GL_TEXTURE_2D.
+ void DoCopyRG8ToRedTextureData(const Context3D& context_3d,
+ unsigned source_texture,
+ unsigned target_texture,
+ unsigned internal_format,
+ unsigned type,
+ unsigned width,
+ unsigned height,
+ bool flip_y);
+
// Last image used to draw to the canvas.
sk_sp<SkImage> last_image_;
// Timestamp of the videoframe used to generate |last_image_|.
@@ -115,6 +162,11 @@ class MEDIA_EXPORT SkCanvasVideoRenderer {
// Used for DCHECKs to ensure method calls executed in the correct thread.
base::ThreadChecker thread_checker_;
+ // Resources rg8_to_red_* are used for GPU conversion of RG8 to R32F textures.
+ unsigned rg8_to_red_program_ = 0;
+ unsigned rg8_to_red_vertices_buffer_ = 0;
+ // Used for tracking cached GL resources (e.g. rg8_to_red_program) lifecycle.
+ unsigned cached_gl_resources_gr_context_id_ = 0;
DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer);
};

Powered by Google App Engine
This is Rietveld 408576698