• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 #include "TransformCanvas.h"
17 #include "HolePunch.h"
18 #include "SkData.h"
19 #include "SkDrawable.h"
20 
21 using namespace android::uirenderer::skiapipeline;
22 
onDrawAnnotation(const SkRect & rect,const char * key,SkData * value)23 void TransformCanvas::onDrawAnnotation(const SkRect& rect, const char* key, SkData* value) {
24     if (HOLE_PUNCH_ANNOTATION == key) {
25         auto* rectParams = reinterpret_cast<const float*>(value->data());
26         float radiusX = rectParams[0];
27         float radiusY = rectParams[1];
28         SkRRect roundRect = SkRRect::MakeRectXY(rect, radiusX, radiusY);
29 
30         SkPaint paint;
31         paint.setColor(SkColors::kBlack);
32         paint.setBlendMode(mHolePunchBlendMode);
33         mWrappedCanvas->drawRRect(roundRect, paint);
34     }
35 }
36 
onDrawDrawable(SkDrawable * drawable,const SkMatrix * matrix)37 void TransformCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
38     drawable->draw(this, matrix);
39 }
40 
onFilter(SkPaint & paint) const41 bool TransformCanvas::onFilter(SkPaint& paint) const {
42     return false;
43 }
44