Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: src/pipe/SkGPipeWrite.cpp

Issue 1181913003: add SkCanvas::drawAtlas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warnings Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pipe/SkGPipeRead.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 void SkGPipeCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], c onst SkRect tex[],
1103 const SkColor colors[], int count, SkXfermode::M ode mode,
1104 const SkRect* cull, const SkPaint* paint) {
1105 NOTIFY_SETUP(this);
1106 unsigned flags = 0; // packs with the op, so needs no extra space
1107
1108 if (paint) {
1109 flags |= kDrawAtlas_HasPaint_DrawOpFlag;
1110 this->writePaint(*paint);
1111 }
1112
1113 size_t size = 4; // image-slot
1114 size += 4; // count
1115 size += 4; // mode
1116 size += count * sizeof(SkRSXform); // xform
1117 size += count * sizeof(SkRect); // tex
1118 if (colors) {
1119 flags |= kDrawAtlas_HasColors_DrawOpFlag;
1120 size += count * sizeof(SkColor); // colors
1121 }
1122 if (cull) {
1123 flags |= kDrawAtlas_HasCull_DrawOpFlag;
1124 size += sizeof(SkRect); // cull
1125 }
1126
1127 if (this->needOpBytes(size)) {
1128 this->writeOp(kDrawAtlas_DrawOp, flags, 0);
1129 int32_t slot = fImageHeap->insert(atlas);
1130 fWriter.write32(slot);
1131 fWriter.write32(count);
1132 fWriter.write32(mode);
1133 fWriter.write(xform, count * sizeof(SkRSXform));
1134 fWriter.write(tex, count * sizeof(SkRect));
1135 if (colors) {
1136 fWriter.write(colors, count * sizeof(SkColor));
1137 }
1138 if (cull) {
1139 fWriter.writeRect(*cull);
1140 }
1141 }
1142 }
1143
1099 void SkGPipeCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4 ], 1144 void SkGPipeCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4 ],
1100 const SkPoint texCoords[4], SkXfermode* xmode, 1145 const SkPoint texCoords[4], SkXfermode* xmode,
1101 const SkPaint& paint) { 1146 const SkPaint& paint) {
1102 NOTIFY_SETUP(this); 1147 NOTIFY_SETUP(this);
1103 1148
1104 size_t size = SkPatchUtils::kNumCtrlPts * sizeof(SkPoint); 1149 size_t size = SkPatchUtils::kNumCtrlPts * sizeof(SkPoint);
1105 unsigned flags = 0; 1150 unsigned flags = 0;
1106 if (colors) { 1151 if (colors) {
1107 flags |= kDrawVertices_HasColors_DrawOpFlag; 1152 flags |= kDrawVertices_HasColors_DrawOpFlag;
1108 size += SkPatchUtils::kNumCorners * sizeof(SkColor); 1153 size += SkPatchUtils::kNumCorners * sizeof(SkColor);
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 int32_t slot = this->find(img); 1473 int32_t slot = this->find(img);
1429 if (slot) { 1474 if (slot) {
1430 return slot; 1475 return slot;
1431 } 1476 }
1432 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess. 1477 // TODO: SkImage does not expose bytes per pixel, 4 is just a best guess.
1433 fBytesInCache += img->width() * img->height() * 4; 1478 fBytesInCache += img->width() * img->height() * 4;
1434 *fArray.append() = SkRef(img); 1479 *fArray.append() = SkRef(img);
1435 return fArray.count(); // slot is always index+1 1480 return fArray.count(); // slot is always index+1
1436 } 1481 }
1437 1482
OLDNEW
« no previous file with comments | « src/pipe/SkGPipeRead.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698