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

Side by Side Diff: src/utils/debugger/SkDrawCommand.cpp

Issue 1387173003: [SkDebugger] Handle path empty-bounds gracefully (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review comments Created 5 years, 2 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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 9
10 #include "SkDrawCommand.h" 10 #include "SkDrawCommand.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } else { 93 } else {
94 canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.height()) , 94 canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.height()) ,
95 SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.height() )); 95 SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.height() ));
96 } 96 }
97 canvas->translate(-bounds.centerX(), -bounds.centerY()); 97 canvas->translate(-bounds.centerX(), -bounds.centerY());
98 } 98 }
99 99
100 100
101 void render_path(SkCanvas* canvas, const SkPath& path) { 101 void render_path(SkCanvas* canvas, const SkPath& path) {
102 canvas->clear(0xFFFFFFFF); 102 canvas->clear(0xFFFFFFFF);
103 canvas->save();
104 103
105 const SkRect& bounds = path.getBounds(); 104 const SkRect& bounds = path.getBounds();
105 if (bounds.isEmpty()) {
106 return;
107 }
106 108
109 SkAutoCanvasRestore acr(canvas, true);
107 xlate_and_scale_to_bounds(canvas, bounds); 110 xlate_and_scale_to_bounds(canvas, bounds);
108 111
109 SkPaint p; 112 SkPaint p;
110 p.setColor(SK_ColorBLACK); 113 p.setColor(SK_ColorBLACK);
111 p.setStyle(SkPaint::kStroke_Style); 114 p.setStyle(SkPaint::kStroke_Style);
112 115
113 canvas->drawPath(path, p); 116 canvas->drawPath(path, p);
114 canvas->restore();
115 } 117 }
116 118
117 void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRec t = nullptr) { 119 void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRec t = nullptr) {
118 const SkISize& size = canvas->getDeviceSize(); 120 const SkISize& size = canvas->getDeviceSize();
119 121
120 SkScalar xScale = SkIntToScalar(size.fWidth-2) / input.width(); 122 SkScalar xScale = SkIntToScalar(size.fWidth-2) / input.width();
121 SkScalar yScale = SkIntToScalar(size.fHeight-2) / input.height(); 123 SkScalar yScale = SkIntToScalar(size.fHeight-2) / input.height();
122 124
123 if (input.width() > input.height()) { 125 if (input.width() > input.height()) {
124 yScale *= input.height() / (float) input.width(); 126 yScale *= input.height() / (float) input.width();
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 977
976 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { 978 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) {
977 fUserMatrix = userMatrix; 979 fUserMatrix = userMatrix;
978 } 980 }
979 981
980 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { 982 void SkSetMatrixCommand::execute(SkCanvas* canvas) const {
981 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); 983 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix);
982 canvas->setMatrix(temp); 984 canvas->setMatrix(temp);
983 } 985 }
984 986
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