| OLD | NEW | 
|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/android/in_process/synchronous_compositor_output_surfa
     ce.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
     ce.h" | 
| 6 | 6 | 
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" | 
| 8 #include "base/logging.h" | 8 #include "base/logging.h" | 
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" | 
| 10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" | 
| 11 #include "cc/output/output_surface_client.h" | 11 #include "cc/output/output_surface_client.h" | 
| 12 #include "cc/output/software_output_device.h" | 12 #include "cc/output/software_output_device.h" | 
| 13 #include "content/browser/android/in_process/synchronous_compositor_external_beg
     in_frame_source.h" | 13 #include "content/browser/android/in_process/synchronous_compositor_external_beg
     in_frame_source.h" | 
| 14 #include "content/browser/android/in_process/synchronous_compositor_impl.h" | 14 #include "content/browser/android/in_process/synchronous_compositor_impl.h" | 
| 15 #include "content/browser/android/in_process/synchronous_compositor_registry.h" | 15 #include "content/browser/android/in_process/synchronous_compositor_registry.h" | 
| 16 #include "content/browser/gpu/compositor_util.h" | 16 #include "content/browser/gpu/compositor_util.h" | 
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" | 
| 18 #include "content/renderer/gpu/frame_swap_message_queue.h" | 18 #include "content/renderer/gpu/frame_swap_message_queue.h" | 
|  | 19 #include "gpu/command_buffer/client/context_support.h" | 
| 19 #include "gpu/command_buffer/client/gles2_interface.h" | 20 #include "gpu/command_buffer/client/gles2_interface.h" | 
| 20 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 21 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 
| 21 #include "third_party/skia/include/core/SkCanvas.h" | 22 #include "third_party/skia/include/core/SkCanvas.h" | 
| 22 #include "ui/gfx/geometry/rect_conversions.h" | 23 #include "ui/gfx/geometry/rect_conversions.h" | 
| 23 #include "ui/gfx/skia_util.h" | 24 #include "ui/gfx/skia_util.h" | 
| 24 #include "ui/gfx/transform.h" | 25 #include "ui/gfx/transform.h" | 
| 25 | 26 | 
| 26 namespace content { | 27 namespace content { | 
| 27 | 28 | 
| 28 namespace { | 29 namespace { | 
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 236     client_->DidSwapBuffersComplete(); | 237     client_->DidSwapBuffersComplete(); | 
| 237 } | 238 } | 
| 238 | 239 | 
| 239 void SynchronousCompositorOutputSurface::ReturnResources( | 240 void SynchronousCompositorOutputSurface::ReturnResources( | 
| 240     const cc::CompositorFrameAck& frame_ack) { | 241     const cc::CompositorFrameAck& frame_ack) { | 
| 241   ReclaimResources(&frame_ack); | 242   ReclaimResources(&frame_ack); | 
| 242 } | 243 } | 
| 243 | 244 | 
| 244 void SynchronousCompositorOutputSurface::SetMemoryPolicy(size_t bytes_limit) { | 245 void SynchronousCompositorOutputSurface::SetMemoryPolicy(size_t bytes_limit) { | 
| 245   DCHECK(CalledOnValidThread()); | 246   DCHECK(CalledOnValidThread()); | 
|  | 247   bool became_zero = memory_policy_.bytes_limit_when_visible && !bytes_limit; | 
|  | 248   bool became_non_zero = | 
|  | 249       !memory_policy_.bytes_limit_when_visible && bytes_limit; | 
| 246   memory_policy_.bytes_limit_when_visible = bytes_limit; | 250   memory_policy_.bytes_limit_when_visible = bytes_limit; | 
| 247   memory_policy_.num_resources_limit = kNumResourcesLimit; | 251   memory_policy_.num_resources_limit = kNumResourcesLimit; | 
| 248 | 252 | 
| 249   if (client_) | 253   if (client_) | 
| 250     client_->SetMemoryPolicy(memory_policy_); | 254     client_->SetMemoryPolicy(memory_policy_); | 
|  | 255 | 
|  | 256   if (became_zero) { | 
|  | 257     // This is small hack to drop context resources without destroying it | 
|  | 258     // when this compositor is put into the background. | 
|  | 259     context_provider()->ContextSupport()->SetSurfaceVisible(false); | 
|  | 260   } else if (became_non_zero) { | 
|  | 261     context_provider()->ContextSupport()->SetSurfaceVisible(true); | 
|  | 262   } | 
| 251 } | 263 } | 
| 252 | 264 | 
| 253 void SynchronousCompositorOutputSurface::SetTreeActivationCallback( | 265 void SynchronousCompositorOutputSurface::SetTreeActivationCallback( | 
| 254     const base::Closure& callback) { | 266     const base::Closure& callback) { | 
| 255   DCHECK(client_); | 267   DCHECK(client_); | 
| 256   client_->SetTreeActivationCallback(callback); | 268   client_->SetTreeActivationCallback(callback); | 
| 257 } | 269 } | 
| 258 | 270 | 
| 259 void SynchronousCompositorOutputSurface::GetMessagesToDeliver( | 271 void SynchronousCompositorOutputSurface::GetMessagesToDeliver( | 
| 260     ScopedVector<IPC::Message>* messages) { | 272     ScopedVector<IPC::Message>* messages) { | 
| 261   DCHECK(CalledOnValidThread()); | 273   DCHECK(CalledOnValidThread()); | 
| 262   scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = | 274   scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = | 
| 263       frame_swap_message_queue_->AcquireSendMessageScope(); | 275       frame_swap_message_queue_->AcquireSendMessageScope(); | 
| 264   frame_swap_message_queue_->DrainMessages(messages); | 276   frame_swap_message_queue_->DrainMessages(messages); | 
| 265 } | 277 } | 
| 266 | 278 | 
| 267 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 279 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | 
| 268 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI | 280 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI | 
| 269 // thread. | 281 // thread. | 
| 270 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 282 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { | 
| 271   return BrowserThread::CurrentlyOn(BrowserThread::UI); | 283   return BrowserThread::CurrentlyOn(BrowserThread::UI); | 
| 272 } | 284 } | 
| 273 | 285 | 
| 274 }  // namespace content | 286 }  // namespace content | 
| OLD | NEW | 
|---|