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

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: Virtual call onDrawPatch 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;
258 virtual void drawData(const void*, size_t) SK_OVERRIDE; 257 virtual void drawData(const void*, size_t) SK_OVERRIDE;
259 virtual void beginCommentGroup(const char* description) SK_OVERRIDE; 258 virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
260 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE; 259 virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
261 virtual void endCommentGroup() SK_OVERRIDE; 260 virtual void endCommentGroup() SK_OVERRIDE;
262 261
263 /** 262 /**
264 * Flatten an SkBitmap to send to the reader, where it will be referenced 263 * Flatten an SkBitmap to send to the reader, where it will be referenced
265 * according to slot. 264 * according to slot.
266 */ 265 */
267 bool shuttleBitmap(const SkBitmap&, int32_t slot); 266 bool shuttleBitmap(const SkBitmap&, int32_t slot);
268 267
269 protected: 268 protected:
270 virtual void willSave() SK_OVERRIDE; 269 virtual void willSave() SK_OVERRIDE;
271 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF lags) SK_OVERRIDE; 270 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF lags) SK_OVERRIDE;
272 virtual void willRestore() SK_OVERRIDE; 271 virtual void willRestore() SK_OVERRIDE;
273 272
274 virtual void didConcat(const SkMatrix&) SK_OVERRIDE; 273 virtual void didConcat(const SkMatrix&) SK_OVERRIDE;
275 virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; 274 virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
276 275
277 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK _OVERRIDE; 276 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK _OVERRIDE;
278 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkS calar y, 277 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkS calar y,
279 const SkPaint&) SK_OVERRIDE; 278 const SkPaint&) SK_OVERRIDE;
280 virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoin t pos[], 279 virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoin t pos[],
281 const SkPaint&) SK_OVERRIDE; 280 const SkPaint&) SK_OVERRIDE;
282 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkSca lar xpos[], 281 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkSca lar xpos[],
283 SkScalar constY, const SkPaint&) SK_OVERRIDE; 282 SkScalar constY, const SkPaint&) SK_OVERRIDE;
284 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkP ath& path, 283 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkP ath& path,
285 const SkMatrix* matrix, const SkPaint&) SK_OVE RRIDE; 284 const SkMatrix* matrix, const SkPaint&) SK_OVE RRIDE;
286 285 virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
286 const SkPoint texCoords[4], SkXfermode* xmode,
287 const SkPaint& paint) SK_OVERRIDE;
287 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERR IDE; 288 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERR IDE;
288 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVE RRIDE; 289 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVE RRIDE;
289 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERR IDE; 290 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERR IDE;
290 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; 291 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
291 292
292 virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint* ) SK_OVERRIDE; 293 virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint* ) SK_OVERRIDE;
293 294
294 private: 295 private:
295 void recordTranslate(const SkMatrix&); 296 void recordTranslate(const SkMatrix&);
296 void recordScale(const SkMatrix&); 297 void recordScale(const SkMatrix&);
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 SkAssertResult(xfer->asMode(&mode)); 997 SkAssertResult(xfer->asMode(&mode));
997 fWriter.write32(mode); 998 fWriter.write32(mode);
998 } 999 }
999 if (flags & kDrawVertices_HasIndices_DrawOpFlag) { 1000 if (flags & kDrawVertices_HasIndices_DrawOpFlag) {
1000 fWriter.write32(indexCount); 1001 fWriter.write32(indexCount);
1001 fWriter.writePad(indices, indexCount * sizeof(uint16_t)); 1002 fWriter.writePad(indices, indexCount * sizeof(uint16_t));
1002 } 1003 }
1003 } 1004 }
1004 } 1005 }
1005 1006
1006 void SkGPipeCanvas::drawPatch(const SkPatch& patch, const SkPaint& paint) { 1007 void SkGPipeCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4 ],
1008 const SkPoint texCoords[4], SkXfermode* xmode,
1009 const SkPaint& paint) {
1010 if (NULL == cubics) {
1011 return;
1012 }
1013
1007 NOTIFY_SETUP(this); 1014 NOTIFY_SETUP(this);
1015
1016 size_t size = SkPatch::kNumCtrlPts * sizeof(SkPoint);
1017 unsigned flags = 0;
1018 if (NULL != colors) {
1019 flags |= kDrawVertices_HasColors_DrawOpFlag;
1020 size += SkPatch::kNumCorners * sizeof(SkColor);
1021 }
1022 if (NULL != texCoords) {
1023 flags |= kDrawVertices_HasTexs_DrawOpFlag;
1024 size += SkPatch::kNumCorners * sizeof(SkPoint);
1025 }
1026 if (NULL != xmode) {
1027 SkXfermode::Mode mode;
1028 if (xmode->asMode(&mode) && SkXfermode::kModulate_Mode != mode) {
1029 flags |= kDrawVertices_HasXfermode_DrawOpFlag;
1030 size += sizeof(int32_t);
1031 }
1032 }
1033
1008 this->writePaint(paint); 1034 this->writePaint(paint);
1009 if (this->needOpBytes(patch.writeToMemory(NULL))) { 1035 if (this->needOpBytes(size)) {
1010 this->writeOp(kDrawPatch_DrawOp); 1036 this->writeOp(kDrawPatch_DrawOp, flags, 0);
1011 fWriter.writePatch(patch); 1037
1038 fWriter.write(cubics, SkPatch::kNumCtrlPts * sizeof(SkPoint));
1039
1040 if (NULL != colors) {
1041 fWriter.write(colors, SkPatch::kNumCorners * sizeof(SkColor));
1042 }
1043
1044 if (NULL != texCoords) {
1045 fWriter.write(texCoords, SkPatch::kNumCorners * sizeof(SkPoint));
1046 }
1047
1048 if (flags & kDrawVertices_HasXfermode_DrawOpFlag) {
1049 SkXfermode::Mode mode = SkXfermode::kModulate_Mode;
1050 SkAssertResult(xmode->asMode(&mode));
1051 fWriter.write32(mode);
1052 }
1012 } 1053 }
1013 } 1054 }
1014 1055
1015 void SkGPipeCanvas::drawData(const void* ptr, size_t size) { 1056 void SkGPipeCanvas::drawData(const void* ptr, size_t size) {
1016 if (size && ptr) { 1057 if (size && ptr) {
1017 NOTIFY_SETUP(this); 1058 NOTIFY_SETUP(this);
1018 unsigned data = 0; 1059 unsigned data = 0;
1019 if (size < (1 << DRAWOPS_DATA_BITS)) { 1060 if (size < (1 << DRAWOPS_DATA_BITS)) {
1020 data = (unsigned)size; 1061 data = (unsigned)size;
1021 } 1062 }
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 return fCanvas->shuttleBitmap(bitmap, slot); 1316 return fCanvas->shuttleBitmap(bitmap, slot);
1276 } 1317 }
1277 1318
1278 void BitmapShuttle::removeCanvas() { 1319 void BitmapShuttle::removeCanvas() {
1279 if (NULL == fCanvas) { 1320 if (NULL == fCanvas) {
1280 return; 1321 return;
1281 } 1322 }
1282 fCanvas->unref(); 1323 fCanvas->unref();
1283 fCanvas = NULL; 1324 fCanvas = NULL;
1284 } 1325 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698