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

Side by Side Diff: content/browser/renderer_host/delegated_frame_host.cc

Issue 2514033002: Introducing SurfaceReferenceFactory (Closed)
Patch Set: rebase Created 4 years 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
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/renderer/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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>
(...skipping 20 matching lines...) Expand all
31 #include "media/base/video_frame.h" 31 #include "media/base/video_frame.h"
32 #include "media/base/video_util.h" 32 #include "media/base/video_util.h"
33 #include "skia/ext/image_operations.h" 33 #include "skia/ext/image_operations.h"
34 #include "third_party/skia/include/core/SkCanvas.h" 34 #include "third_party/skia/include/core/SkCanvas.h"
35 #include "third_party/skia/include/core/SkPaint.h" 35 #include "third_party/skia/include/core/SkPaint.h"
36 #include "third_party/skia/include/effects/SkLumaColorFilter.h" 36 #include "third_party/skia/include/effects/SkLumaColorFilter.h"
37 #include "ui/gfx/geometry/dip_util.h" 37 #include "ui/gfx/geometry/dip_util.h"
38 38
39 namespace content { 39 namespace content {
40 40
41 namespace {
42
43 void SatisfyCallback(base::WeakPtr<cc::SurfaceManager> manager,
44 const cc::SurfaceSequence& sequence) {
45 if (!manager)
46 return;
47 std::vector<uint32_t> sequences;
48 sequences.push_back(sequence.sequence);
49 manager->DidSatisfySequences(sequence.frame_sink_id, &sequences);
50 }
51
52 void RequireCallback(base::WeakPtr<cc::SurfaceManager> manager,
53 const cc::SurfaceId& id,
54 const cc::SurfaceSequence& sequence) {
55 cc::Surface* surface = manager->GetSurfaceForId(id);
56 if (!surface) {
57 LOG(ERROR) << "Attempting to require callback on nonexistent surface";
58 return;
59 }
60 surface->AddDestructionDependency(sequence);
61 }
62
63 } // namespace
64
65 //////////////////////////////////////////////////////////////////////////////// 41 ////////////////////////////////////////////////////////////////////////////////
66 // DelegatedFrameHost 42 // DelegatedFrameHost
67 43
68 DelegatedFrameHost::DelegatedFrameHost(const cc::FrameSinkId& frame_sink_id, 44 DelegatedFrameHost::DelegatedFrameHost(const cc::FrameSinkId& frame_sink_id,
69 DelegatedFrameHostClient* client) 45 DelegatedFrameHostClient* client)
70 : frame_sink_id_(frame_sink_id), 46 : frame_sink_id_(frame_sink_id),
71 client_(client), 47 client_(client),
72 compositor_(nullptr), 48 compositor_(nullptr),
73 tick_clock_(new base::DefaultTickClock()), 49 tick_clock_(new base::DefaultTickClock()),
74 last_compositor_frame_sink_id_(0), 50 last_compositor_frame_sink_id_(0),
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 cc::SurfaceFactory::DrawCallback ack_callback; 482 cc::SurfaceFactory::DrawCallback ack_callback;
507 if (compositor_ && !skip_frame) { 483 if (compositor_ && !skip_frame) {
508 ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, AsWeakPtr(), 484 ack_callback = base::Bind(&DelegatedFrameHost::SurfaceDrawn, AsWeakPtr(),
509 compositor_frame_sink_id); 485 compositor_frame_sink_id);
510 did_send_ack_callback = true; 486 did_send_ack_callback = true;
511 } 487 }
512 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), 488 surface_factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame),
513 ack_callback); 489 ack_callback);
514 if (allocated_new_local_frame_id) { 490 if (allocated_new_local_frame_id) {
515 // manager must outlive compositors using it. 491 // manager must outlive compositors using it.
492 cc::SurfaceId surface_id(frame_sink_id_, local_frame_id_);
493 cc::SurfaceInfo surface_info(surface_id, frame_device_scale_factor,
494 frame_size);
516 client_->DelegatedFrameHostGetLayer()->SetShowSurface( 495 client_->DelegatedFrameHostGetLayer()->SetShowSurface(
517 cc::SurfaceId(frame_sink_id_, local_frame_id_), 496 surface_info, manager->reference_factory());
518 base::Bind(&SatisfyCallback, manager->GetWeakPtr()),
519 base::Bind(&RequireCallback, manager->GetWeakPtr()), frame_size,
520 frame_device_scale_factor);
521 current_surface_size_ = frame_size; 497 current_surface_size_ = frame_size;
522 current_scale_factor_ = frame_device_scale_factor; 498 current_scale_factor_ = frame_device_scale_factor;
523 } 499 }
524 } 500 }
525 released_front_lock_ = NULL; 501 released_front_lock_ = NULL;
526 current_frame_size_in_dip_ = frame_size_in_dip; 502 current_frame_size_in_dip_ = frame_size_in_dip;
527 CheckResizeLock(); 503 CheckResizeLock();
528 504
529 UpdateGutters(); 505 UpdateGutters();
530 506
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 std::move(request)); 867 std::move(request));
892 } 868 }
893 } 869 }
894 870
895 void DelegatedFrameHost::UnlockResources() { 871 void DelegatedFrameHost::UnlockResources() {
896 DCHECK(local_frame_id_.is_valid()); 872 DCHECK(local_frame_id_.is_valid());
897 delegated_frame_evictor_->UnlockFrame(); 873 delegated_frame_evictor_->UnlockFrame();
898 } 874 }
899 875
900 } // namespace content 876 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/renderer/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698