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

Unified Diff: ui/gfx/canvas.cc

Issue 303543004: MacViews: views_examples_with_content_exe working! Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add files Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/cocoa/events_mac.mm ('k') | ui/gfx/gfx.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/canvas.cc
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index 6303d874abf5541ab268f950e9938117266d03ec..99b98cace480a35e1a278a787aac9b94b0c3bf8c 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -26,6 +26,7 @@ namespace gfx {
Canvas::Canvas(const Size& size, float image_scale, bool is_opaque)
: image_scale_(image_scale),
canvas_(NULL) {
+ DCHECK_NE(0.0, image_scale_);
Size pixel_size = ToCeiledSize(ScaleSize(size, image_scale));
owned_canvas_ = skia::AdoptRef(skia::CreatePlatformCanvas(pixel_size.width(),
pixel_size.height(),
@@ -49,6 +50,7 @@ Canvas::Canvas(const ImageSkiaRep& image_rep, bool is_opaque)
image_rep.pixel_height(),
is_opaque))),
canvas_(owned_canvas_.get()) {
+ DCHECK_NE(0.0, image_scale_);
SkScalar scale_scalar = SkFloatToScalar(image_scale_);
canvas_->scale(scale_scalar, scale_scalar);
DrawImageInt(ImageSkia(image_rep), 0, 0);
@@ -73,6 +75,7 @@ void Canvas::RecreateBackingCanvas(const Size& size,
float image_scale,
bool is_opaque) {
image_scale_ = image_scale;
+ DCHECK_NE(0.0, image_scale_);
Size pixel_size = ToFlooredSize(ScaleSize(size, image_scale));
owned_canvas_ = skia::AdoptRef(skia::CreatePlatformCanvas(pixel_size.width(),
pixel_size.height(),
@@ -335,6 +338,9 @@ void Canvas::DrawImageInt(const ImageSkia& image,
int x,
int y,
const SkPaint& paint) {
+ if (image_scale_ == 0)
+ DLOG(ERROR) << "0 image scale??";
+ image_scale_ = 1;
const ImageSkiaRep& image_rep = image.GetRepresentation(image_scale_);
if (image_rep.is_null())
return;
« no previous file with comments | « ui/events/cocoa/events_mac.mm ('k') | ui/gfx/gfx.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698