1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.wallpaper.picker.preview.shared.model
18 
19 import android.graphics.Point
20 import android.graphics.Rect
21 
22 /**
23  * Data class represents user's cropHint for a dimension.
24  *
25  * It could be one of below:
26  * 1. A current wallpaper crop.
27  * 2. User's crop via full preview.
28  * 3. Default crop from small preview.
29  *
30  * Only #2 will it contains [cropSizeModel], the other cases parallax (0 for #3) has already
31  * included in [cropHint].
32  */
33 data class FullPreviewCropModel(
34     /** The user's crop of wallpaper based on the full wallpaper size. */
35     val cropHint: Rect,
36     /** The data required to compute parallax for this crop, null for no parallax. */
37     val cropSizeModel: CropSizeModel?,
38 )
39 
40 /** Required for computing parallax. */
41 data class CropSizeModel(
42     /** The zoom of the wallpaper on its hosting view when user selects the cropHint. */
43     val wallpaperZoom: Float,
44     /** The size of the view hosting the wallpaper, e.g. SurfaceView. */
45     val hostViewSize: Point,
46     /** A larger version of hostViewSize that can safely contain parallax. */
47     val cropViewSize: Point,
48 )
49