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

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

Issue 2320923002: Add a full Blimp integration test. (Closed)
Patch Set: Fix build break with chrome embedder 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_(std::move(contents_layer)),
23 weak_ptr_factory_(this) {
24 DCHECK(blimp_contents_);
25 DCHECK(contents_layer_);
26 }
27
28 BlimpContentsViewImpl::~BlimpContentsViewImpl() = default;
29
30 scoped_refptr<cc::Layer> BlimpContentsViewImpl::GetLayer() {
31 return contents_layer_;
32 }
33
34 void BlimpContentsViewImpl::SetSizeAndScale(const gfx::Size& size,
35 float device_scale_factor) {
36 blimp_contents_->SetSizeAndScale(size, device_scale_factor);
37 }
38
39 bool BlimpContentsViewImpl::OnTouchEvent(const ui::MotionEvent& motion_event) {
40 return blimp_contents_->compositor_manager()->OnTouchEvent(motion_event);
41 }
42
43 void BlimpContentsViewImpl::CopyFromCompositingSurface(
44 const ReadbackRequestCallback& callback) {
45 blimp_contents_->compositor_manager()->NotifyWhenDonePendingCommits(
46 base::Bind(&BlimpContentsViewImpl::StartReadbackRequest,
47 weak_ptr_factory_.GetWeakPtr(), callback));
48 }
49
50 void BlimpContentsViewImpl::StartReadbackRequest(
51 const ReadbackRequestCallback& callback) {
52 std::unique_ptr<cc::CopyOutputRequest> request =
53 cc::CopyOutputRequest::CreateBitmapRequest(
54 base::Bind(&BlimpContentsViewImpl::OnReadbackComplete,
55 weak_ptr_factory_.GetWeakPtr(), callback));
56 contents_layer_->RequestCopyOfOutput(std::move(request));
57 }
58
59 void BlimpContentsViewImpl::OnReadbackComplete(
60 const ReadbackRequestCallback& callback,
61 std::unique_ptr<cc::CopyOutputResult> result) {
62 callback.Run(result->TakeBitmap());
63 }
64
65 } // namespace client
66 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/contents/blimp_contents_view_impl.h ('k') | blimp/client/core/contents/blimp_contents_view_impl_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698