blob: 12e115cd6a128d8d150abc786d4d38b1d5119d91 [file] [log] [blame]
Christopher Cameron4bc282bb2017-12-03 11:24:051// Copyright 2017 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#ifndef UI_GFX_CA_LAYER_PARAMS_H_
6#define UI_GFX_CA_LAYER_PARAMS_H_
7
8#include "build/build_config.h"
Christopher Cameronb7158c72017-12-06 06:13:389#include "ui/gfx/geometry/size.h"
Christopher Cameron4bc282bb2017-12-03 11:24:0510#include "ui/gfx/gfx_export.h"
11
Xiaohan Wangd1b0e6b2022-01-20 21:40:2012#if BUILDFLAG(IS_MAC)
Christopher Cameron4bc282bb2017-12-03 11:24:0513#include "ui/gfx/mac/io_surface.h"
14#endif
15
16namespace gfx {
17
18// The parameters required to add a composited frame to a CALayer. This
19// is used only on macOS.
20struct GFX_EXPORT CALayerParams {
21 CALayerParams();
22 CALayerParams(CALayerParams&& params);
23 CALayerParams(const CALayerParams& params);
24 CALayerParams& operator=(CALayerParams&& params);
25 CALayerParams& operator=(const CALayerParams& params);
26 ~CALayerParams();
27
Scott Violet30987792022-04-13 19:57:2028 bool operator==(const CALayerParams& params) const {
29 return is_empty == params.is_empty &&
30 ca_context_id == params.ca_context_id &&
31#if BUILDFLAG(IS_MAC)
32 io_surface_mach_port == params.io_surface_mach_port &&
33#endif
34 pixel_size == params.pixel_size &&
35 scale_factor == params.scale_factor;
36 }
37
Christopher Cameron4bc282bb2017-12-03 11:24:0538 // The |is_empty| flag is used to short-circuit code to handle CALayerParams
39 // on non-macOS platforms.
Christopher Cameronb7158c72017-12-06 06:13:3840 bool is_empty = true;
41
Christopher Cameron4bc282bb2017-12-03 11:24:0542 // Can be used to instantiate a CALayerTreeHost in the browser process, which
43 // will display a CALayerTree rooted in the GPU process. This is non-zero when
44 // using remote CoreAnimation.
45 uint32_t ca_context_id = 0;
Christopher Cameronb7158c72017-12-06 06:13:3846
Christopher Cameron4bc282bb2017-12-03 11:24:0547 // Used to set the contents of a CALayer in the browser to an IOSurface that
48 // is specified by the GPU process. This is non-null iff |ca_context_id| is
49 // zero.
Xiaohan Wangd1b0e6b2022-01-20 21:40:2050#if BUILDFLAG(IS_MAC)
Christopher Cameron4bc282bb2017-12-03 11:24:0551 gfx::ScopedRefCountedIOSurfaceMachPort io_surface_mach_port;
Christopher Cameronb7158c72017-12-06 06:13:3852#endif
53
54 // The geometry of the frame.
Christopher Cameron4bc282bb2017-12-03 11:24:0555 gfx::Size pixel_size;
56 float scale_factor = 1.f;
Christopher Cameron4bc282bb2017-12-03 11:24:0557};
58
59} // namespace gfx
60
61#endif // UI_GFX_CA_LAYER_PARAMS_H_