| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/canvas.h" | 5 #include "ui/gfx/canvas.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "ui/gfx/canvas_skia_paint.h" | 21 #include "ui/gfx/canvas_skia_paint.h" |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 namespace gfx { | 24 namespace gfx { |
| 25 | 25 |
| 26 Canvas::Canvas(const gfx::Size& size, | 26 Canvas::Canvas(const gfx::Size& size, |
| 27 ui::ScaleFactor scale_factor, | 27 ui::ScaleFactor scale_factor, |
| 28 bool is_opaque) | 28 bool is_opaque) |
| 29 : scale_factor_(scale_factor), | 29 : scale_factor_(scale_factor), |
| 30 canvas_(NULL) { | 30 canvas_(NULL) { |
| 31 gfx::Size pixel_size = gfx::ToFlooredSize( | 31 gfx::Size pixel_size = gfx::ToCeiledSize( |
| 32 gfx::ScaleSize(size, ui::GetScaleFactorScale(scale_factor))); | 32 gfx::ScaleSize(size, ui::GetScaleFactorScale(scale_factor))); |
| 33 owned_canvas_ = skia::AdoptRef(skia::CreatePlatformCanvas(pixel_size.width(), | 33 owned_canvas_ = skia::AdoptRef(skia::CreatePlatformCanvas(pixel_size.width(), |
| 34 pixel_size.height(), | 34 pixel_size.height(), |
| 35 is_opaque)); | 35 is_opaque)); |
| 36 canvas_ = owned_canvas_.get(); | 36 canvas_ = owned_canvas_.get(); |
| 37 #if defined(OS_WIN) || defined(OS_MACOSX) | 37 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 38 // skia::PlatformCanvas instances are initialized to 0 by Cairo on Linux, but | 38 // skia::PlatformCanvas instances are initialized to 0 by Cairo on Linux, but |
| 39 // uninitialized on Win and Mac. | 39 // uninitialized on Win and Mac. |
| 40 if (!is_opaque) | 40 if (!is_opaque) |
| 41 owned_canvas_->clear(SkColorSetARGB(0, 0, 0, 0)); | 41 owned_canvas_->clear(SkColorSetARGB(0, 0, 0, 0)); |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 | 533 |
| 534 float bitmap_scale = image_rep.GetScale(); | 534 float bitmap_scale = image_rep.GetScale(); |
| 535 if (scale_x < bitmap_scale || scale_y < bitmap_scale) | 535 if (scale_x < bitmap_scale || scale_y < bitmap_scale) |
| 536 const_cast<SkBitmap&>(image_rep.sk_bitmap()).buildMipMap(); | 536 const_cast<SkBitmap&>(image_rep.sk_bitmap()).buildMipMap(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 return image_rep; | 539 return image_rep; |
| 540 } | 540 } |
| 541 | 541 |
| 542 } // namespace gfx | 542 } // namespace gfx |
| OLD | NEW |