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

Side by Side Diff: ui/android/delegated_frame_host_android.cc

Issue 2514033002: Introducing SurfaceReferenceFactory (Closed)
Patch Set: fix 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 "ui/android/delegated_frame_host_android.h" 5 #include "ui/android/delegated_frame_host_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "cc/layers/solid_color_layer.h" 9 #include "cc/layers/solid_color_layer.h"
10 #include "cc/layers/surface_layer.h" 10 #include "cc/layers/surface_layer.h"
11 #include "cc/output/compositor_frame.h" 11 #include "cc/output/compositor_frame.h"
12 #include "cc/output/copy_output_result.h" 12 #include "cc/output/copy_output_result.h"
13 #include "cc/surfaces/surface.h" 13 #include "cc/surfaces/surface.h"
14 #include "cc/surfaces/surface_id.h" 14 #include "cc/surfaces/surface_id.h"
15 #include "cc/surfaces/surface_id_allocator.h" 15 #include "cc/surfaces/surface_id_allocator.h"
16 #include "cc/surfaces/surface_manager.h" 16 #include "cc/surfaces/surface_manager.h"
17 #include "ui/android/context_provider_factory.h" 17 #include "ui/android/context_provider_factory.h"
18 #include "ui/android/view_android.h" 18 #include "ui/android/view_android.h"
19 #include "ui/android/window_android_compositor.h" 19 #include "ui/android/window_android_compositor.h"
20 #include "ui/gfx/android/device_display_info.h" 20 #include "ui/gfx/android/device_display_info.h"
21 #include "ui/gfx/geometry/dip_util.h" 21 #include "ui/gfx/geometry/dip_util.h"
22 22
23 namespace ui { 23 namespace ui {
24 24
25 namespace { 25 namespace {
26 26
27 void SatisfyCallback(cc::SurfaceManager* manager,
28 const cc::SurfaceSequence& sequence) {
29 std::vector<uint32_t> sequences;
30 sequences.push_back(sequence.sequence);
31 manager->DidSatisfySequences(sequence.frame_sink_id, &sequences);
32 }
33
34 void RequireCallback(cc::SurfaceManager* manager,
35 const cc::SurfaceId& id,
36 const cc::SurfaceSequence& sequence) {
37 cc::Surface* surface = manager->GetSurfaceForId(id);
38 if (!surface) {
39 LOG(ERROR) << "Attempting to require callback on nonexistent surface";
40 return;
41 }
42 surface->AddDestructionDependency(sequence);
43 }
44
45 scoped_refptr<cc::SurfaceLayer> CreateSurfaceLayer( 27 scoped_refptr<cc::SurfaceLayer> CreateSurfaceLayer(
46 cc::SurfaceManager* surface_manager, 28 cc::SurfaceManager* surface_manager,
47 cc::SurfaceId surface_id, 29 cc::SurfaceId surface_id,
48 const gfx::Size surface_size, 30 const gfx::Size surface_size,
49 bool surface_opaque) { 31 bool surface_opaque) {
50 // manager must outlive compositors using it. 32 // manager must outlive compositors using it.
51 scoped_refptr<cc::SurfaceLayer> layer = cc::SurfaceLayer::Create( 33 scoped_refptr<cc::SurfaceLayer> layer = cc::SurfaceLayer::Create();
52 base::Bind(&SatisfyCallback, base::Unretained(surface_manager)), 34 cc::SurfaceRefPtr surface_ref =
53 base::Bind(&RequireCallback, base::Unretained(surface_manager))); 35 surface_manager->NewSurfaceRef(surface_id, 1.f, surface_size);
Fady Samuel 2016/11/30 19:51:29 SurfaceManager will live in mus gpu and this Surfa
54 layer->SetSurfaceId(surface_id, 1.f, surface_size); 36 layer->SetSurfaceRef(std::move(surface_ref));
55 layer->SetBounds(surface_size); 37 layer->SetBounds(surface_size);
56 layer->SetIsDrawable(true); 38 layer->SetIsDrawable(true);
57 layer->SetContentsOpaque(surface_opaque); 39 layer->SetContentsOpaque(surface_opaque);
58 40
59 return layer; 41 return layer;
60 } 42 }
61 43
62 void CopyOutputRequestCallback( 44 void CopyOutputRequestCallback(
63 scoped_refptr<cc::Layer> readback_layer, 45 scoped_refptr<cc::Layer> readback_layer,
64 cc::CopyOutputRequest::CopyOutputRequestCallback result_callback, 46 cc::CopyOutputRequest::CopyOutputRequestCallback result_callback,
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 content_size_in_dip.width() < container_size_in_dip_.width() || 244 content_size_in_dip.width() < container_size_in_dip_.width() ||
263 content_size_in_dip.height() < container_size_in_dip_.height(); 245 content_size_in_dip.height() < container_size_in_dip_.height();
264 } else { 246 } else {
265 background_is_drawable = true; 247 background_is_drawable = true;
266 } 248 }
267 249
268 background_layer_->SetIsDrawable(background_is_drawable); 250 background_layer_->SetIsDrawable(background_is_drawable);
269 } 251 }
270 252
271 } // namespace ui 253 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698