Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 EglBase.Context sharedContext, RendererCommon.RendererEvents rendererEvent s) { | 138 EglBase.Context sharedContext, RendererCommon.RendererEvents rendererEvent s) { |
| 139 init(sharedContext, rendererEvents, EglBase.CONFIG_PLAIN, new GlRectDrawer() ); | 139 init(sharedContext, rendererEvents, EglBase.CONFIG_PLAIN, new GlRectDrawer() ); |
| 140 } | 140 } |
| 141 | 141 |
| 142 /** | 142 /** |
| 143 * Initialize this class, sharing resources with |sharedContext|. The custom | drawer| will be used | 143 * Initialize this class, sharing resources with |sharedContext|. The custom | drawer| will be used |
| 144 * for drawing frames on the EGLSurface. This class is responsible for calling release() on | 144 * for drawing frames on the EGLSurface. This class is responsible for calling release() on |
| 145 * |drawer|. It is allowed to call init() to reinitialize the renderer after a previous | 145 * |drawer|. It is allowed to call init() to reinitialize the renderer after a previous |
| 146 * init()/release() cycle. | 146 * init()/release() cycle. |
| 147 */ | 147 */ |
| 148 public void init(EglBase.Context sharedContext, RendererCommon.RendererEvents rendererEvents, | 148 public void init( |
| 149 int[] configAttributes, RendererCommon.GlDrawer drawer) { | 149 final EglBase.Context sharedContext, RendererCommon.RendererEvents rendere rEvents, |
| 150 final int[] configAttributes, RendererCommon.GlDrawer drawer) { | |
| 150 synchronized (handlerLock) { | 151 synchronized (handlerLock) { |
| 151 if (renderThreadHandler != null) { | 152 if (renderThreadHandler != null) { |
| 152 throw new IllegalStateException(getResourceName() + "Already initialized "); | 153 throw new IllegalStateException(getResourceName() + "Already initialized "); |
| 153 } | 154 } |
| 154 Logging.d(TAG, getResourceName() + "Initializing."); | 155 Logging.d(TAG, getResourceName() + "Initializing."); |
| 155 this.rendererEvents = rendererEvents; | 156 this.rendererEvents = rendererEvents; |
| 156 this.drawer = drawer; | 157 this.drawer = drawer; |
| 157 renderThread = new HandlerThread(TAG); | 158 renderThread = new HandlerThread(TAG); |
| 158 renderThread.start(); | 159 renderThread.start(); |
| 159 eglBase = EglBase.create(sharedContext, configAttributes); | |
| 160 renderThreadHandler = new Handler(renderThread.getLooper()); | 160 renderThreadHandler = new Handler(renderThread.getLooper()); |
| 161 // Create EGL context on the newly created render thread. It should be pos sibly to create the | |
| 162 // context on this thread and make it current on the render thread, but th is causes failure on | |
| 163 // some Marvel based JB devices. | |
|
perkj_webrtc
2016/09/14 07:02:05
nit: link comment to bug.
magjed_webrtc
2016/09/14 07:50:00
Done.
| |
| 164 ThreadUtils.invokeAtFrontUninterruptibly(renderThreadHandler, new Runnable () { | |
|
sakal
2016/09/14 07:10:05
Invoking is safer but do we need to do that? I thi
magjed_webrtc
2016/09/14 07:50:00
I'm worried about release() being called immediate
| |
| 165 @Override | |
| 166 public void run() { | |
| 167 eglBase = EglBase.create(sharedContext, configAttributes); | |
|
perkj_webrtc
2016/09/14 07:02:05
ok- so previously we created it on this thread and
magjed_webrtc
2016/09/14 07:50:00
Yes, which should be fine according to the documen
| |
| 168 } | |
| 169 }); | |
| 161 } | 170 } |
| 162 tryCreateEglSurface(); | 171 tryCreateEglSurface(); |
| 163 } | 172 } |
| 164 | 173 |
| 165 /** | 174 /** |
| 166 * Create and make an EGLSurface current if both init() and surfaceCreated() h ave been called. | 175 * Create and make an EGLSurface current if both init() and surfaceCreated() h ave been called. |
| 167 */ | 176 */ |
| 168 public void tryCreateEglSurface() { | 177 public void tryCreateEglSurface() { |
| 169 // |renderThreadHandler| is only created after |eglBase| is created in init( ), so the | 178 // |renderThreadHandler| is only created after |eglBase| is created in init( ), so the |
| 170 // following code will only execute if eglBase != null. | 179 // following code will only execute if eglBase != null. |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 if (framesReceived > 0 && framesRendered > 0) { | 571 if (framesReceived > 0 && framesRendered > 0) { |
| 563 final long timeSinceFirstFrameNs = System.nanoTime() - firstFrameTimeNs; | 572 final long timeSinceFirstFrameNs = System.nanoTime() - firstFrameTimeNs; |
| 564 Logging.d(TAG, getResourceName() + "Duration: " + (int) (timeSinceFirstF rameNs / 1e6) + | 573 Logging.d(TAG, getResourceName() + "Duration: " + (int) (timeSinceFirstF rameNs / 1e6) + |
| 565 " ms. FPS: " + framesRendered * 1e9 / timeSinceFirstFrameNs); | 574 " ms. FPS: " + framesRendered * 1e9 / timeSinceFirstFrameNs); |
| 566 Logging.d(TAG, getResourceName() + "Average render time: " | 575 Logging.d(TAG, getResourceName() + "Average render time: " |
| 567 + (int) (renderTimeNs / (1000 * framesRendered)) + " us."); | 576 + (int) (renderTimeNs / (1000 * framesRendered)) + " us."); |
| 568 } | 577 } |
| 569 } | 578 } |
| 570 } | 579 } |
| 571 } | 580 } |
| OLD | NEW |