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

Side by Side Diff: cc/video_layer_impl.cc

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

Powered by Google App Engine
This is Rietveld 408576698