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 "RenderNodeDrawable.h" 20 21 #include <SkCanvas.h> 22 #include <SkDrawable.h> 23 #include <utils/FatVector.h> 24 25 namespace android { 26 namespace uirenderer { 27 namespace skiapipeline { 28 29 class SkiaDisplayList; 30 class EndReorderBarrierDrawable; 31 32 /** 33 * StartReorderBarrierDrawable and EndReorderBarrierDrawable work together to define 34 * a sub-list in a display list that need to be drawn out-of-order sorted instead by render 35 * node Z index. 36 * StartReorderBarrierDrawable will sort the entire range and it will draw 37 * render nodes in the range with negative Z index. 38 */ 39 class StartReorderBarrierDrawable : public SkDrawable { 40 public: 41 explicit StartReorderBarrierDrawable(SkiaDisplayList* data); 42 43 protected: 44 virtual SkRect onGetBounds() override { return SkRect::MakeLargest(); } 45 virtual void onDraw(SkCanvas* canvas) override; 46 47 private: 48 int mEndChildIndex; 49 int mBeginChildIndex; 50 FatVector<RenderNodeDrawable*, 16> mChildren; 51 SkiaDisplayList* mDisplayList; 52 53 friend class EndReorderBarrierDrawable; 54 }; 55 56 /** 57 * See StartReorderBarrierDrawable. 58 * EndReorderBarrierDrawable relies on StartReorderBarrierDrawable to host and sort the render 59 * nodes by Z index. When EndReorderBarrierDrawable is drawn it will draw all render nodes in the 60 * range with positive Z index. It is also responsible for drawing shadows for the nodes 61 * corresponding to their z-index. 62 */ 63 class EndReorderBarrierDrawable : public SkDrawable { 64 public: 65 explicit EndReorderBarrierDrawable(StartReorderBarrierDrawable* startBarrier); 66 67 protected: 68 virtual SkRect onGetBounds() override { return SkRect::MakeLargest(); } 69 virtual void onDraw(SkCanvas* canvas) override; 70 71 private: 72 void drawShadow(SkCanvas* canvas, RenderNodeDrawable* caster); 73 StartReorderBarrierDrawable* mStartBarrier; 74 }; 75 76 }; // namespace skiapipeline 77 }; // namespace uirenderer 78 }; // namespace android 79