| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkRecorder.h" | 8 #include "SkRecorder.h" |
| 9 #include "SkPicture.h" | 9 #include "SkPicture.h" |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 T* SkRecorder::copy(const T* src) { | 50 T* SkRecorder::copy(const T* src) { |
| 51 if (NULL == src) { | 51 if (NULL == src) { |
| 52 return NULL; | 52 return NULL; |
| 53 } | 53 } |
| 54 return SkNEW_PLACEMENT_ARGS(fRecord->alloc<T>(), T, (*src)); | 54 return SkNEW_PLACEMENT_ARGS(fRecord->alloc<T>(), T, (*src)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 // This copy() is for arrays. | 57 // This copy() is for arrays. |
| 58 // It will work with POD or non-POD, though currently we only use it for POD. | 58 // It will work with POD or non-POD, though currently we only use it for POD. |
| 59 template <typename T> | 59 template <typename T> |
| 60 T* SkRecorder::copy(const T src[], unsigned count) { | 60 T* SkRecorder::copy(const T src[], size_t count) { |
| 61 if (NULL == src) { | 61 if (NULL == src) { |
| 62 return NULL; | 62 return NULL; |
| 63 } | 63 } |
| 64 T* dst = fRecord->alloc<T>(count); | 64 T* dst = fRecord->alloc<T>(count); |
| 65 for (unsigned i = 0; i < count; i++) { | 65 for (size_t i = 0; i < count; i++) { |
| 66 SkNEW_PLACEMENT_ARGS(dst + i, T, (src[i])); | 66 SkNEW_PLACEMENT_ARGS(dst + i, T, (src[i])); |
| 67 } | 67 } |
| 68 return dst; | 68 return dst; |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Specialization for copying strings, using memcpy. | 71 // Specialization for copying strings, using memcpy. |
| 72 // This measured around 2x faster for copying code points, | 72 // This measured around 2x faster for copying code points, |
| 73 // but I found no corresponding speedup for other arrays. | 73 // but I found no corresponding speedup for other arrays. |
| 74 template <> | 74 template <> |
| 75 char* SkRecorder::copy(const char src[], unsigned count) { | 75 char* SkRecorder::copy(const char src[], size_t count) { |
| 76 if (NULL == src) { | 76 if (NULL == src) { |
| 77 return NULL; | 77 return NULL; |
| 78 } | 78 } |
| 79 char* dst = fRecord->alloc<char>(count); | 79 char* dst = fRecord->alloc<char>(count); |
| 80 memcpy(dst, src, count); | 80 memcpy(dst, src, count); |
| 81 return dst; | 81 return dst; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void SkRecorder::clear(SkColor color) { | 84 void SkRecorder::clear(SkColor color) { |
| 85 APPEND(Clear, color); | 85 APPEND(Clear, color); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 const SkMatrix* matrix, const SkPaint& paint)
{ | 180 const SkMatrix* matrix, const SkPaint& paint)
{ |
| 181 APPEND(DrawTextOnPath, | 181 APPEND(DrawTextOnPath, |
| 182 delay_copy(paint), | 182 delay_copy(paint), |
| 183 this->copy((const char*)text, byteLength), | 183 this->copy((const char*)text, byteLength), |
| 184 byteLength, | 184 byteLength, |
| 185 delay_copy(path), | 185 delay_copy(path), |
| 186 this->copy(matrix)); | 186 this->copy(matrix)); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void SkRecorder::onDrawPicture(const SkPicture* picture) { | 189 void SkRecorder::onDrawPicture(const SkPicture* picture) { |
| 190 picture->draw(this); | 190 APPEND(DrawPicture, picture); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void SkRecorder::drawVertices(VertexMode vmode, | 193 void SkRecorder::drawVertices(VertexMode vmode, |
| 194 int vertexCount, const SkPoint vertices[], | 194 int vertexCount, const SkPoint vertices[], |
| 195 const SkPoint texs[], const SkColor colors[], | 195 const SkPoint texs[], const SkColor colors[], |
| 196 SkXfermode* xmode, | 196 SkXfermode* xmode, |
| 197 const uint16_t indices[], int indexCount, const Sk
Paint& paint) { | 197 const uint16_t indices[], int indexCount, const Sk
Paint& paint) { |
| 198 APPEND(DrawVertices, delay_copy(paint), | 198 APPEND(DrawVertices, delay_copy(paint), |
| 199 vmode, | 199 vmode, |
| 200 vertexCount, | 200 vertexCount, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 258 |
| 259 void SkRecorder::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e
dgeStyle) { | 259 void SkRecorder::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e
dgeStyle) { |
| 260 APPEND(ClipPath, delay_copy(path), op, edgeStyle == kSoft_ClipEdgeStyle); | 260 APPEND(ClipPath, delay_copy(path), op, edgeStyle == kSoft_ClipEdgeStyle); |
| 261 INHERITED(updateClipConservativelyUsingBounds, path.getBounds(), op, path.is
InverseFillType()); | 261 INHERITED(updateClipConservativelyUsingBounds, path.getBounds(), op, path.is
InverseFillType()); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { | 264 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { |
| 265 APPEND(ClipRegion, delay_copy(deviceRgn), op); | 265 APPEND(ClipRegion, delay_copy(deviceRgn), op); |
| 266 INHERITED(onClipRegion, deviceRgn, op); | 266 INHERITED(onClipRegion, deviceRgn, op); |
| 267 } | 267 } |
| OLD | NEW |