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

Side by Side Diff: content/common/gpu/media/avda_codec_image.h

Issue 1559203003: Add GLStreamTextureImage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added enum, removed count parameter. Created 4 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ 5 #ifndef CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_
6 #define CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ 6 #define CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "content/common/gpu/media/avda_shared_state.h" 11 #include "content/common/gpu/media/avda_shared_state.h"
12 #include "ui/gl/gl_image.h" 12 #include "ui/gl/gl_image.h"
13 13
14 namespace ui {
15 class ScopedMakeCurrent;
16 }
17
14 namespace content { 18 namespace content {
15 19
16 // GLImage that renders MediaCodec buffers to a SurfaceTexture or SurfaceView as 20 // GLImage that renders MediaCodec buffers to a SurfaceTexture or SurfaceView as
17 // needed in order to draw them. 21 // needed in order to draw them.
18 class AVDACodecImage : public gl::GLImage { 22 class AVDACodecImage : public gl::GLImage {
19 public: 23 public:
20 AVDACodecImage(const scoped_refptr<AVDASharedState>&, 24 AVDACodecImage(const scoped_refptr<AVDASharedState>&,
21 media::VideoCodecBridge* codec, 25 media::VideoCodecBridge* codec,
22 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder, 26 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder,
23 const scoped_refptr<gfx::SurfaceTexture>& surface_texture); 27 const scoped_refptr<gfx::SurfaceTexture>& surface_texture);
(...skipping 13 matching lines...) Expand all
37 const gfx::Point& offset, 41 const gfx::Point& offset,
38 const gfx::Rect& rect) override; 42 const gfx::Rect& rect) override;
39 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, 43 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
40 int z_order, 44 int z_order,
41 gfx::OverlayTransform transform, 45 gfx::OverlayTransform transform,
42 const gfx::Rect& bounds_rect, 46 const gfx::Rect& bounds_rect,
43 const gfx::RectF& crop_rect) override; 47 const gfx::RectF& crop_rect) override;
44 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, 48 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
45 uint64_t process_tracing_id, 49 uint64_t process_tracing_id,
46 const std::string& dump_name) override; 50 const std::string& dump_name) override;
51 bool GetCustomMatrix(int matrixId, float xform[16]) override;
47 52
48 public: 53 public:
49 // Decoded buffer index that has the image for us to display. 54 // Decoded buffer index that has the image for us to display.
50 void SetMediaCodecBufferIndex(int buffer_index); 55 void SetMediaCodecBufferIndex(int buffer_index);
51 56
52 // Return the codec buffer that we will return to the codec, or 57 // Return the codec buffer that we will return to the codec, or
53 // <0 if there is no such buffer. 58 // <0 if there is no such buffer.
54 int GetMediaCodecBufferIndex() const; 59 int GetMediaCodecBufferIndex() const;
55 60
56 // Set the size of the current image. 61 // Set the size of the current image.
57 void SetSize(const gfx::Size& size); 62 void SetSize(const gfx::Size& size);
58 63
59 void SetMediaCodec(media::MediaCodecBridge* codec); 64 void SetMediaCodec(media::MediaCodecBridge* codec);
60 65
61 void SetTexture(gpu::gles2::Texture* texture); 66 void SetTexture(gpu::gles2::Texture* texture);
62 67
63 private: 68 private:
64 enum { kInvalidCodecBufferIndex = -1 }; 69 enum { kInvalidCodecBufferIndex = -1 };
65 70
66 // Make sure that the surface texture's front buffer is current. 71 // Make sure that the surface texture's front buffer is current. This will
67 void UpdateSurfaceTexture(); 72 // save / restore the current context. It will optionally restore the texture
73 // bindings in the surface texture's context, based on |mode|. This is
74 // intended as a hint if we don't need to change contexts. If we do need to
75 // change contexts, then we'll always preserve the texture bindings in the
76 // both contexts. In other words, the caller is telling us whether it's
77 // okay to change the binding in the current context.
78 enum RestoreBindingsMode { kDontRestoreBindings, kDoRestoreBindings };
79 void UpdateSurfaceTexture(RestoreBindingsMode mode);
68 80
69 // Attach the surface texture to our GL context, with a texture that we 81 // Attach the surface texture to our GL context to whatever texture is bound
70 // create for it. 82 // on the active unit.
71 void AttachSurfaceTextureToContext(); 83 void AttachSurfaceTextureToContext();
72 84
73 // Install the current texture matrix into the shader. 85 // Make shared_state_->context() current if it isn't already.
74 void InstallTextureMatrix(); 86 scoped_ptr<ui::ScopedMakeCurrent> MakeCurrentIfNeeded();
87
88 // Return whether or not the current context is in the same share group as
89 // |surface_texture_|'s client texture.
90 // TODO(liberato): is this needed?
91 bool IsCorrectShareGroup() const;
92
93 // Return whether there is a codec buffer that we haven't rendered yet. Will
94 // return false also if there's no codec or we otherwise can't update.
95 bool IsCodecBufferOutstanding() const;
75 96
76 // Shared state between the AVDA and all AVDACodecImages. 97 // Shared state between the AVDA and all AVDACodecImages.
77 scoped_refptr<AVDASharedState> shared_state_; 98 scoped_refptr<AVDASharedState> shared_state_;
78 99
79 // The MediaCodec buffer index that we should render. Only valid if not equal 100 // The MediaCodec buffer index that we should render. Only valid if not equal
80 // to |kInvalidCodecBufferIndex|. 101 // to |kInvalidCodecBufferIndex|.
81 int codec_buffer_index_; 102 int codec_buffer_index_;
82 103
83 // Our image size. 104 // Our image size.
84 gfx::Size size_; 105 gfx::Size size_;
85 106
86 // May be null. 107 // May be null.
87 media::MediaCodecBridge* media_codec_; 108 media::MediaCodecBridge* media_codec_;
88 109
89 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder_; 110 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder_;
90 111
91 // The SurfaceTexture to render to. This is null when rendering to a 112 // The SurfaceTexture to render to. This is null when rendering to a
92 // SurfaceView. 113 // SurfaceView.
93 const scoped_refptr<gfx::SurfaceTexture> surface_texture_; 114 const scoped_refptr<gfx::SurfaceTexture> surface_texture_;
94 115
95 // Should we detach |surface_texture_| from its GL context when we are 116 // Should we detach |surface_texture_| from its GL context when we are
96 // deleted? This happens when it's using our Texture's texture handle. 117 // deleted? This happens when it's using our Texture's texture handle.
97 bool detach_surface_texture_on_destruction_; 118 bool detach_surface_texture_on_destruction_;
98 119
99 // The texture that we're attached to. 120 // The texture that we're attached to.
100 gpu::gles2::Texture* texture_; 121 gpu::gles2::Texture* texture_;
101 122
102 // Have we cached |texmatrix_uniform_location_| yet?
103 bool need_shader_info_;
104
105 // Uniform ID of the texture matrix in the shader.
106 GLint texmatrix_uniform_location_;
107
108 // Texture matrix of the front buffer of the surface texture. 123 // Texture matrix of the front buffer of the surface texture.
109 float gl_matrix_[16]; 124 float gl_matrix_[16];
110 125
111 DISALLOW_COPY_AND_ASSIGN(AVDACodecImage); 126 DISALLOW_COPY_AND_ASSIGN(AVDACodecImage);
112 }; 127 };
113 128
114 } // namespace content 129 } // namespace content
115 130
116 #endif // CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ 131 #endif // CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698