1 /*
2  * Copyright (C) 2023 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.google.android.wallpaper.weathereffects.graphics.none
18 
19 import android.graphics.Bitmap
20 import android.graphics.Canvas
21 import android.util.SizeF
22 import com.google.android.wallpaper.weathereffects.graphics.WeatherEffect
23 import com.google.android.wallpaper.weathereffects.graphics.utils.MatrixUtils
24 
25 /** Simply draws foreground and background images with no weather effect. */
26 class NoEffect(val foreground: Bitmap, val background: Bitmap, private var surfaceSize: SizeF) :
27     WeatherEffect {
resizenull28     override fun resize(newSurfaceSize: SizeF) {
29         surfaceSize = newSurfaceSize
30     }
31 
updatenull32     override fun update(deltaMillis: Long, frameTimeNanos: Long) {}
33 
drawnull34     override fun draw(canvas: Canvas) {
35         canvas.drawBitmap(
36             background,
37             MatrixUtils.centerCropMatrix(
38                 surfaceSize,
39                 SizeF(background.width.toFloat(), background.height.toFloat())
40             ),
41             null
42         )
43 
44         canvas.drawBitmap(
45             foreground,
46             MatrixUtils.centerCropMatrix(
47                 surfaceSize,
48                 SizeF(foreground.width.toFloat(), foreground.height.toFloat())
49             ),
50             null
51         )
52     }
53 
resetnull54     override fun reset() {}
55 
releasenull56     override fun release() {}
57 
setIntensitynull58     override fun setIntensity(intensity: Float) {}
59 }
60