Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit af64e6d

Browse files
Always use integers to hold the size of the performance overlay cache bitmap (#40071)
Previously this was comparing a float overlay rectangle size with an integer cache bitmap size. This could result in mismatches if the overlay width is not an integer.
1 parent 07ff132 commit af64e6d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

flow/instrumentation.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ fml::TimeDelta Stopwatch::AverageDelta() const {
8686

8787
// Initialize the SkSurface for drawing into. Draws the base background and any
8888
// timing data from before the initial Visualize() call.
89-
void Stopwatch::InitVisualizeSurface(const SkRect& rect) const {
89+
void Stopwatch::InitVisualizeSurface(SkISize size) const {
9090
// Mark as dirty if the size has changed.
9191
if (visualize_cache_surface_) {
92-
if (rect.width() != visualize_cache_surface_->width() ||
93-
rect.height() != visualize_cache_surface_->height()) {
92+
if (size.width() != visualize_cache_surface_->width() ||
93+
size.height() != visualize_cache_surface_->height()) {
9494
cache_dirty_ = true;
9595
};
9696
}
@@ -102,15 +102,15 @@ void Stopwatch::InitVisualizeSurface(const SkRect& rect) const {
102102

103103
// TODO(garyq): Use a GPU surface instead of a CPU surface.
104104
visualize_cache_surface_ =
105-
SkSurface::MakeRasterN32Premul(rect.width(), rect.height());
105+
SkSurface::MakeRasterN32Premul(size.width(), size.height());
106106

107107
SkCanvas* cache_canvas = visualize_cache_surface_->getCanvas();
108108

109109
// Establish the graph position.
110110
const SkScalar x = 0;
111111
const SkScalar y = 0;
112-
const SkScalar width = rect.width();
113-
const SkScalar height = rect.height();
112+
const SkScalar width = size.width();
113+
const SkScalar height = size.height();
114114

115115
SkPaint paint;
116116
paint.setColor(0x99FFFFFF);
@@ -155,16 +155,16 @@ void Stopwatch::InitVisualizeSurface(const SkRect& rect) const {
155155

156156
void Stopwatch::Visualize(DlCanvas* canvas, const SkRect& rect) const {
157157
// Initialize visualize cache if it has not yet been initialized.
158-
InitVisualizeSurface(rect);
158+
InitVisualizeSurface(SkISize::Make(rect.width(), rect.height()));
159159

160160
SkCanvas* cache_canvas = visualize_cache_surface_->getCanvas();
161161
SkPaint paint;
162162

163163
// Establish the graph position.
164164
const SkScalar x = 0;
165165
const SkScalar y = 0;
166-
const SkScalar width = rect.width();
167-
const SkScalar height = rect.height();
166+
const SkScalar width = visualize_cache_surface_->width();
167+
const SkScalar height = visualize_cache_surface_->height();
168168

169169
// Scale the graph to show frame times up to those that are 3 times the frame
170170
// time.

flow/instrumentation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Stopwatch {
3838

3939
fml::TimeDelta AverageDelta() const;
4040

41-
void InitVisualizeSurface(const SkRect& rect) const;
41+
void InitVisualizeSurface(SkISize size) const;
4242

4343
void Visualize(DlCanvas* canvas, const SkRect& rect) const;
4444

0 commit comments

Comments
 (0)