| 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 "content/browser/renderer_host/delegated_frame_host.h" | 5 #include "content/browser/renderer_host/delegated_frame_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/time/default_tick_clock.h" | 15 #include "base/time/default_tick_clock.h" |
| 16 #include "cc/base/switches.h" | 16 #include "cc/base/switches.h" |
| 17 #include "cc/output/compositor_frame.h" | 17 #include "cc/output/compositor_frame.h" |
| 18 #include "cc/output/copy_output_request.h" | 18 #include "cc/output/copy_output_request.h" |
| 19 #include "cc/resources/single_release_callback.h" | 19 #include "cc/resources/single_release_callback.h" |
| 20 #include "cc/resources/texture_mailbox.h" | 20 #include "cc/resources/texture_mailbox.h" |
| 21 #include "cc/surfaces/direct_surface_embedding.h" |
| 21 #include "cc/surfaces/surface.h" | 22 #include "cc/surfaces/surface.h" |
| 22 #include "cc/surfaces/surface_factory.h" | 23 #include "cc/surfaces/surface_factory.h" |
| 23 #include "cc/surfaces/surface_hittest.h" | 24 #include "cc/surfaces/surface_hittest.h" |
| 24 #include "cc/surfaces/surface_manager.h" | 25 #include "cc/surfaces/surface_manager.h" |
| 25 #include "components/display_compositor/gl_helper.h" | 26 #include "components/display_compositor/gl_helper.h" |
| 26 #include "content/browser/compositor/surface_utils.h" | 27 #include "content/browser/compositor/surface_utils.h" |
| 27 #include "content/browser/gpu/compositor_util.h" | 28 #include "content/browser/gpu/compositor_util.h" |
| 28 #include "content/browser/renderer_host/resize_lock.h" | 29 #include "content/browser/renderer_host/resize_lock.h" |
| 29 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 30 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 30 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
| 31 #include "media/base/video_frame.h" | 32 #include "media/base/video_frame.h" |
| 32 #include "media/base/video_util.h" | 33 #include "media/base/video_util.h" |
| 33 #include "skia/ext/image_operations.h" | 34 #include "skia/ext/image_operations.h" |
| 34 #include "third_party/skia/include/core/SkCanvas.h" | 35 #include "third_party/skia/include/core/SkCanvas.h" |
| 35 #include "third_party/skia/include/core/SkPaint.h" | 36 #include "third_party/skia/include/core/SkPaint.h" |
| 36 #include "third_party/skia/include/effects/SkLumaColorFilter.h" | 37 #include "third_party/skia/include/effects/SkLumaColorFilter.h" |
| 37 #include "ui/gfx/geometry/dip_util.h" | 38 #include "ui/gfx/geometry/dip_util.h" |
| 38 | 39 |
| 39 namespace content { | 40 namespace content { |
| 40 | 41 |
| 41 namespace { | |
| 42 | |
| 43 void SatisfyCallback(cc::SurfaceManager* manager, | |
| 44 const cc::SurfaceSequence& sequence) { | |
| 45 std::vector<uint32_t> sequences; | |
| 46 sequences.push_back(sequence.sequence); | |
| 47 manager->DidSatisfySequences(sequence.frame_sink_id, &sequences); | |
| 48 } | |
| 49 | |
| 50 void RequireCallback(cc::SurfaceManager* manager, | |
| 51 const cc::SurfaceId& id, | |
| 52 const cc::SurfaceSequence& sequence) { | |
| 53 cc::Surface* surface = manager->GetSurfaceForId(id); | |
| 54 if (!surface) { | |
| 55 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; | |
| 56 return; | |
| 57 } | |
| 58 surface->AddDestructionDependency(sequence); | |
| 59 } | |
| 60 | |
| 61 } // namespace | |
| 62 | |
| 63 //////////////////////////////////////////////////////////////////////////////// | 42 //////////////////////////////////////////////////////////////////////////////// |
| 64 // DelegatedFrameHost | 43 // DelegatedFrameHost |
| 65 | 44 |
| 66 DelegatedFrameHost::DelegatedFrameHost(const cc::FrameSinkId& frame_sink_id, | 45 DelegatedFrameHost::DelegatedFrameHost(const cc::FrameSinkId& frame_sink_id, |
| 67 DelegatedFrameHostClient* client) | 46 DelegatedFrameHostClient* client) |
| 68 : frame_sink_id_(frame_sink_id), | 47 : frame_sink_id_(frame_sink_id), |
| 69 client_(client), | 48 client_(client), |
| 70 compositor_(nullptr), | 49 compositor_(nullptr), |
| 71 tick_clock_(new base::DefaultTickClock()), | 50 tick_clock_(new base::DefaultTickClock()), |
| 72 last_compositor_frame_sink_id_(0), | 51 last_compositor_frame_sink_id_(0), |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 cc::SurfaceFactory::DrawCallback ack_callback; | 479 cc::SurfaceFactory::DrawCallback ack_callback; |
| 501 if (compositor_ && !skip_frame) { | 480 if (compositor_ && !skip_frame) { |
| 502 ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, AsWeakPtr(), | 481 ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, AsWeakPtr(), |
| 503 compositor_frame_sink_id); | 482 compositor_frame_sink_id); |
| 504 did_send_ack_callback = true; | 483 did_send_ack_callback = true; |
| 505 } | 484 } |
| 506 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), | 485 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), |
| 507 ack_callback); | 486 ack_callback); |
| 508 if (allocated_new_local_frame_id) { | 487 if (allocated_new_local_frame_id) { |
| 509 // manager must outlive compositors using it. | 488 // manager must outlive compositors using it. |
| 489 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_); |
| 490 auto surface_ref = base::MakeUnique<cc::DirectSurfaceEmbedding>( |
| 491 cc::SurfaceInfo(surface_id, frame_device_scale_factor, frame_size), |
| 492 manager); |
| 510 client_->DelegatedFrameHostGetLayer()->SetShowSurface( | 493 client_->DelegatedFrameHostGetLayer()->SetShowSurface( |
| 511 cc::SurfaceId(frame_sink_id_, local_frame_id_), | 494 std::move(surface_ref), frame_size_in_dip); |
| 512 base::Bind(&SatisfyCallback, base::Unretained(manager)), | |
| 513 base::Bind(&RequireCallback, base::Unretained(manager)), frame_size, | |
| 514 frame_device_scale_factor, frame_size_in_dip); | |
| 515 current_surface_size_ = frame_size; | 495 current_surface_size_ = frame_size; |
| 516 current_scale_factor_ = frame_device_scale_factor; | 496 current_scale_factor_ = frame_device_scale_factor; |
| 517 } | 497 } |
| 518 } | 498 } |
| 519 released_front_lock_ = NULL; | 499 released_front_lock_ = NULL; |
| 520 current_frame_size_in_dip_ = frame_size_in_dip; | 500 current_frame_size_in_dip_ = frame_size_in_dip; |
| 521 CheckResizeLock(); | 501 CheckResizeLock(); |
| 522 | 502 |
| 523 UpdateGutters(); | 503 UpdateGutters(); |
| 524 | 504 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 std::move(request)); | 861 std::move(request)); |
| 882 } | 862 } |
| 883 } | 863 } |
| 884 | 864 |
| 885 void DelegatedFrameHost::UnlockResources() { | 865 void DelegatedFrameHost::UnlockResources() { |
| 886 DCHECK(local_frame_id_.is_valid()); | 866 DCHECK(local_frame_id_.is_valid()); |
| 887 delegated_frame_evictor_->UnlockFrame(); | 867 delegated_frame_evictor_->UnlockFrame(); |
| 888 } | 868 } |
| 889 | 869 |
| 890 } // namespace content | 870 } // namespace content |
| OLD | NEW |