| OLD | NEW |
| 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 Loading... |
| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 106 |
| 108 // TODO(boliu): Handle context loss. | 107 // TODO(boliu): Handle context loss. |
| 109 if (last_egl_context_ != current_context) | 108 if (last_egl_context_ != current_context) |
| 110 DLOG(WARNING) << "EGLContextChanged"; | 109 DLOG(WARNING) << "EGLContextChanged"; |
| 111 | 110 |
| 112 // SurfaceFactory::SubmitCompositorFrame might call glFlush. So calling it | 111 // SurfaceFactory::SubmitCompositorFrame might call glFlush. So calling it |
| 113 // during "kModeSync" stage (which does not allow GL) might result in extra | 112 // during "kModeSync" stage (which does not allow GL) might result in extra |
| 114 // kModeProcess. Instead, submit the frame in "kModeDraw" stage to avoid | 113 // kModeProcess. Instead, submit the frame in "kModeDraw" stage to avoid |
| 115 // unnecessary kModeProcess. | 114 // unnecessary kModeProcess. |
| 116 if (child_frame_.get() && child_frame_->frame.get()) { | 115 if (child_frame_.get() && child_frame_->frame.get()) { |
| 117 if (compositor_id_ != child_frame_->compositor_id || | 116 if (CompositorIDIsDifferent()(compositor_id_, |
| 117 child_frame_->compositor_id) || |
| 118 last_submitted_output_surface_id_ != child_frame_->output_surface_id) { | 118 last_submitted_output_surface_id_ != child_frame_->output_surface_id) { |
| 119 if (!root_id_.is_null()) | 119 if (!root_id_.is_null()) |
| 120 surface_factory_->Destroy(root_id_); | 120 surface_factory_->Destroy(root_id_); |
| 121 if (!child_id_.is_null()) | 121 if (!child_id_.is_null()) |
| 122 surface_factory_->Destroy(child_id_); | 122 surface_factory_->Destroy(child_id_); |
| 123 | 123 |
| 124 root_id_ = cc::SurfaceId(); | 124 root_id_ = cc::SurfaceId(); |
| 125 child_id_ = cc::SurfaceId(); | 125 child_id_ = cc::SurfaceId(); |
| 126 | 126 |
| 127 // This will return all the resources to the previous compositor. | 127 // This will return all the resources to the previous compositor. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // compositor_id_. | 254 // compositor_id_. |
| 255 ReturnResourcesToCompositor(resources_to_return, | 255 ReturnResourcesToCompositor(resources_to_return, |
| 256 child_frame_->compositor_id, | 256 child_frame_->compositor_id, |
| 257 child_frame_->output_surface_id); | 257 child_frame_->output_surface_id); |
| 258 } | 258 } |
| 259 child_frame_.reset(); | 259 child_frame_.reset(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void HardwareRenderer::ReturnResourcesToCompositor( | 262 void HardwareRenderer::ReturnResourcesToCompositor( |
| 263 const cc::ReturnedResourceArray& resources, | 263 const cc::ReturnedResourceArray& resources, |
| 264 uint32_t compositor_id, | 264 CompositorID compositor_id, |
| 265 uint32_t output_surface_id) { | 265 uint32_t output_surface_id) { |
| 266 if (output_surface_id != last_committed_output_surface_id_) | 266 if (output_surface_id != last_committed_output_surface_id_) |
| 267 return; | 267 return; |
| 268 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, | 268 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, |
| 269 output_surface_id); | 269 output_surface_id); |
| 270 } | 270 } |
| 271 | 271 |
| 272 } // namespace android_webview | 272 } // namespace android_webview |
| OLD | NEW |