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

Side by Side Diff: tools/debugger/SkDrawCommand.cpp

Issue 2124113003: add bounds to textblob (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | 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 * 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 2638 matching lines...) Expand 10 before | Expand all | Expand 10 after
2649 run[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS] = jsonPositions; 2649 run[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS] = jsonPositions;
2650 } 2650 }
2651 run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS] = jsonGlyphs; 2651 run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS] = jsonGlyphs;
2652 SkPaint fontPaint; 2652 SkPaint fontPaint;
2653 iter.applyFontToPaint(&fontPaint); 2653 iter.applyFontToPaint(&fontPaint);
2654 run[SKDEBUGCANVAS_ATTRIBUTE_FONT] = MakeJsonPaint(fontPaint, urlDataMana ger); 2654 run[SKDEBUGCANVAS_ATTRIBUTE_FONT] = MakeJsonPaint(fontPaint, urlDataMana ger);
2655 run[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonPoint(iter.offset()); 2655 run[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonPoint(iter.offset());
2656 runs.append(run); 2656 runs.append(run);
2657 iter.next(); 2657 iter.next();
2658 } 2658 }
2659 SkRect bounds = fBlob->bounds();
2659 result[SKDEBUGCANVAS_ATTRIBUTE_RUNS] = runs; 2660 result[SKDEBUGCANVAS_ATTRIBUTE_RUNS] = runs;
2660 result[SKDEBUGCANVAS_ATTRIBUTE_X] = Json::Value(fXPos); 2661 result[SKDEBUGCANVAS_ATTRIBUTE_X] = Json::Value(fXPos);
2661 result[SKDEBUGCANVAS_ATTRIBUTE_Y] = Json::Value(fYPos); 2662 result[SKDEBUGCANVAS_ATTRIBUTE_Y] = Json::Value(fYPos);
2663 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(bounds);
2662 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager ); 2664 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager );
2665
2666 SkString desc;
2667 // make the bounds local by applying the x,y
2668 bounds.offset(fXPos, fYPos);
2669 result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc, bo unds)->c_str());
2670
2663 return result; 2671 return result;
2664 } 2672 }
2665 2673
2666 SkDrawTextBlobCommand* SkDrawTextBlobCommand::fromJSON(Json::Value& command, 2674 SkDrawTextBlobCommand* SkDrawTextBlobCommand::fromJSON(Json::Value& command,
2667 UrlDataManager& urlDataMa nager) { 2675 UrlDataManager& urlDataMa nager) {
2668 SkTextBlobBuilder builder; 2676 SkTextBlobBuilder builder;
2669 Json::Value runs = command[SKDEBUGCANVAS_ATTRIBUTE_RUNS]; 2677 Json::Value runs = command[SKDEBUGCANVAS_ATTRIBUTE_RUNS];
2670 for (Json::ArrayIndex i = 0 ; i < runs.size(); i++) { 2678 for (Json::ArrayIndex i = 0 ; i < runs.size(); i++) {
2671 Json::Value run = runs[i]; 2679 Json::Value run = runs[i];
2672 SkPaint font; 2680 SkPaint font;
2673 font.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 2681 font.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
2674 extract_json_paint(run[SKDEBUGCANVAS_ATTRIBUTE_FONT], urlDataManager, &f ont); 2682 extract_json_paint(run[SKDEBUGCANVAS_ATTRIBUTE_FONT], urlDataManager, &f ont);
2675 Json::Value glyphs = run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS]; 2683 Json::Value glyphs = run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS];
2676 int count = glyphs.size(); 2684 int count = glyphs.size();
2677 Json::Value coords = run[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; 2685 Json::Value coords = run[SKDEBUGCANVAS_ATTRIBUTE_COORDS];
2678 SkScalar x = coords[0].asFloat(); 2686 SkScalar x = coords[0].asFloat();
2679 SkScalar y = coords[1].asFloat(); 2687 SkScalar y = coords[1].asFloat();
2688 SkRect bounds;
2689 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &bounds);
2690
2680 if (run.isMember(SKDEBUGCANVAS_ATTRIBUTE_POSITIONS)) { 2691 if (run.isMember(SKDEBUGCANVAS_ATTRIBUTE_POSITIONS)) {
2681 Json::Value positions = run[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS]; 2692 Json::Value positions = run[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS];
2682 if (positions.size() > 0 && positions[0].isNumeric()) { 2693 if (positions.size() > 0 && positions[0].isNumeric()) {
2683 SkTextBlobBuilder::RunBuffer buffer = builder.allocRunPosH(font, count, y); 2694 SkTextBlobBuilder::RunBuffer buffer = builder.allocRunPosH(font, count, y, &bounds);
2684 for (int j = 0; j < count; j++) { 2695 for (int j = 0; j < count; j++) {
2685 buffer.glyphs[j] = glyphs[j].asUInt(); 2696 buffer.glyphs[j] = glyphs[j].asUInt();
2686 buffer.pos[j] = positions[j].asFloat(); 2697 buffer.pos[j] = positions[j].asFloat();
2687 } 2698 }
2688 } 2699 }
2689 else { 2700 else {
2690 SkTextBlobBuilder::RunBuffer buffer = builder.allocRunPos(font, count); 2701 SkTextBlobBuilder::RunBuffer buffer = builder.allocRunPos(font, count, &bounds);
2691 for (int j = 0; j < count; j++) { 2702 for (int j = 0; j < count; j++) {
2692 buffer.glyphs[j] = glyphs[j].asUInt(); 2703 buffer.glyphs[j] = glyphs[j].asUInt();
2693 buffer.pos[j * 2] = positions[j][0].asFloat(); 2704 buffer.pos[j * 2] = positions[j][0].asFloat();
2694 buffer.pos[j * 2 + 1] = positions[j][1].asFloat(); 2705 buffer.pos[j * 2 + 1] = positions[j][1].asFloat();
2695 } 2706 }
2696 } 2707 }
2697 } 2708 }
2698 else { 2709 else {
2699 SkTextBlobBuilder::RunBuffer buffer = builder.allocRun(font, count, x, y); 2710 SkTextBlobBuilder::RunBuffer buffer = builder.allocRun(font, count, x, y, &bounds);
2700 for (int j = 0; j < count; j++) { 2711 for (int j = 0; j < count; j++) {
2701 buffer.glyphs[j] = glyphs[j].asUInt(); 2712 buffer.glyphs[j] = glyphs[j].asUInt();
2702 } 2713 }
2703 } 2714 }
2704 } 2715 }
2705 SkScalar x = command[SKDEBUGCANVAS_ATTRIBUTE_X].asFloat(); 2716 SkScalar x = command[SKDEBUGCANVAS_ATTRIBUTE_X].asFloat();
2706 SkScalar y = command[SKDEBUGCANVAS_ATTRIBUTE_Y].asFloat(); 2717 SkScalar y = command[SKDEBUGCANVAS_ATTRIBUTE_Y].asFloat();
2707 SkPaint paint; 2718 SkPaint paint;
2708 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint); 2719 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2709 return new SkDrawTextBlobCommand(builder.build(), x, y, paint); 2720 return new SkDrawTextBlobCommand(builder.build(), x, y, paint);
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
3217 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); 3228 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix);
3218 return result; 3229 return result;
3219 } 3230 }
3220 3231
3221 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, 3232 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command,
3222 UrlDataManager& urlDataManager) { 3233 UrlDataManager& urlDataManager) {
3223 SkMatrix matrix; 3234 SkMatrix matrix;
3224 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); 3235 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix);
3225 return new SkSetMatrixCommand(matrix); 3236 return new SkSetMatrixCommand(matrix);
3226 } 3237 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698