OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkDevice.h" | 8 #include "SkDevice.h" |
9 #include "SkDraw.h" | |
9 #include "SkMetaData.h" | 10 #include "SkMetaData.h" |
10 | 11 |
11 SkBaseDevice::SkBaseDevice() | 12 SkBaseDevice::SkBaseDevice() |
12 : fLeakyProperties(SkDeviceProperties::MakeDefault()) | 13 : fLeakyProperties(SkDeviceProperties::MakeDefault()) |
13 #ifdef SK_DEBUG | 14 #ifdef SK_DEBUG |
14 , fAttachedToCanvas(false) | 15 , fAttachedToCanvas(false) |
15 #endif | 16 #endif |
16 { | 17 { |
17 fOrigin.setZero(); | 18 fOrigin.setZero(); |
18 fMetaData = NULL; | 19 fMetaData = NULL; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 SkPath path; | 71 SkPath path; |
71 path.addRRect(outer); | 72 path.addRRect(outer); |
72 path.addRRect(inner); | 73 path.addRRect(inner); |
73 path.setFillType(SkPath::kEvenOdd_FillType); | 74 path.setFillType(SkPath::kEvenOdd_FillType); |
74 | 75 |
75 const SkMatrix* preMatrix = NULL; | 76 const SkMatrix* preMatrix = NULL; |
76 const bool pathIsMutable = true; | 77 const bool pathIsMutable = true; |
77 this->drawPath(draw, path, paint, preMatrix, pathIsMutable); | 78 this->drawPath(draw, path, paint, preMatrix, pathIsMutable); |
78 } | 79 } |
79 | 80 |
81 void SkBaseDevice::drawPatch(const SkDraw& draw, const SkPatch& patch, const SkP aint& paint) { | |
82 SkPatch::VertexData data; | |
83 | |
84 SkPoint corners[4]; | |
85 patch.getCornerPoints(corners); | |
86 draw.fMatrix->mapPoints(corners, 4); | |
87 | |
88 // size in pixels of each partition per axis, adjust this knob | |
89 int partitionSize = 25; | |
bsalomon
2014/07/31 17:39:06
static const int kPartitionSize?
dandov
2014/07/31 21:35:40
Done.
| |
90 | |
91 // level of detail per axis, based on the larger side between top and bottom or left and right | |
92 int lodX = SkMaxScalar(SkScalarAbs(corners[0].x() - corners[1].x()), | |
bsalomon
2014/07/31 17:39:06
Doesn't this need to be
SkScalarSqrt(SkMaxScalar(
dandov
2014/07/31 21:35:40
Completed using an approximate arc length based on
| |
93 SkScalarAbs(corners[3].x() - corners[2].x())) / part itionSize; | |
94 int lodY = SkMaxScalar(SkScalarAbs(corners[0].y() - corners[3].y()), | |
95 SkScalarAbs(corners[1].y() - corners[2].y())) / part itionSize; | |
96 | |
97 // It automatically adjusts lodX and lodY in case it exceeds the number of i ndices. | |
98 patch.getVertexData(&data, SkMax32(2, lodX), SkMax32(2, lodY)); | |
99 this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCount, data.fPoints, | |
100 data.fTexCoords, data.fColors, NULL, data.fIndices, data. fIndexCount, paint); | |
101 } | |
102 | |
80 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt es, int x, int y) { | 103 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt es, int x, int y) { |
81 #ifdef SK_DEBUG | 104 #ifdef SK_DEBUG |
82 SkASSERT(info.width() > 0 && info.height() > 0); | 105 SkASSERT(info.width() > 0 && info.height() > 0); |
83 SkASSERT(dstP); | 106 SkASSERT(dstP); |
84 SkASSERT(rowBytes >= info.minRowBytes()); | 107 SkASSERT(rowBytes >= info.minRowBytes()); |
85 SkASSERT(x >= 0 && y >= 0); | 108 SkASSERT(x >= 0 && y >= 0); |
86 | 109 |
87 const SkImageInfo& srcInfo = this->imageInfo(); | 110 const SkImageInfo& srcInfo = this->imageInfo(); |
88 SkASSERT(x + info.width() <= srcInfo.width()); | 111 SkASSERT(x + info.width() <= srcInfo.width()); |
89 SkASSERT(y + info.height() <= srcInfo.height()); | 112 SkASSERT(y + info.height() <= srcInfo.height()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 } | 154 } |
132 | 155 |
133 void SkBaseDevice::EXPERIMENTAL_optimize(const SkPicture* picture) { | 156 void SkBaseDevice::EXPERIMENTAL_optimize(const SkPicture* picture) { |
134 // The base class doesn't perform any analysis but derived classes may | 157 // The base class doesn't perform any analysis but derived classes may |
135 } | 158 } |
136 | 159 |
137 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* p icture) { | 160 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* p icture) { |
138 // The base class doesn't perform any accelerated picture rendering | 161 // The base class doesn't perform any accelerated picture rendering |
139 return false; | 162 return false; |
140 } | 163 } |
OLD | NEW |