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

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

Issue 112913005: reenable vertices gm, adding picture support (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/pipe/SkGPipeRead.cpp ('k') | no next file » | 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 "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 } 921 }
922 } 922 }
923 } 923 }
924 } 924 }
925 925
926 void SkGPipeCanvas::drawPicture(SkPicture& picture) { 926 void SkGPipeCanvas::drawPicture(SkPicture& picture) {
927 // we want to playback the picture into individual draw calls 927 // we want to playback the picture into individual draw calls
928 this->INHERITED::drawPicture(picture); 928 this->INHERITED::drawPicture(picture);
929 } 929 }
930 930
931 void SkGPipeCanvas::drawVertices(VertexMode mode, int vertexCount, 931 void SkGPipeCanvas::drawVertices(VertexMode vmode, int vertexCount,
932 const SkPoint vertices[], const SkPoint texs[], 932 const SkPoint vertices[], const SkPoint texs[],
933 const SkColor colors[], SkXfermode*, 933 const SkColor colors[], SkXfermode* xfer,
934 const uint16_t indices[], int indexCount, 934 const uint16_t indices[], int indexCount,
935 const SkPaint& paint) { 935 const SkPaint& paint) {
936 if (0 == vertexCount) { 936 if (0 == vertexCount) {
937 return; 937 return;
938 } 938 }
939 939
940 NOTIFY_SETUP(this); 940 NOTIFY_SETUP(this);
941 size_t size = 4 + vertexCount * sizeof(SkPoint); 941 size_t size = 4 + vertexCount * sizeof(SkPoint);
942 this->writePaint(paint); 942 this->writePaint(paint);
943 unsigned flags = 0; 943 unsigned flags = 0;
944 if (texs) { 944 if (texs) {
945 flags |= kDrawVertices_HasTexs_DrawOpFlag; 945 flags |= kDrawVertices_HasTexs_DrawOpFlag;
946 size += vertexCount * sizeof(SkPoint); 946 size += vertexCount * sizeof(SkPoint);
947 } 947 }
948 if (colors) { 948 if (colors) {
949 flags |= kDrawVertices_HasColors_DrawOpFlag; 949 flags |= kDrawVertices_HasColors_DrawOpFlag;
950 size += vertexCount * sizeof(SkColor); 950 size += vertexCount * sizeof(SkColor);
951 } 951 }
952 if (indices && indexCount > 0) { 952 if (indices && indexCount > 0) {
953 flags |= kDrawVertices_HasIndices_DrawOpFlag; 953 flags |= kDrawVertices_HasIndices_DrawOpFlag;
954 size += 4 + SkAlign4(indexCount * sizeof(uint16_t)); 954 size += 4 + SkAlign4(indexCount * sizeof(uint16_t));
955 } 955 }
956 if (xfer && !SkXfermode::IsMode(xfer, SkXfermode::kModulate_Mode)) {
957 flags |= kDrawVertices_HasXfermode_DrawOpFlag;
958 size += sizeof(int32_t); // mode enum
959 }
956 960
957 if (this->needOpBytes(size)) { 961 if (this->needOpBytes(size)) {
958 this->writeOp(kDrawVertices_DrawOp, flags, 0); 962 this->writeOp(kDrawVertices_DrawOp, flags, 0);
959 fWriter.write32(mode); 963 fWriter.write32(vmode);
960 fWriter.write32(vertexCount); 964 fWriter.write32(vertexCount);
961 fWriter.write(vertices, vertexCount * sizeof(SkPoint)); 965 fWriter.write(vertices, vertexCount * sizeof(SkPoint));
962 if (texs) { 966 if (texs) {
963 fWriter.write(texs, vertexCount * sizeof(SkPoint)); 967 fWriter.write(texs, vertexCount * sizeof(SkPoint));
964 } 968 }
965 if (colors) { 969 if (colors) {
966 fWriter.write(colors, vertexCount * sizeof(SkColor)); 970 fWriter.write(colors, vertexCount * sizeof(SkColor));
967 } 971 }
968 972 if (flags & kDrawVertices_HasXfermode_DrawOpFlag) {
969 // TODO: flatten xfermode 973 SkXfermode::Mode mode = SkXfermode::kModulate_Mode;
970 974 (void)xfer->asMode(&mode);
975 fWriter.write32(mode);
976 }
971 if (indices && indexCount > 0) { 977 if (indices && indexCount > 0) {
972 fWriter.write32(indexCount); 978 fWriter.write32(indexCount);
973 fWriter.writePad(indices, indexCount * sizeof(uint16_t)); 979 fWriter.writePad(indices, indexCount * sizeof(uint16_t));
974 } 980 }
975 } 981 }
976 } 982 }
977 983
978 void SkGPipeCanvas::drawData(const void* ptr, size_t size) { 984 void SkGPipeCanvas::drawData(const void* ptr, size_t size) {
979 if (size && ptr) { 985 if (size && ptr) {
980 NOTIFY_SETUP(this); 986 NOTIFY_SETUP(this);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 return fCanvas->shuttleBitmap(bitmap, slot); 1240 return fCanvas->shuttleBitmap(bitmap, slot);
1235 } 1241 }
1236 1242
1237 void BitmapShuttle::removeCanvas() { 1243 void BitmapShuttle::removeCanvas() {
1238 if (NULL == fCanvas) { 1244 if (NULL == fCanvas) {
1239 return; 1245 return;
1240 } 1246 }
1241 fCanvas->unref(); 1247 fCanvas->unref();
1242 fCanvas = NULL; 1248 fCanvas = NULL;
1243 } 1249 }
OLDNEW
« no previous file with comments | « src/pipe/SkGPipeRead.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698