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