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

Side by Side Diff: android_webview/browser/hardware_renderer.cc

Issue 2036023002: Rewire Android WebView's compositor changed signal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use web_contents_ Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "android_webview/browser/hardware_renderer.h" 5 #include "android_webview/browser/hardware_renderer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "android_webview/browser/aw_gl_surface.h" 9 #include "android_webview/browser/aw_gl_surface.h"
10 #include "android_webview/browser/aw_render_thread_context_provider.h" 10 #include "android_webview/browser/aw_render_thread_context_provider.h"
(...skipping 20 matching lines...) Expand all
31 #include "ui/gfx/geometry/rect_f.h" 31 #include "ui/gfx/geometry/rect_f.h"
32 #include "ui/gfx/transform.h" 32 #include "ui/gfx/transform.h"
33 #include "ui/gl/gl_bindings.h" 33 #include "ui/gl/gl_bindings.h"
34 34
35 namespace android_webview { 35 namespace android_webview {
36 36
37 HardwareRenderer::HardwareRenderer(RenderThreadManager* state) 37 HardwareRenderer::HardwareRenderer(RenderThreadManager* state)
38 : render_thread_manager_(state), 38 : render_thread_manager_(state),
39 last_egl_context_(eglGetCurrentContext()), 39 last_egl_context_(eglGetCurrentContext()),
40 gl_surface_(new AwGLSurface), 40 gl_surface_(new AwGLSurface),
41 compositor_id_(0u), // Valid compositor id starts at 1.
42 last_committed_output_surface_id_(0u), 41 last_committed_output_surface_id_(0u),
43 last_submitted_output_surface_id_(0u), 42 last_submitted_output_surface_id_(0u),
44 output_surface_(NULL) { 43 output_surface_(NULL) {
45 DCHECK(last_egl_context_); 44 DCHECK(last_egl_context_);
46 45
47 cc::RendererSettings settings; 46 cc::RendererSettings settings;
48 47
49 // Should be kept in sync with compositor_impl_android.cc. 48 // Should be kept in sync with compositor_impl_android.cc.
50 settings.allow_antialiasing = false; 49 settings.allow_antialiasing = false;
51 settings.highp_threshold_min = 2048; 50 settings.highp_threshold_min = 2048;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 114
116 // TODO(boliu): Handle context loss. 115 // TODO(boliu): Handle context loss.
117 if (last_egl_context_ != current_context) 116 if (last_egl_context_ != current_context)
118 DLOG(WARNING) << "EGLContextChanged"; 117 DLOG(WARNING) << "EGLContextChanged";
119 118
120 // SurfaceFactory::SubmitCompositorFrame might call glFlush. So calling it 119 // SurfaceFactory::SubmitCompositorFrame might call glFlush. So calling it
121 // during "kModeSync" stage (which does not allow GL) might result in extra 120 // during "kModeSync" stage (which does not allow GL) might result in extra
122 // kModeProcess. Instead, submit the frame in "kModeDraw" stage to avoid 121 // kModeProcess. Instead, submit the frame in "kModeDraw" stage to avoid
123 // unnecessary kModeProcess. 122 // unnecessary kModeProcess.
124 if (child_frame_.get() && child_frame_->frame.get()) { 123 if (child_frame_.get() && child_frame_->frame.get()) {
125 if (compositor_id_ != child_frame_->compositor_id || 124 if (!compositor_id_.Equals(child_frame_->compositor_id) ||
126 last_submitted_output_surface_id_ != child_frame_->output_surface_id) { 125 last_submitted_output_surface_id_ != child_frame_->output_surface_id) {
127 if (!root_id_.is_null()) 126 if (!root_id_.is_null())
128 surface_factory_->Destroy(root_id_); 127 surface_factory_->Destroy(root_id_);
129 if (!child_id_.is_null()) 128 if (!child_id_.is_null())
130 surface_factory_->Destroy(child_id_); 129 surface_factory_->Destroy(child_id_);
131 130
132 root_id_ = cc::SurfaceId(); 131 root_id_ = cc::SurfaceId();
133 child_id_ = cc::SurfaceId(); 132 child_id_ = cc::SurfaceId();
134 133
135 // This will return all the resources to the previous compositor. 134 // This will return all the resources to the previous compositor.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // compositor_id_. 252 // compositor_id_.
254 ReturnResourcesToCompositor(resources_to_return, 253 ReturnResourcesToCompositor(resources_to_return,
255 child_frame_->compositor_id, 254 child_frame_->compositor_id,
256 child_frame_->output_surface_id); 255 child_frame_->output_surface_id);
257 } 256 }
258 child_frame_.reset(); 257 child_frame_.reset();
259 } 258 }
260 259
261 void HardwareRenderer::ReturnResourcesToCompositor( 260 void HardwareRenderer::ReturnResourcesToCompositor(
262 const cc::ReturnedResourceArray& resources, 261 const cc::ReturnedResourceArray& resources,
263 uint32_t compositor_id, 262 const CompositorID& compositor_id,
264 uint32_t output_surface_id) { 263 uint32_t output_surface_id) {
265 if (output_surface_id != last_committed_output_surface_id_) 264 if (output_surface_id != last_committed_output_surface_id_)
266 return; 265 return;
267 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, 266 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id,
268 output_surface_id); 267 output_surface_id);
269 } 268 }
270 269
271 } // namespace android_webview 270 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/hardware_renderer.h ('k') | android_webview/browser/render_thread_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698