Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkDrawCommand.h" | 8 #include "SkDrawCommand.h" |
| 9 | 9 |
| 10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 case kDrawPaint_OpType: return "DrawPaint"; | 196 case kDrawPaint_OpType: return "DrawPaint"; |
| 197 case kDrawPatch_OpType: return "DrawPatch"; | 197 case kDrawPatch_OpType: return "DrawPatch"; |
| 198 case kDrawPath_OpType: return "DrawPath"; | 198 case kDrawPath_OpType: return "DrawPath"; |
| 199 case kDrawPoints_OpType: return "DrawPoints"; | 199 case kDrawPoints_OpType: return "DrawPoints"; |
| 200 case kDrawPosText_OpType: return "DrawPosText"; | 200 case kDrawPosText_OpType: return "DrawPosText"; |
| 201 case kDrawPosTextH_OpType: return "DrawPosTextH"; | 201 case kDrawPosTextH_OpType: return "DrawPosTextH"; |
| 202 case kDrawRect_OpType: return "DrawRect"; | 202 case kDrawRect_OpType: return "DrawRect"; |
| 203 case kDrawRRect_OpType: return "DrawRRect"; | 203 case kDrawRRect_OpType: return "DrawRRect"; |
| 204 case kDrawText_OpType: return "DrawText"; | 204 case kDrawText_OpType: return "DrawText"; |
| 205 case kDrawTextBlob_OpType: return "DrawTextBlob"; | 205 case kDrawTextBlob_OpType: return "DrawTextBlob"; |
| 206 case kDrawTextOnPath_OpType: return "DrawTextOnPath"; | 206 case kDrawTextOnPath_OpType: return "DrawTextOnPath"; |
|
robertphillips
2016/07/07 20:59:11
Everyone else starts with a capital 'D' ...
reed1
2016/07/07 22:51:45
Yes, all of the other ones are wrong.
Done.
| |
| 207 case kDrawTextRSXform_OpType: return "drawTextRSXform"; | |
| 207 case kDrawVertices_OpType: return "DrawVertices"; | 208 case kDrawVertices_OpType: return "DrawVertices"; |
| 208 case kEndDrawPicture_OpType: return "EndDrawPicture"; | 209 case kEndDrawPicture_OpType: return "EndDrawPicture"; |
| 209 case kRestore_OpType: return "Restore"; | 210 case kRestore_OpType: return "Restore"; |
| 210 case kSave_OpType: return "Save"; | 211 case kSave_OpType: return "Save"; |
| 211 case kSaveLayer_OpType: return "SaveLayer"; | 212 case kSaveLayer_OpType: return "SaveLayer"; |
| 212 case kSetMatrix_OpType: return "SetMatrix"; | 213 case kSetMatrix_OpType: return "SetMatrix"; |
| 213 default: | 214 default: |
| 214 SkDebugf("OpType error 0x%08x\n", type); | 215 SkDebugf("OpType error 0x%08x\n", type); |
| 215 SkASSERT(0); | 216 SkASSERT(0); |
| 216 break; | 217 break; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 INSTALL_FACTORY(DrawImage); | 251 INSTALL_FACTORY(DrawImage); |
| 251 INSTALL_FACTORY(DrawImageRect); | 252 INSTALL_FACTORY(DrawImageRect); |
| 252 INSTALL_FACTORY(DrawOval); | 253 INSTALL_FACTORY(DrawOval); |
| 253 INSTALL_FACTORY(DrawPaint); | 254 INSTALL_FACTORY(DrawPaint); |
| 254 INSTALL_FACTORY(DrawPath); | 255 INSTALL_FACTORY(DrawPath); |
| 255 INSTALL_FACTORY(DrawPoints); | 256 INSTALL_FACTORY(DrawPoints); |
| 256 INSTALL_FACTORY(DrawText); | 257 INSTALL_FACTORY(DrawText); |
| 257 INSTALL_FACTORY(DrawPosText); | 258 INSTALL_FACTORY(DrawPosText); |
| 258 INSTALL_FACTORY(DrawPosTextH); | 259 INSTALL_FACTORY(DrawPosTextH); |
| 259 INSTALL_FACTORY(DrawTextOnPath); | 260 INSTALL_FACTORY(DrawTextOnPath); |
| 261 INSTALL_FACTORY(DrawTextRSXform); | |
| 260 INSTALL_FACTORY(DrawTextBlob); | 262 INSTALL_FACTORY(DrawTextBlob); |
| 261 | 263 |
| 262 INSTALL_FACTORY(DrawRect); | 264 INSTALL_FACTORY(DrawRect); |
| 263 INSTALL_FACTORY(DrawRRect); | 265 INSTALL_FACTORY(DrawRRect); |
| 264 INSTALL_FACTORY(DrawDRRect); | 266 INSTALL_FACTORY(DrawDRRect); |
| 265 INSTALL_FACTORY(DrawPatch); | 267 INSTALL_FACTORY(DrawPatch); |
| 266 INSTALL_FACTORY(Save); | 268 INSTALL_FACTORY(Save); |
| 267 INSTALL_FACTORY(SaveLayer); | 269 INSTALL_FACTORY(SaveLayer); |
| 268 INSTALL_FACTORY(SetMatrix); | 270 INSTALL_FACTORY(SetMatrix); |
| 269 } | 271 } |
| (...skipping 2679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2949 SkDrawTextCommand* SkDrawTextCommand::fromJSON(Json::Value& command, | 2951 SkDrawTextCommand* SkDrawTextCommand::fromJSON(Json::Value& command, |
| 2950 UrlDataManager& urlDataManager) { | 2952 UrlDataManager& urlDataManager) { |
| 2951 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); | 2953 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); |
| 2952 SkPaint paint; | 2954 SkPaint paint; |
| 2953 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint); | 2955 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint); |
| 2954 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; | 2956 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; |
| 2955 return new SkDrawTextCommand(text, strlen(text), coords[0].asFloat(), coords [1].asFloat(), | 2957 return new SkDrawTextCommand(text, strlen(text), coords[0].asFloat(), coords [1].asFloat(), |
| 2956 paint); | 2958 paint); |
| 2957 } | 2959 } |
| 2958 | 2960 |
| 2961 //////////////////////////////////////////////////////////////////////////////// /////////////////// | |
| 2962 | |
| 2959 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe ngth, | 2963 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe ngth, |
| 2960 const SkPath& path, const SkMat rix* matrix, | 2964 const SkPath& path, const SkMat rix* matrix, |
| 2961 const SkPaint& paint) | 2965 const SkPaint& paint) |
| 2962 : INHERITED(kDrawTextOnPath_OpType) { | 2966 : INHERITED(kDrawTextOnPath_OpType) { |
| 2963 fText = new char[byteLength]; | 2967 fText = new char[byteLength]; |
| 2964 memcpy(fText, text, byteLength); | 2968 memcpy(fText, text, byteLength); |
| 2965 fByteLength = byteLength; | 2969 fByteLength = byteLength; |
| 2966 fPath = path; | 2970 fPath = path; |
| 2967 if (matrix) { | 2971 if (matrix) { |
| 2968 fMatrix = *matrix; | 2972 fMatrix = *matrix; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3010 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_MATRIX)) { | 3014 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_MATRIX)) { |
| 3011 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 3015 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
| 3012 matrixPtr = &matrix; | 3016 matrixPtr = &matrix; |
| 3013 } | 3017 } |
| 3014 else { | 3018 else { |
| 3015 matrixPtr = nullptr; | 3019 matrixPtr = nullptr; |
| 3016 } | 3020 } |
| 3017 return new SkDrawTextOnPathCommand(text, strlen(text), path, matrixPtr, pain t); | 3021 return new SkDrawTextOnPathCommand(text, strlen(text), path, matrixPtr, pain t); |
| 3018 } | 3022 } |
| 3019 | 3023 |
| 3024 //////////////////////////////////////////////////////////////////////////////// /////////////////// | |
| 3025 | |
| 3026 SkDrawTextRSXformCommand::SkDrawTextRSXformCommand(const void* text, size_t byte Length, | |
| 3027 const SkRSXform xform[], cons t SkRect* cull, | |
| 3028 const SkPaint& paint) | |
|
robertphillips
2016/07/07 20:59:11
Not 'kDrawTextRSXform_OpType' ?
reed1
2016/07/07 22:51:45
Done.
| |
| 3029 : INHERITED(kDrawTextOnPath_OpType) | |
| 3030 { | |
| 3031 fText = new char[byteLength]; | |
| 3032 memcpy(fText, text, byteLength); | |
| 3033 fByteLength = byteLength; | |
| 3034 int count = paint.countText(text, byteLength); | |
| 3035 fXform = new SkRSXform[count]; | |
| 3036 memcpy(fXform, xform, count * sizeof(SkRSXform)); | |
| 3037 if (cull) { | |
| 3038 fCullStorage = *cull; | |
| 3039 fCull = &fCullStorage; | |
| 3040 } else { | |
| 3041 fCull = nullptr; | |
| 3042 } | |
| 3043 fPaint = paint; | |
| 3044 | |
| 3045 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod ing())); | |
| 3046 fInfo.push(SkObjectParser::PaintToString(paint)); | |
| 3047 } | |
| 3048 | |
| 3049 void SkDrawTextRSXformCommand::execute(SkCanvas* canvas) const { | |
| 3050 canvas->drawTextRSXform(fText, fByteLength, fXform, fCull, fPaint); | |
| 3051 } | |
| 3052 | |
| 3053 Json::Value SkDrawTextRSXformCommand::toJSON(UrlDataManager& urlDataManager) con st { | |
| 3054 Json::Value result = INHERITED::toJSON(urlDataManager); | |
| 3055 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, | |
| 3056 ((const char*) fText) + f ByteLength); | |
| 3057 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager ); | |
| 3058 return result; | |
| 3059 } | |
| 3060 | |
| 3061 SkDrawTextRSXformCommand* SkDrawTextRSXformCommand::fromJSON(Json::Value& comman d, | |
| 3062 UrlDataManager& url DataManager) { | |
| 3063 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); | |
| 3064 size_t byteLength = strlen(text); | |
| 3065 SkPaint paint; | |
| 3066 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint); | |
| 3067 | |
| 3068 // TODO: handle xform and cull | |
| 3069 int count = paint.countText(text, byteLength); | |
| 3070 SkAutoTArray<SkRSXform> xform(count); | |
| 3071 for (int i = 0; i < count; ++i) { | |
| 3072 xform[i].fSCos = 1; | |
| 3073 xform[i].fSSin = xform[i].fTx = xform[i].fTy = 0; | |
| 3074 } | |
| 3075 return new SkDrawTextRSXformCommand(text, byteLength, &xform[0], nullptr, pa int); | |
| 3076 } | |
| 3077 | |
| 3078 //////////////////////////////////////////////////////////////////////////////// /////////////////// | |
| 3079 | |
| 3020 SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int ver texCount, | 3080 SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int ver texCount, |
| 3021 const SkPoint vertices[], const SkP oint texs[], | 3081 const SkPoint vertices[], const SkP oint texs[], |
| 3022 const SkColor colors[], SkXfermode* xfermode, | 3082 const SkColor colors[], SkXfermode* xfermode, |
| 3023 const uint16_t indices[], int index Count, | 3083 const uint16_t indices[], int index Count, |
| 3024 const SkPaint& paint) | 3084 const SkPaint& paint) |
| 3025 : INHERITED(kDrawVertices_OpType) { | 3085 : INHERITED(kDrawVertices_OpType) { |
| 3026 fVmode = vmode; | 3086 fVmode = vmode; |
| 3027 | 3087 |
| 3028 fVertexCount = vertexCount; | 3088 fVertexCount = vertexCount; |
| 3029 | 3089 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3217 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); | 3277 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); |
| 3218 return result; | 3278 return result; |
| 3219 } | 3279 } |
| 3220 | 3280 |
| 3221 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, | 3281 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, |
| 3222 UrlDataManager& urlDataManager) { | 3282 UrlDataManager& urlDataManager) { |
| 3223 SkMatrix matrix; | 3283 SkMatrix matrix; |
| 3224 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 3284 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
| 3225 return new SkSetMatrixCommand(matrix); | 3285 return new SkSetMatrixCommand(matrix); |
| 3226 } | 3286 } |
| OLD | NEW |