Ahan Wu | fa42c51 | 2019-05-15 19:52:51 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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.systemui.glwallpaper; |
| 18 | |
| 19 | import android.util.Size; |
Ahan Wu | fa42c51 | 2019-05-15 19:52:51 +0800 | [diff] [blame] | 20 | |
Ahan Wu | 7688424 | 2019-05-22 20:04:23 +0800 | [diff] [blame] | 21 | import java.io.FileDescriptor; |
| 22 | import java.io.PrintWriter; |
| 23 | |
Ahan Wu | fa42c51 | 2019-05-15 19:52:51 +0800 | [diff] [blame] | 24 | /** |
| 25 | * A renderer which is responsible for making OpenGL calls to render a frame. |
| 26 | */ |
| 27 | public interface GLWallpaperRenderer { |
| 28 | |
| 29 | /** |
Ahan Wu | 287d828 | 2019-12-17 16:23:17 +0800 | [diff] [blame] | 30 | * Check if the content to render is a WCG content. |
| 31 | */ |
| 32 | boolean isWcgContent(); |
| 33 | |
| 34 | /** |
Ahan Wu | fa42c51 | 2019-05-15 19:52:51 +0800 | [diff] [blame] | 35 | * Called when the surface is created or recreated. |
| 36 | */ |
| 37 | void onSurfaceCreated(); |
| 38 | |
| 39 | /** |
| 40 | * Called when the surface changed size. |
| 41 | * @param width surface width. |
| 42 | * @param height surface height. |
| 43 | */ |
| 44 | void onSurfaceChanged(int width, int height); |
| 45 | |
| 46 | /** |
| 47 | * Called to draw the current frame. |
| 48 | */ |
| 49 | void onDrawFrame(); |
| 50 | |
| 51 | /** |
| 52 | * Notify ambient mode is changed. |
| 53 | * @param inAmbientMode true if in ambient mode. |
| 54 | * @param duration duration of transition. |
| 55 | */ |
| 56 | void updateAmbientMode(boolean inAmbientMode, long duration); |
| 57 | |
| 58 | /** |
Ahan Wu | e16e1fa | 2019-05-29 18:39:33 +0800 | [diff] [blame] | 59 | * Notify the wallpaper offsets changed. |
| 60 | * @param xOffset offset along x axis. |
| 61 | * @param yOffset offset along y axis. |
| 62 | */ |
| 63 | void updateOffsets(float xOffset, float yOffset); |
| 64 | |
| 65 | /** |
Ahan Wu | fa42c51 | 2019-05-15 19:52:51 +0800 | [diff] [blame] | 66 | * Ask renderer to report the surface size it needs. |
| 67 | */ |
| 68 | Size reportSurfaceSize(); |
| 69 | |
| 70 | /** |
| 71 | * Called when no need to render any more. |
| 72 | */ |
| 73 | void finish(); |
| 74 | |
| 75 | /** |
Ahan Wu | 7688424 | 2019-05-22 20:04:23 +0800 | [diff] [blame] | 76 | * Called to dump current state. |
| 77 | * @param prefix prefix. |
| 78 | * @param fd fd. |
| 79 | * @param out out. |
| 80 | * @param args args. |
| 81 | */ |
| 82 | void dump(String prefix, FileDescriptor fd, PrintWriter out, String[] args); |
| 83 | |
| 84 | /** |
Ahan Wu | fa42c51 | 2019-05-15 19:52:51 +0800 | [diff] [blame] | 85 | * A proxy which owns surface holder. |
| 86 | */ |
| 87 | interface SurfaceProxy { |
| 88 | |
| 89 | /** |
Ahan Wu | fa42c51 | 2019-05-15 19:52:51 +0800 | [diff] [blame] | 90 | * Ask proxy to start rendering frame to surface. |
| 91 | */ |
| 92 | void requestRender(); |
| 93 | |
| 94 | /** |
| 95 | * Ask proxy to prepare render context. |
| 96 | */ |
| 97 | void preRender(); |
| 98 | |
| 99 | /** |
| 100 | * Ask proxy to destroy render context. |
| 101 | */ |
| 102 | void postRender(); |
| 103 | } |
| 104 | } |