| 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_skia.h" | 5 #include "ui/gfx/canvas_skia.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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 namespace gfx { | 48 namespace gfx { |
| 49 | 49 |
| 50 //////////////////////////////////////////////////////////////////////////////// | 50 //////////////////////////////////////////////////////////////////////////////// |
| 51 // CanvasSkia, public: | 51 // CanvasSkia, public: |
| 52 | 52 |
| 53 CanvasSkia::CanvasSkia(const gfx::Size& size, bool is_opaque) | 53 CanvasSkia::CanvasSkia(const gfx::Size& size, bool is_opaque) |
| 54 : owned_canvas_(new skia::PlatformCanvas(size.width(), size.height(), | 54 : owned_canvas_(new skia::PlatformCanvas(size.width(), size.height(), |
| 55 is_opaque)), | 55 is_opaque)), |
| 56 canvas_(owned_canvas_.get()) { | 56 canvas_(owned_canvas_.get()) { |
| 57 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 58 // skia::PlatformCanvas instances are initialized to 0 by Cairo on Linux, but |
| 59 // uninitialized on Win and Mac. |
| 60 if (!is_opaque) |
| 61 owned_canvas_->clear(SkColorSetARGB(0, 0, 0, 0)); |
| 62 #endif |
| 57 } | 63 } |
| 58 | 64 |
| 59 CanvasSkia::CanvasSkia(const SkBitmap& bitmap, bool is_opaque) | 65 CanvasSkia::CanvasSkia(const SkBitmap& bitmap, bool is_opaque) |
| 60 : owned_canvas_(new skia::PlatformCanvas(bitmap.width(), bitmap.height(), | 66 : owned_canvas_(new skia::PlatformCanvas(bitmap.width(), bitmap.height(), |
| 61 is_opaque)), | 67 is_opaque)), |
| 62 canvas_(owned_canvas_.get()) { | 68 canvas_(owned_canvas_.get()) { |
| 63 DrawBitmapInt(bitmap, 0, 0); | 69 DrawBitmapInt(bitmap, 0, 0); |
| 64 } | 70 } |
| 65 | 71 |
| 66 CanvasSkia::CanvasSkia() | 72 CanvasSkia::CanvasSkia() |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 // CanvasSkia, private: | 380 // CanvasSkia, private: |
| 375 | 381 |
| 376 bool CanvasSkia::IntersectsClipRectInt(int x, int y, int w, int h) { | 382 bool CanvasSkia::IntersectsClipRectInt(int x, int y, int w, int h) { |
| 377 SkRect clip; | 383 SkRect clip; |
| 378 return canvas_->getClipBounds(&clip) && | 384 return canvas_->getClipBounds(&clip) && |
| 379 clip.intersect(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(x + w), | 385 clip.intersect(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(x + w), |
| 380 SkIntToScalar(y + h)); | 386 SkIntToScalar(y + h)); |
| 381 } | 387 } |
| 382 | 388 |
| 383 } // namespace gfx | 389 } // namespace gfx |
| OLD | NEW |