blob: 0093c38cf8a8f5a40cd765ad1b98819758d371bb [file] [log] [blame]
John Reck013127b2020-10-29 20:53:51 -04001/*
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
27namespace android::uirenderer {
28
29void 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
John Reck90b0a1c2020-11-12 12:37:30 -050035 source.for_each([&]<CanvasOpType T>(const CanvasOpContainer<T> * op) {
Nader Jawad55f19762020-11-25 15:30:20 -080036 if constexpr (
37 T == CanvasOpType::BeginZ ||
38 T == CanvasOpType::EndZ ||
39 T == CanvasOpType::DrawLayer
40 ) {
John Reck013127b2020-10-29 20:53:51 -040041 // Do beginZ or endZ
42 LOG_ALWAYS_FATAL("TODO");
43 return;
44 } else {
45 // Generic OP
46 // First apply the current transformation
47 destination->setMatrix(SkMatrix::Concat(currentGlobalTransform, op->transform()));
48 // Now draw it
49 (*op)->draw(destination);
50 }
51 });
52}
53
54} // namespace android::uirenderer