OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkAnnotation.h" | 9 #include "SkAnnotation.h" |
10 #include "SkBitmapHeap.h" | 10 #include "SkBitmapHeap.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkColorFilter.h" | 12 #include "SkColorFilter.h" |
13 #include "SkData.h" | 13 #include "SkData.h" |
14 #include "SkDrawLooper.h" | 14 #include "SkDrawLooper.h" |
15 #include "SkGPipe.h" | 15 #include "SkGPipe.h" |
16 #include "SkGPipePriv.h" | 16 #include "SkGPipePriv.h" |
17 #include "SkImageFilter.h" | 17 #include "SkImageFilter.h" |
18 #include "SkMaskFilter.h" | 18 #include "SkMaskFilter.h" |
19 #include "SkRSXform.h" | |
19 #include "SkWriteBuffer.h" | 20 #include "SkWriteBuffer.h" |
20 #include "SkPaint.h" | 21 #include "SkPaint.h" |
21 #include "SkPatchUtils.h" | 22 #include "SkPatchUtils.h" |
22 #include "SkPathEffect.h" | 23 #include "SkPathEffect.h" |
23 #include "SkPictureFlat.h" | 24 #include "SkPictureFlat.h" |
24 #include "SkPtrRecorder.h" | 25 #include "SkPtrRecorder.h" |
25 #include "SkRasterizer.h" | 26 #include "SkRasterizer.h" |
26 #include "SkRRect.h" | 27 #include "SkRRect.h" |
27 #include "SkShader.h" | 28 #include "SkShader.h" |
28 #include "SkStream.h" | 29 #include "SkStream.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, | 281 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, |
281 const SkPaint*) override; | 282 const SkPaint*) override; |
282 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, | 283 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, |
283 const SkPaint*) override; | 284 const SkPaint*) override; |
284 void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) overri de; | 285 void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*) overri de; |
285 void onDrawVertices(VertexMode vmode, int vertexCount, | 286 void onDrawVertices(VertexMode vmode, int vertexCount, |
286 const SkPoint vertices[], const SkPoint texs[], | 287 const SkPoint vertices[], const SkPoint texs[], |
287 const SkColor colors[], SkXfermode* xmode, | 288 const SkColor colors[], SkXfermode* xmode, |
288 const uint16_t indices[], int indexCount, | 289 const uint16_t indices[], int indexCount, |
289 const SkPaint&) override; | 290 const SkPaint&) override; |
291 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const Sk Color[], | |
292 int count, SkXfermode::Mode, const SkRect* cull, const SkPa int*) override; | |
290 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; | 293 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; |
291 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; | 294 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; |
292 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; | 295 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; |
293 void onClipRegion(const SkRegion&, SkRegion::Op) override; | 296 void onClipRegion(const SkRegion&, SkRegion::Op) override; |
294 | 297 |
295 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) overri de; | 298 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) overri de; |
296 | 299 |
297 private: | 300 private: |
298 void recordTranslate(const SkMatrix&); | 301 void recordTranslate(const SkMatrix&); |
299 void recordScale(const SkMatrix&); | 302 void recordScale(const SkMatrix&); |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1089 SkAssertResult(xfer->asMode(&mode)); | 1092 SkAssertResult(xfer->asMode(&mode)); |
1090 fWriter.write32(mode); | 1093 fWriter.write32(mode); |
1091 } | 1094 } |
1092 if (flags & kDrawVertices_HasIndices_DrawOpFlag) { | 1095 if (flags & kDrawVertices_HasIndices_DrawOpFlag) { |
1093 fWriter.write32(indexCount); | 1096 fWriter.write32(indexCount); |
1094 fWriter.writePad(indices, indexCount * sizeof(uint16_t)); | 1097 fWriter.writePad(indices, indexCount * sizeof(uint16_t)); |
1095 } | 1098 } |
1096 } | 1099 } |
1097 } | 1100 } |
1098 | 1101 |
1102 /* | |
1103 const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], | |
scroggo
2015/06/24 17:00:21
Is this comment necessary?
reed1
2015/06/24 17:04:30
Done.
| |
1104 int count, SkXfermode::Mode, const SkRect* cull, const SkPaint* | |
1105 */ | |
1106 void SkGPipeCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], c onst SkRect tex[], | |
1107 const SkColor colors[], int count, SkXfermode::M ode mode, | |
1108 const SkRect* cull, const SkPaint* paint) { | |
1109 NOTIFY_SETUP(this); | |
1110 unsigned flags = 0; // packs with the op, so needs no extra space | |
1111 | |
1112 if (paint) { | |
1113 flags |= kDrawAtlas_HasPaint_DrawOpFlag; | |
1114 this->writePaint(*paint); | |
1115 } | |
1116 | |
1117 size_t size = 4; // image-slot | |
1118 size += 4; // count | |
1119 size += 4; // mode | |
1120 size += count * sizeof(SkRSXform); // xform | |
1121 size += count * sizeof(SkRect); // tex | |
1122 if (colors) { | |
1123 flags |= kDrawAtlas_HasColors_DrawOpFlag; | |
1124 size += count * sizeof(SkColor); // colors | |
1125 } | |
1126 if (cull) { | |
1127 flags |= kDrawAtlas_HasCull_DrawOpFlag; | |
1128 size += sizeof(SkRect); // cull | |
1129 } | |
1130 | |
1131 if (this->needOpBytes(size)) { | |
1132 this->writeOp(kDrawAtlas_DrawOp, flags, 0); | |
1133 int32_t slot = fImageHeap->insert(atlas); | |
1134 fWriter.write32(slot); | |
1135 fWriter.write32(count); | |
1136 fWriter.write32(mode); | |
1137 fWriter.write(xform, count * sizeof(SkRSXform)); | |
1138 fWriter.write(tex, count * sizeof(SkRect)); | |
1139 if (colors) { | |
1140 fWriter.write(colors, count * sizeof(SkColor)); | |
1141 } | |
1142 if (cull) { | |
1143 fWriter.writeRect(*cull); | |
1144 } | |
1145 } | |
1146 } | |
1147 | |
1099 void SkGPipeCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4 ], | 1148 void SkGPipeCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4 ], |
1100 const SkPoint texCoords[4], SkXfermode* xmode, | 1149 const SkPoint texCoords[4], SkXfermode* xmode, |
1101 const SkPaint& paint) { | 1150 const SkPaint& paint) { |
1102 NOTIFY_SETUP(this); | 1151 NOTIFY_SETUP(this); |
1103 | 1152 |
1104 size_t size = SkPatchUtils::kNumCtrlPts * sizeof(SkPoint); | 1153 size_t size = SkPatchUtils::kNumCtrlPts * sizeof(SkPoint); |
1105 unsigned flags = 0; | 1154 unsigned flags = 0; |
1106 if (colors) { | 1155 if (colors) { |
1107 flags |= kDrawVertices_HasColors_DrawOpFlag; | 1156 flags |= kDrawVertices_HasColors_DrawOpFlag; |
1108 size += SkPatchUtils::kNumCorners * sizeof(SkColor); | 1157 size += SkPatchUtils::kNumCorners * sizeof(SkColor); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1428 int32_t slot = this->find(img); | 1477 int32_t slot = this->find(img); |
1429 if (slot) { | 1478 if (slot) { |
1430 return slot; | 1479 return slot; |
1431 } | 1480 } |
1432 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. | 1481 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. |
1433 fBytesInCache += img->width() * img->height() * 4; | 1482 fBytesInCache += img->width() * img->height() * 4; |
1434 *fArray.append() = SkRef(img); | 1483 *fArray.append() = SkRef(img); |
1435 return fArray.count(); // slot is always index+1 | 1484 return fArray.count(); // slot is always index+1 |
1436 } | 1485 } |
1437 | 1486 |
OLD | NEW |