• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <ui/FatVector.h>
17 #include "SkPoint.h"
18 #include "SkRefCnt.h"
19 
20 /**
21  * Collection of points that are ref counted and to be used with
22  * various drawing calls that consume SkPoint as inputs like
23  * drawLines/drawPoints
24  */
25 class Points: public SkNVRefCnt<SkPoint> {
26 public:
Points(int size)27   Points(int size){
28       skPoints.resize(size);
29   }
30 
Points(std::initializer_list<SkPoint> init)31   Points(std::initializer_list<SkPoint> init): skPoints(init) { }
32 
33   SkPoint& operator[](int index) {
34       return skPoints[index];
35   }
36 
data()37   const SkPoint* data() const {
38       return skPoints.data();
39   }
40 
size()41   size_t size() const {
42       return skPoints.size();
43   }
44 private:
45   // Initialize the size to contain 2 SkPoints on the stack for optimized
46   // drawLine calls that require 2 SkPoints for start/end points of the line
47   android::FatVector<SkPoint, 2> skPoints;
48 };
49