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