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

Side by Side Diff: blimp/client/core/contents/blimp_contents_view_impl.cc

Issue 2320923002: Add a full Blimp integration test. (Closed)
Patch Set: Addressed more comments, added thread restriction bypass for tests. Created 4 years, 3 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/client/core/contents/blimp_contents_view_impl.h"
6
7 #include "base/bind.h"
8 #include "base/callback_helpers.h"
9 #include "base/threading/thread_task_runner_handle.h"
10 #include "blimp/client/core/contents/blimp_contents_impl.h"
11 #include "cc/output/copy_output_request.h"
12 #include "cc/output/copy_output_result.h"
13 #include "ui/gfx/geometry/size.h"
14
15 namespace blimp {
16 namespace client {
17
18 BlimpContentsViewImpl::BlimpContentsViewImpl(
19 BlimpContentsImpl* blimp_contents,
20 scoped_refptr<cc::Layer> contents_layer)
21 : blimp_contents_(blimp_contents),
22 contents_layer_(contents_layer),
Khushal 2016/09/13 23:47:10 nit: std::move is nicer.
David Trainor- moved to gerrit 2016/09/14 00:31:09 Done.
23 weak_ptr_factory_(this) {}
Khushal 2016/09/13 23:47:10 DCHECK content_layer_ and blimp_contents?
David Trainor- moved to gerrit 2016/09/14 00:31:09 Done.
24
25 BlimpContentsViewImpl::~BlimpContentsViewImpl() = default;
26
27 scoped_refptr<cc::Layer> BlimpContentsViewImpl::GetLayer() {
28 return contents_layer_;
29 }
30
31 void BlimpContentsViewImpl::SetSizeAndScale(const gfx::Size& size,
32 float device_scale_factor) {
33 blimp_contents_->SetSizeAndScale(size, device_scale_factor);
34 }
35
36 bool BlimpContentsViewImpl::OnTouchEvent(const ui::MotionEvent& motion_event) {
37 return blimp_contents_->compositor_manager()->OnTouchEvent(motion_event);
38 }
39
40 void BlimpContentsViewImpl::CopyFromCompositingSurface(
41 const ReadbackRequestCallback& callback,
42 bool flush_pending_commits) {
43 // If we currently have a readback or we don't have a content layer drop the
44 // readback request.
45 if (!readback_callback_.is_null() || !contents_layer_) {
Khushal 2016/09/13 23:47:10 We should always have a content_layer_ here. This
David Trainor- moved to gerrit 2016/09/14 00:31:09 Done.
46 base::ThreadTaskRunnerHandle::Get()->PostTask(
47 FROM_HERE, base::Bind(callback, nullptr));
48 return;
49 }
50
51 readback_callback_ = callback;
52
53 if (flush_pending_commits) {
54 blimp_contents_->compositor_manager()->NotifyWhenDonePendingCommits(
55 base::Bind(&BlimpContentsViewImpl::StartReadbackRequest,
56 weak_ptr_factory_.GetWeakPtr()));
57 } else {
58 StartReadbackRequest();
59 }
60 }
61
62 void BlimpContentsViewImpl::StartReadbackRequest() {
63 std::unique_ptr<cc::CopyOutputRequest> request =
64 cc::CopyOutputRequest::CreateBitmapRequest(
65 base::Bind(&BlimpContentsViewImpl::OnReadbackComplete,
66 weak_ptr_factory_.GetWeakPtr()));
67 contents_layer_->RequestCopyOfOutput(std::move(request));
68 }
69
70 void BlimpContentsViewImpl::OnReadbackComplete(
71 std::unique_ptr<cc::CopyOutputResult> result) {
72 DCHECK(!readback_callback_.is_null());
73 base::ResetAndReturn(&readback_callback_).Run(result->TakeBitmap());
74 }
75
76 } // namespace client
77 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698