OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/video_layer_impl.h" | 7 #include "cc/video_layer_impl.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "cc/io_surface_draw_quad.h" | 10 #include "cc/io_surface_draw_quad.h" |
11 #include "cc/layer_tree_host_impl.h" | 11 #include "cc/layer_tree_host_impl.h" |
| 12 #include "cc/proxy.h" |
12 #include "cc/quad_sink.h" | 13 #include "cc/quad_sink.h" |
13 #include "cc/resource_provider.h" | 14 #include "cc/resource_provider.h" |
14 #include "cc/stream_video_draw_quad.h" | 15 #include "cc/stream_video_draw_quad.h" |
15 #include "cc/texture_draw_quad.h" | 16 #include "cc/texture_draw_quad.h" |
16 #include "cc/yuv_video_draw_quad.h" | 17 #include "cc/yuv_video_draw_quad.h" |
17 #include "media/filters/skcanvas_video_renderer.h" | 18 #include "media/filters/skcanvas_video_renderer.h" |
18 #include "third_party/khronos/GLES2/gl2.h" | 19 #include "third_party/khronos/GLES2/gl2.h" |
19 #include "third_party/khronos/GLES2/gl2ext.h" | 20 #include "third_party/khronos/GLES2/gl2ext.h" |
20 | 21 |
21 namespace cc { | 22 namespace cc { |
(...skipping 13 matching lines...) Expand all Loading... |
35 m_streamTextureMatrix = WebKit::WebTransformationMatrix( | 36 m_streamTextureMatrix = WebKit::WebTransformationMatrix( |
36 1, 0, 0, 0, | 37 1, 0, 0, 0, |
37 0, -1, 0, 0, | 38 0, -1, 0, 0, |
38 0, 0, 1, 0, | 39 0, 0, 1, 0, |
39 0, 1, 0, 1); | 40 0, 1, 0, 1); |
40 | 41 |
41 // This only happens during a commit on the compositor thread while the main | 42 // This only happens during a commit on the compositor thread while the main |
42 // thread is blocked. That makes this a thread-safe call to set the video | 43 // thread is blocked. That makes this a thread-safe call to set the video |
43 // frame provider client that does not require a lock. The same is true of | 44 // frame provider client that does not require a lock. The same is true of |
44 // the call in the destructor. | 45 // the call in the destructor. |
| 46 DCHECK(Proxy::isMainThreadBlocked()); |
45 m_provider->setVideoFrameProviderClient(this); | 47 m_provider->setVideoFrameProviderClient(this); |
46 } | 48 } |
47 | 49 |
48 VideoLayerImpl::~VideoLayerImpl() | 50 VideoLayerImpl::~VideoLayerImpl() |
49 { | 51 { |
50 // See comment in constructor for why this doesn't need a lock. | 52 // See comment in constructor for why this doesn't need a lock. |
| 53 DCHECK(Proxy::isMainThreadBlocked()); |
51 if (m_provider) { | 54 if (m_provider) { |
52 m_provider->setVideoFrameProviderClient(0); | 55 m_provider->setVideoFrameProviderClient(0); |
53 m_provider = 0; | 56 m_provider = 0; |
54 } | 57 } |
55 freePlaneData(layerTreeHostImpl()->resourceProvider()); | 58 freePlaneData(layerTreeHostImpl()->resourceProvider()); |
56 | 59 |
57 #ifndef NDEBUG | 60 #ifndef NDEBUG |
58 for (size_t i = 0; i < media::VideoFrame::kMaxPlanes; ++i) | 61 for (size_t i = 0; i < media::VideoFrame::kMaxPlanes; ++i) |
59 DCHECK(!m_framePlanes[i].resourceId); | 62 DCHECK(!m_framePlanes[i].resourceId); |
60 DCHECK(!m_externalTextureResource); | 63 DCHECK(!m_externalTextureResource); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 break; | 112 break; |
110 case media::VideoFrame::NATIVE_TEXTURE: | 113 case media::VideoFrame::NATIVE_TEXTURE: |
111 return 0; | 114 return 0; |
112 } | 115 } |
113 NOTREACHED(); | 116 NOTREACHED(); |
114 return 0; | 117 return 0; |
115 } | 118 } |
116 | 119 |
117 void VideoLayerImpl::willDraw(ResourceProvider* resourceProvider) | 120 void VideoLayerImpl::willDraw(ResourceProvider* resourceProvider) |
118 { | 121 { |
| 122 DCHECK(Proxy::isImplThread()); |
119 LayerImpl::willDraw(resourceProvider); | 123 LayerImpl::willDraw(resourceProvider); |
120 | 124 |
121 // Explicitly acquire and release the provider mutex so it can be held from | 125 // Explicitly acquire and release the provider mutex so it can be held from |
122 // willDraw to didDraw. Since the compositor thread is in the middle of | 126 // willDraw to didDraw. Since the compositor thread is in the middle of |
123 // drawing, the layer will not be destroyed before didDraw is called. | 127 // drawing, the layer will not be destroyed before didDraw is called. |
124 // Therefore, the only thing that will prevent this lock from being released | 128 // Therefore, the only thing that will prevent this lock from being released |
125 // is the GPU process locking it. As the GPU process can't cause the | 129 // is the GPU process locking it. As the GPU process can't cause the |
126 // destruction of the provider (calling stopUsingProvider), holding this | 130 // destruction of the provider (calling stopUsingProvider), holding this |
127 // lock should not cause a deadlock. | 131 // lock should not cause a deadlock. |
128 m_providerLock.Acquire(); | 132 m_providerLock.Acquire(); |
129 | 133 |
130 willDrawInternal(resourceProvider); | 134 willDrawInternal(resourceProvider); |
131 freeUnusedPlaneData(resourceProvider); | 135 freeUnusedPlaneData(resourceProvider); |
132 | 136 |
133 if (!m_frame) | 137 if (!m_frame) |
134 m_providerLock.Release(); | 138 m_providerLock.Release(); |
135 } | 139 } |
136 | 140 |
137 void VideoLayerImpl::willDrawInternal(ResourceProvider* resourceProvider) | 141 void VideoLayerImpl::willDrawInternal(ResourceProvider* resourceProvider) |
138 { | 142 { |
| 143 DCHECK(Proxy::isImplThread()); |
139 DCHECK(!m_externalTextureResource); | 144 DCHECK(!m_externalTextureResource); |
140 | 145 |
141 if (!m_provider) { | 146 if (!m_provider) { |
142 m_frame = 0; | 147 m_frame = 0; |
143 return; | 148 return; |
144 } | 149 } |
145 | 150 |
146 m_webFrame = m_provider->getCurrentFrame(); | 151 m_webFrame = m_provider->getCurrentFrame(); |
147 m_frame = m_unwrapper.Run(m_webFrame); | 152 m_frame = m_unwrapper.Run(m_webFrame); |
148 | 153 |
(...skipping 30 matching lines...) Expand all Loading... |
179 m_frame = 0; | 184 m_frame = 0; |
180 return; | 185 return; |
181 } | 186 } |
182 | 187 |
183 if (m_format == GL_TEXTURE_2D) | 188 if (m_format == GL_TEXTURE_2D) |
184 m_externalTextureResource = resourceProvider->createResourceFromExternal
Texture(m_frame->texture_id()); | 189 m_externalTextureResource = resourceProvider->createResourceFromExternal
Texture(m_frame->texture_id()); |
185 } | 190 } |
186 | 191 |
187 void VideoLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuad
sData) | 192 void VideoLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuad
sData) |
188 { | 193 { |
| 194 DCHECK(Proxy::isImplThread()); |
| 195 |
189 if (!m_frame) | 196 if (!m_frame) |
190 return; | 197 return; |
191 | 198 |
192 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ
uadState()); | 199 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ
uadState()); |
193 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); | 200 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); |
194 | 201 |
195 // FIXME: When we pass quads out of process, we need to double-buffer, or | 202 // FIXME: When we pass quads out of process, we need to double-buffer, or |
196 // otherwise synchonize use of all textures in the quad. | 203 // otherwise synchonize use of all textures in the quad. |
197 | 204 |
198 gfx::Rect quadRect(gfx::Point(), contentBounds()); | 205 gfx::Rect quadRect(gfx::Point(), contentBounds()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 break; | 246 break; |
240 } | 247 } |
241 default: | 248 default: |
242 NOTREACHED(); // Someone updated convertVFCFormatToGLenum above but upd
ate this! | 249 NOTREACHED(); // Someone updated convertVFCFormatToGLenum above but upd
ate this! |
243 break; | 250 break; |
244 } | 251 } |
245 } | 252 } |
246 | 253 |
247 void VideoLayerImpl::didDraw(ResourceProvider* resourceProvider) | 254 void VideoLayerImpl::didDraw(ResourceProvider* resourceProvider) |
248 { | 255 { |
| 256 DCHECK(Proxy::isImplThread()); |
249 LayerImpl::didDraw(resourceProvider); | 257 LayerImpl::didDraw(resourceProvider); |
250 | 258 |
251 if (!m_frame) | 259 if (!m_frame) |
252 return; | 260 return; |
253 | 261 |
254 if (m_format == GL_TEXTURE_2D) { | 262 if (m_format == GL_TEXTURE_2D) { |
255 DCHECK(m_externalTextureResource); | 263 DCHECK(m_externalTextureResource); |
256 // FIXME: the following assert will not be true when sending resources t
o a | 264 // FIXME: the following assert will not be true when sending resources t
o a |
257 // parent compositor. We will probably need to hold on to m_frame for | 265 // parent compositor. We will probably need to hold on to m_frame for |
258 // longer, and have several "current frames" in the pipeline. | 266 // longer, and have several "current frames" in the pipeline. |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 str->append("video layer\n"); | 424 str->append("video layer\n"); |
417 LayerImpl::dumpLayerProperties(str, indent); | 425 LayerImpl::dumpLayerProperties(str, indent); |
418 } | 426 } |
419 | 427 |
420 const char* VideoLayerImpl::layerTypeAsString() const | 428 const char* VideoLayerImpl::layerTypeAsString() const |
421 { | 429 { |
422 return "VideoLayer"; | 430 return "VideoLayer"; |
423 } | 431 } |
424 | 432 |
425 } | 433 } |
OLD | NEW |