Home | History | Annotate | Download | only in renderthread
      1 /*
      2  * Copyright (C) 2016 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 #pragma once
     18 
     19 #include "DamageAccumulator.h"
     20 #include "FrameInfoVisualizer.h"
     21 #include "LayerUpdateQueue.h"
     22 #include "Lighting.h"
     23 #include "SwapBehavior.h"
     24 #include "hwui/Bitmap.h"
     25 
     26 #include <SkRect.h>
     27 #include <utils/RefBase.h>
     28 
     29 class GrContext;
     30 
     31 struct ANativeWindow;
     32 
     33 namespace android {
     34 
     35 namespace uirenderer {
     36 
     37 class DeferredLayerUpdater;
     38 class ErrorHandler;
     39 class TaskManager;
     40 
     41 namespace renderthread {
     42 
     43 enum class MakeCurrentResult { AlreadyCurrent, Failed, Succeeded };
     44 
     45 enum class ColorMode {
     46     // SRGB means HWUI will produce buffer in SRGB color space.
     47     SRGB,
     48     // WideColorGamut means HWUI would support rendering scRGB non-linear into
     49     // a signed buffer with enough range to support the wide color gamut of the
     50     // display.
     51     WideColorGamut,
     52     // Hdr
     53 };
     54 
     55 class Frame;
     56 
     57 class IRenderPipeline {
     58 public:
     59     virtual MakeCurrentResult makeCurrent() = 0;
     60     virtual Frame getFrame() = 0;
     61     virtual bool draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
     62                       const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
     63                       const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo,
     64                       const std::vector<sp<RenderNode>>& renderNodes,
     65                       FrameInfoVisualizer* profiler) = 0;
     66     virtual bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty,
     67                              FrameInfo* currentFrameInfo, bool* requireSwap) = 0;
     68     virtual DeferredLayerUpdater* createTextureLayer() = 0;
     69     virtual bool setSurface(ANativeWindow* window, SwapBehavior swapBehavior, ColorMode colorMode,
     70                             uint32_t extraBuffers) = 0;
     71     virtual void onStop() = 0;
     72     virtual bool isSurfaceReady() = 0;
     73     virtual bool isContextReady() = 0;
     74     virtual void onDestroyHardwareResources() = 0;
     75     virtual void renderLayers(const LightGeometry& lightGeometry,
     76                               LayerUpdateQueue* layerUpdateQueue, bool opaque,
     77                               const LightInfo& lightInfo) = 0;
     78     virtual bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator,
     79                                      ErrorHandler* errorHandler) = 0;
     80     virtual bool pinImages(std::vector<SkImage*>& mutableImages) = 0;
     81     virtual bool pinImages(LsaVector<sk_sp<Bitmap>>& images) = 0;
     82     virtual void unpinImages() = 0;
     83     virtual void onPrepareTree() = 0;
     84     virtual SkColorType getSurfaceColorType() const = 0;
     85     virtual sk_sp<SkColorSpace> getSurfaceColorSpace() = 0;
     86     virtual GrSurfaceOrigin getSurfaceOrigin() = 0;
     87     virtual void setPictureCapturedCallback(
     88             const std::function<void(sk_sp<SkPicture>&&)>& callback) = 0;
     89 
     90     virtual ~IRenderPipeline() {}
     91 };
     92 
     93 } /* namespace renderthread */
     94 } /* namespace uirenderer */
     95 } /* namespace android */
     96