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

Side by Side Diff: content/renderer/skia_benchmarking_extension.cc

Issue 556463002: Revert of tryAllocPixels returns bool, allocPixels requires success (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « content/common/cursors/webcursor_mac.mm ('k') | extensions/renderer/set_icon_natives.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/skia_benchmarking_extension.h" 5 #include "content/renderer/skia_benchmarking_extension.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 cc::MathUtil::FromValue(clip_value, &clip_rect); 151 cc::MathUtil::FromValue(clip_value, &clip_rect);
152 } 152 }
153 } 153 }
154 154
155 gfx::RectF clip(clip_rect); 155 gfx::RectF clip(clip_rect);
156 clip.Intersect(picture->LayerRect()); 156 clip.Intersect(picture->LayerRect());
157 clip.Scale(scale); 157 clip.Scale(scale);
158 gfx::Rect snapped_clip = gfx::ToEnclosingRect(clip); 158 gfx::Rect snapped_clip = gfx::ToEnclosingRect(clip);
159 159
160 SkBitmap bitmap; 160 SkBitmap bitmap;
161 if (!bitmap.tryAllocN32Pixels(snapped_clip.width(), snapped_clip.height())) 161 if (!bitmap.allocN32Pixels(snapped_clip.width(), snapped_clip.height()))
162 return; 162 return;
163 bitmap.eraseARGB(0, 0, 0, 0); 163 bitmap.eraseARGB(0, 0, 0, 0);
164 164
165 SkCanvas canvas(bitmap); 165 SkCanvas canvas(bitmap);
166 canvas.translate(SkFloatToScalar(-clip.x()), SkFloatToScalar(-clip.y())); 166 canvas.translate(SkFloatToScalar(-clip.x()), SkFloatToScalar(-clip.y()));
167 canvas.clipRect(gfx::RectToSkRect(snapped_clip)); 167 canvas.clipRect(gfx::RectToSkRect(snapped_clip));
168 canvas.scale(scale, scale); 168 canvas.scale(scale, scale);
169 canvas.translate(picture->LayerRect().x(), picture->LayerRect().y()); 169 canvas.translate(picture->LayerRect().x(), picture->LayerRect().y());
170 170
171 // First, build a debug canvas for the given picture. 171 // First, build a debug canvas for the given picture.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 v8::Handle<v8::Object> result = v8::Object::New(isolate); 303 v8::Handle<v8::Object> result = v8::Object::New(isolate);
304 result->Set(v8::String::NewFromUtf8(isolate, "width"), 304 result->Set(v8::String::NewFromUtf8(isolate, "width"),
305 v8::Number::New(isolate, picture->LayerRect().width())); 305 v8::Number::New(isolate, picture->LayerRect().width()));
306 result->Set(v8::String::NewFromUtf8(isolate, "height"), 306 result->Set(v8::String::NewFromUtf8(isolate, "height"),
307 v8::Number::New(isolate, picture->LayerRect().height())); 307 v8::Number::New(isolate, picture->LayerRect().height()));
308 308
309 args->Return(result); 309 args->Return(result);
310 } 310 }
311 311
312 } // namespace content 312 } // namespace content
OLDNEW
« no previous file with comments | « content/common/cursors/webcursor_mac.mm ('k') | extensions/renderer/set_icon_natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698