Christopher Cameron | 4bc282bb | 2017-12-03 11:24:05 | [diff] [blame] | 1 | // 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 Cameron | b7158c7 | 2017-12-06 06:13:38 | [diff] [blame] | 9 | #include "ui/gfx/geometry/size.h" |
Christopher Cameron | 4bc282bb | 2017-12-03 11:24:05 | [diff] [blame] | 10 | #include "ui/gfx/gfx_export.h" |
| 11 | |
Xiaohan Wang | d1b0e6b | 2022-01-20 21:40:20 | [diff] [blame] | 12 | #if BUILDFLAG(IS_MAC) |
Christopher Cameron | 4bc282bb | 2017-12-03 11:24:05 | [diff] [blame] | 13 | #include "ui/gfx/mac/io_surface.h" |
| 14 | #endif |
| 15 | |
| 16 | namespace gfx { |
| 17 | |
| 18 | // The parameters required to add a composited frame to a CALayer. This |
| 19 | // is used only on macOS. |
| 20 | struct 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 Violet | 3098779 | 2022-04-13 19:57:20 | [diff] [blame] | 28 | 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 Cameron | 4bc282bb | 2017-12-03 11:24:05 | [diff] [blame] | 38 | // The |is_empty| flag is used to short-circuit code to handle CALayerParams |
| 39 | // on non-macOS platforms. |
Christopher Cameron | b7158c7 | 2017-12-06 06:13:38 | [diff] [blame] | 40 | bool is_empty = true; |
| 41 | |
Christopher Cameron | 4bc282bb | 2017-12-03 11:24:05 | [diff] [blame] | 42 | // 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 Cameron | b7158c7 | 2017-12-06 06:13:38 | [diff] [blame] | 46 | |
Christopher Cameron | 4bc282bb | 2017-12-03 11:24:05 | [diff] [blame] | 47 | // 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 Wang | d1b0e6b | 2022-01-20 21:40:20 | [diff] [blame] | 50 | #if BUILDFLAG(IS_MAC) |
Christopher Cameron | 4bc282bb | 2017-12-03 11:24:05 | [diff] [blame] | 51 | gfx::ScopedRefCountedIOSurfaceMachPort io_surface_mach_port; |
Christopher Cameron | b7158c7 | 2017-12-06 06:13:38 | [diff] [blame] | 52 | #endif |
| 53 | |
| 54 | // The geometry of the frame. |
Christopher Cameron | 4bc282bb | 2017-12-03 11:24:05 | [diff] [blame] | 55 | gfx::Size pixel_size; |
| 56 | float scale_factor = 1.f; |
Christopher Cameron | 4bc282bb | 2017-12-03 11:24:05 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | } // namespace gfx |
| 60 | |
| 61 | #endif // UI_GFX_CA_LAYER_PARAMS_H_ |