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

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

Issue 463493002: SkCanvas::drawPatch param SkPoint[12] (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
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 "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 const SkPaint*) SK_OVERRIDE; 247 const SkPaint*) SK_OVERRIDE;
248 virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, 248 virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
249 const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE; 249 const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE;
250 virtual void drawSprite(const SkBitmap&, int left, int top, 250 virtual void drawSprite(const SkBitmap&, int left, int top,
251 const SkPaint*) SK_OVERRIDE; 251 const SkPaint*) SK_OVERRIDE;
252 virtual void drawVertices(VertexMode, int vertexCount, 252 virtual void drawVertices(VertexMode, int vertexCount,
253 const SkPoint vertices[], const SkPoint texs[], 253 const SkPoint vertices[], const SkPoint texs[],
254 const SkColor colors[], SkXfermode*, 254 const SkColor colors[], SkXfermode*,
255 const uint16_t indices[], int indexCount, 255 const uint16_t indices[], int indexCount,
256 const SkPaint&) SK_OVERRIDE; 256 const SkPaint&) SK_OVERRIDE;
257 virtual void drawPatch(const SkPatch& patch, const SkPaint& paint) SK_OVERRI DE; 257 virtual void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
258 const SkPoint texCoords[4], SkXfermode* xmode,
259 const SkPaint& paint) SK_OVERRIDE;
258 virtual void drawData(const void*, size_t) SK_OVERRIDE; 260 virtual void drawData(const void*, size_t) SK_OVERRIDE;
259 virtual void beginCommentGroup(const char* description) SK_OVERRIDE; 261 virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
260 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE; 262 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
261 virtual void endCommentGroup() SK_OVERRIDE; 263 virtual void endCommentGroup() SK_OVERRIDE;
262 264
263 /** 265 /**
264 * Flatten an SkBitmap to send to the reader, where it will be referenced 266 * Flatten an SkBitmap to send to the reader, where it will be referenced
265 * according to slot. 267 * according to slot.
266 */ 268 */
267 bool shuttleBitmap(const SkBitmap&, int32_t slot); 269 bool shuttleBitmap(const SkBitmap&, int32_t slot);
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 SkAssertResult(xfer->asMode(&mode)); 998 SkAssertResult(xfer->asMode(&mode));
997 fWriter.write32(mode); 999 fWriter.write32(mode);
998 } 1000 }
999 if (flags & kDrawVertices_HasIndices_DrawOpFlag) { 1001 if (flags & kDrawVertices_HasIndices_DrawOpFlag) {
1000 fWriter.write32(indexCount); 1002 fWriter.write32(indexCount);
1001 fWriter.writePad(indices, indexCount * sizeof(uint16_t)); 1003 fWriter.writePad(indices, indexCount * sizeof(uint16_t));
1002 } 1004 }
1003 } 1005 }
1004 } 1006 }
1005 1007
1006 void SkGPipeCanvas::drawPatch(const SkPatch& patch, const SkPaint& paint) { 1008 void SkGPipeCanvas::drawPatch(const SkPoint cubics[12], const SkColor colors[4],
1009 const SkPoint texCoords[4], SkXfermode* xmode,
1010 const SkPaint& paint) {
1011 if (NULL == cubics) {
1012 return;
1013 }
1014
1007 NOTIFY_SETUP(this); 1015 NOTIFY_SETUP(this);
1016
1017 size_t size = SkPatch::kNumCtrlPts * sizeof(SkPoint);
1018 unsigned flags = 0;
1019 if (NULL != colors) {
1020 flags |= kDrawVertices_HasColors_DrawOpFlag;
1021 size += SkPatch::kNumCorners * sizeof(SkColor);
1022 }
1023 if (NULL != texCoords) {
1024 flags |= kDrawVertices_HasTexs_DrawOpFlag;
1025 size += SkPatch::kNumCorners * sizeof(SkPoint);
1026 }
1027 if (NULL != xmode) {
1028 SkXfermode::Mode mode;
1029 if (xmode->asMode(&mode) && SkXfermode::kModulate_Mode != mode) {
1030 flags |= kDrawVertices_HasXfermode_DrawOpFlag;
1031 size += sizeof(int32_t);
1032 }
1033 }
1034
1008 this->writePaint(paint); 1035 this->writePaint(paint);
1009 if (this->needOpBytes(patch.writeToMemory(NULL))) { 1036 if (this->needOpBytes(size)) {
1010 this->writeOp(kDrawPatch_DrawOp); 1037 this->writeOp(kDrawPatch_DrawOp, flags, 0);
1011 fWriter.writePatch(patch); 1038
1039 fWriter.write(cubics, SkPatch::kNumCtrlPts * sizeof(SkPoint));
1040
1041 if (NULL != colors) {
1042 fWriter.write(colors, SkPatch::kNumCorners * sizeof(SkColor));
1043 }
1044
1045 if (NULL != texCoords) {
1046 fWriter.write(texCoords, SkPatch::kNumCorners * sizeof(SkPoint));
1047 }
1048
1049 if (flags & kDrawVertices_HasXfermode_DrawOpFlag) {
1050 SkXfermode::Mode mode = SkXfermode::kModulate_Mode;
1051 SkAssertResult(xmode->asMode(&mode));
1052 fWriter.write32(mode);
1053 }
1012 } 1054 }
1013 } 1055 }
1014 1056
1015 void SkGPipeCanvas::drawData(const void* ptr, size_t size) { 1057 void SkGPipeCanvas::drawData(const void* ptr, size_t size) {
1016 if (size && ptr) { 1058 if (size && ptr) {
1017 NOTIFY_SETUP(this); 1059 NOTIFY_SETUP(this);
1018 unsigned data = 0; 1060 unsigned data = 0;
1019 if (size < (1 << DRAWOPS_DATA_BITS)) { 1061 if (size < (1 << DRAWOPS_DATA_BITS)) {
1020 data = (unsigned)size; 1062 data = (unsigned)size;
1021 } 1063 }
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 return fCanvas->shuttleBitmap(bitmap, slot); 1317 return fCanvas->shuttleBitmap(bitmap, slot);
1276 } 1318 }
1277 1319
1278 void BitmapShuttle::removeCanvas() { 1320 void BitmapShuttle::removeCanvas() {
1279 if (NULL == fCanvas) { 1321 if (NULL == fCanvas) {
1280 return; 1322 return;
1281 } 1323 }
1282 fCanvas->unref(); 1324 fCanvas->unref();
1283 fCanvas = NULL; 1325 fCanvas = NULL;
1284 } 1326 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698