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 "FrameInfoVisualizer.h"
     20 #include "SwapBehavior.h"
     21 
     22 #include <SkRect.h>
     23 #include <utils/RefBase.h>
     24 
     25 class GrContext;
     26 
     27 namespace android {
     28 
     29 class Surface;
     30 
     31 namespace uirenderer {
     32 
     33 class DeferredLayerUpdater;
     34 class ErrorHandler;
     35 
     36 namespace renderthread {
     37 
     38 enum class MakeCurrentResult { AlreadyCurrent, Failed, Succeeded };
     39 
     40 enum class ColorMode {
     41     Srgb,
     42     WideColorGamut,
     43     // Hdr
     44 };
     45 
     46 class Frame;
     47 
     48 class IRenderPipeline {
     49 public:
     50     virtual MakeCurrentResult makeCurrent() = 0;
     51     virtual Frame getFrame() = 0;
     52     virtual bool draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
     53                       const FrameBuilder::LightGeometry& lightGeometry,
     54                       LayerUpdateQueue* layerUpdateQueue, const Rect& contentDrawBounds,
     55                       bool opaque, bool wideColorGamut, const BakedOpRenderer::LightInfo& lightInfo,
     56                       const std::vector<sp<RenderNode>>& renderNodes,
     57                       FrameInfoVisualizer* profiler) = 0;
     58     virtual bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty,
     59                              FrameInfo* currentFrameInfo, bool* requireSwap) = 0;
     60     virtual bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) = 0;
     61     virtual DeferredLayerUpdater* createTextureLayer() = 0;
     62     virtual bool setSurface(Surface* window, SwapBehavior swapBehavior, ColorMode colorMode) = 0;
     63     virtual void onStop() = 0;
     64     virtual bool isSurfaceReady() = 0;
     65     virtual bool isContextReady() = 0;
     66     virtual void onDestroyHardwareResources() = 0;
     67     virtual void renderLayers(const FrameBuilder::LightGeometry& lightGeometry,
     68                               LayerUpdateQueue* layerUpdateQueue, bool opaque, bool wideColorGamut,
     69                               const BakedOpRenderer::LightInfo& lightInfo) = 0;
     70     virtual TaskManager* getTaskManager() = 0;
     71     virtual bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator,
     72                                      bool wideColorGamut, ErrorHandler* errorHandler) = 0;
     73     virtual bool pinImages(std::vector<SkImage*>& mutableImages) = 0;
     74     virtual bool pinImages(LsaVector<sk_sp<Bitmap>>& images) = 0;
     75     virtual void unpinImages() = 0;
     76     virtual void onPrepareTree() = 0;
     77 
     78     virtual ~IRenderPipeline() {}
     79 };
     80 
     81 } /* namespace renderthread */
     82 } /* namespace uirenderer */
     83 } /* namespace android */
     84