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

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

Issue 1315323006: webgl: optimize webgl.texSubImage2D(video) path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: don't use c++11 initialize-list Created 5 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_BLINK_SKCANVAS_VIDEO_RENDERER_H_ 5 #ifndef MEDIA_BLINK_SKCANVAS_VIDEO_RENDERER_H_
6 #define MEDIA_BLINK_SKCANVAS_VIDEO_RENDERER_H_ 6 #define MEDIA_BLINK_SKCANVAS_VIDEO_RENDERER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // Convert the contents of |video_frame| to raw RGB pixels. |rgb_pixels| 57 // Convert the contents of |video_frame| to raw RGB pixels. |rgb_pixels|
58 // should point into a buffer large enough to hold as many 32 bit RGBA pixels 58 // should point into a buffer large enough to hold as many 32 bit RGBA pixels
59 // as are in the visible_rect() area of the frame. 59 // as are in the visible_rect() area of the frame.
60 static void ConvertVideoFrameToRGBPixels(const media::VideoFrame* video_frame, 60 static void ConvertVideoFrameToRGBPixels(const media::VideoFrame* video_frame,
61 void* rgb_pixels, 61 void* rgb_pixels,
62 size_t row_bytes); 62 size_t row_bytes);
63 63
64 // Copy the contents of texture of |video_frame| to texture |texture|. 64 // Copy the contents of texture of |video_frame| to texture |texture|.
65 // |level|, |internal_format|, |type| specify target texture |texture|. 65 // |level|, |internal_format|, |type| specify target texture |texture|.
66 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. 66 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE.
67 struct CopyFrameSingleTextureParams {
68 enum CopyType { FullCopy, SubCopy };
69 CopyFrameSingleTextureParams() = delete;
70 CopyFrameSingleTextureParams(CopyType copy_type,
71 unsigned target,
72 unsigned texture,
73 unsigned internal_format,
74 unsigned type,
75 int level,
76 int xoffset,
77 int yoffset,
78 bool premultiply_alpha,
79 bool flip_y)
80 : copy_type(copy_type),
81 target(target),
82 texture(texture),
83 internal_format(internal_format),
84 type(type),
85 level(level),
86 xoffset(xoffset),
87 yoffset(yoffset),
88 premultiply_alpha(premultiply_alpha),
89 flip_y(flip_y) {}
90 CopyType copy_type;
91 unsigned int target;
92 unsigned int texture;
93 unsigned int internal_format;
94 unsigned int type;
95 int level;
96 int xoffset;
97 int yoffset;
98 bool premultiply_alpha;
99 bool flip_y;
100 };
67 static void CopyVideoFrameSingleTextureToGLTexture( 101 static void CopyVideoFrameSingleTextureToGLTexture(
68 gpu::gles2::GLES2Interface* gl, 102 gpu::gles2::GLES2Interface* gl,
69 VideoFrame* video_frame, 103 VideoFrame* video_frame,
70 unsigned int texture, 104 const CopyFrameSingleTextureParams& params);
71 unsigned int internal_format,
72 unsigned int type,
73 bool premultiply_alpha,
74 bool flip_y);
75 105
76 private: 106 private:
77 void ResetCache(); 107 void ResetCache();
78 108
79 // Last image used to draw to the canvas. 109 // Last image used to draw to the canvas.
80 skia::RefPtr<SkImage> last_image_; 110 skia::RefPtr<SkImage> last_image_;
81 // Timestamp of the videoframe used to generate |last_image_|. 111 // Timestamp of the videoframe used to generate |last_image_|.
82 base::TimeDelta last_timestamp_ = media::kNoTimestamp(); 112 base::TimeDelta last_timestamp_ = media::kNoTimestamp();
83 // If |last_image_| is not used for a while, it's deleted to save memory. 113 // If |last_image_| is not used for a while, it's deleted to save memory.
84 base::DelayTimer last_image_deleting_timer_; 114 base::DelayTimer last_image_deleting_timer_;
85 115
86 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); 116 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer);
87 }; 117 };
88 118
89 } // namespace media 119 } // namespace media
90 120
91 #endif // MEDIA_BLINK_SKCANVAS_VIDEO_RENDERER_H_ 121 #endif // MEDIA_BLINK_SKCANVAS_VIDEO_RENDERER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698