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 "BakedOpDispatcher.h" 20 #include "BakedOpRenderer.h" 21 #include "CanvasContext.h" 22 #include "FrameBuilder.h" 23 #include "IRenderPipeline.h" 24 25 namespace android { 26 namespace uirenderer { 27 namespace renderthread { 28 29 class OpenGLPipeline : public IRenderPipeline { 30 public: 31 OpenGLPipeline(RenderThread& thread); ~OpenGLPipeline()32 virtual ~OpenGLPipeline() {} 33 34 MakeCurrentResult makeCurrent() override; 35 Frame getFrame() override; 36 bool draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty, 37 const FrameBuilder::LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue, 38 const Rect& contentDrawBounds, bool opaque, bool wideColorGamut, 39 const BakedOpRenderer::LightInfo& lightInfo, 40 const std::vector<sp<RenderNode>>& renderNodes, 41 FrameInfoVisualizer* profiler) override; 42 bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty, 43 FrameInfo* currentFrameInfo, bool* requireSwap) override; 44 bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) override; 45 DeferredLayerUpdater* createTextureLayer() override; 46 bool setSurface(Surface* window, SwapBehavior swapBehavior, ColorMode colorMode) override; 47 void onStop() override; 48 bool isSurfaceReady() override; 49 bool isContextReady() override; 50 void onDestroyHardwareResources() override; 51 void renderLayers(const FrameBuilder::LightGeometry& lightGeometry, 52 LayerUpdateQueue* layerUpdateQueue, bool opaque, bool wideColorGamut, 53 const BakedOpRenderer::LightInfo& lightInfo) override; 54 TaskManager* getTaskManager() override; 55 bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator, 56 bool wideColorGamut, ErrorHandler* errorHandler) override; pinImages(std::vector<SkImage * > & mutableImages)57 bool pinImages(std::vector<SkImage*>& mutableImages) override { return false; } 58 bool pinImages(LsaVector<sk_sp<Bitmap>>& images) override; 59 void unpinImages() override; onPrepareTree()60 void onPrepareTree() override {} 61 static void destroyLayer(RenderNode* node); 62 static void prepareToDraw(const RenderThread& thread, Bitmap* bitmap); 63 static void invokeFunctor(const RenderThread& thread, Functor* functor); 64 static sk_sp<Bitmap> allocateHardwareBitmap(RenderThread& thread, SkBitmap& skBitmap); 65 66 private: 67 EglManager& mEglManager; 68 EGLSurface mEglSurface = EGL_NO_SURFACE; 69 bool mBufferPreserved = false; 70 RenderThread& mRenderThread; 71 }; 72 73 } /* namespace renderthread */ 74 } /* namespace uirenderer */ 75 } /* namespace android */ 76