John Reck | 013127b | 2020-10-29 20:53:51 -0400 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2020 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 | #include "CanvasOpRasterizer.h" |
| 18 | |
| 19 | #include <SkCanvas.h> |
| 20 | #include <log/log.h> |
| 21 | |
| 22 | #include <vector> |
| 23 | |
| 24 | #include "CanvasOpBuffer.h" |
| 25 | #include "CanvasOps.h" |
| 26 | |
| 27 | namespace android::uirenderer { |
| 28 | |
| 29 | void rasterizeCanvasBuffer(const CanvasOpBuffer& source, SkCanvas* destination) { |
| 30 | // Tracks the global transform from the current display list back toward the display space |
| 31 | // Push on beginning a RenderNode draw, pop on ending one |
| 32 | std::vector<SkMatrix> globalMatrixStack; |
| 33 | SkMatrix& currentGlobalTransform = globalMatrixStack.emplace_back(SkMatrix::I()); |
| 34 | |
| 35 | source.for_each([&]<CanvasOpType T>(CanvasOpContainer<T> * op) { |
| 36 | if constexpr (T == CanvasOpType::BeginZ || T == CanvasOpType::EndZ) { |
| 37 | // Do beginZ or endZ |
| 38 | LOG_ALWAYS_FATAL("TODO"); |
| 39 | return; |
| 40 | } else { |
| 41 | // Generic OP |
| 42 | // First apply the current transformation |
| 43 | destination->setMatrix(SkMatrix::Concat(currentGlobalTransform, op->transform())); |
| 44 | // Now draw it |
| 45 | (*op)->draw(destination); |
| 46 | } |
| 47 | }); |
| 48 | } |
| 49 | |
| 50 | } // namespace android::uirenderer |