| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/views/painter.h" | 5 #include "ui/views/painter.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
| 9 #include "third_party/skia/include/effects/SkGradientShader.h" | 9 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| 11 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
| 12 #include "ui/gfx/canvas_skia.h" | 12 #include "ui/gfx/canvas_skia.h" |
| 13 #include "ui/gfx/insets.h" | 13 #include "ui/gfx/insets.h" |
| 14 #include "ui/gfx/point.h" | 14 #include "ui/gfx/point.h" |
| 15 #include "ui/gfx/rect.h" |
| 15 | 16 |
| 16 namespace views { | 17 namespace views { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 class GradientPainter : public Painter { | 21 class GradientPainter : public Painter { |
| 21 public: | 22 public: |
| 22 GradientPainter(bool horizontal, const SkColor& top, const SkColor& bottom) | 23 GradientPainter(bool horizontal, const SkColor& top, const SkColor& bottom) |
| 23 : horizontal_(horizontal) { | 24 : horizontal_(horizontal) { |
| 24 colors_[0] = top; | 25 colors_[0] = top; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 183 } |
| 183 | 184 |
| 184 void HorizontalPainter::Paint(int w, int h, gfx::Canvas* canvas) { | 185 void HorizontalPainter::Paint(int w, int h, gfx::Canvas* canvas) { |
| 185 if (w < (images_[LEFT]->width() + images_[CENTER]->width() + | 186 if (w < (images_[LEFT]->width() + images_[CENTER]->width() + |
| 186 images_[RIGHT]->width())) { | 187 images_[RIGHT]->width())) { |
| 187 // No room to paint. | 188 // No room to paint. |
| 188 return; | 189 return; |
| 189 } | 190 } |
| 190 canvas->DrawBitmapInt(*images_[LEFT], 0, 0); | 191 canvas->DrawBitmapInt(*images_[LEFT], 0, 0); |
| 191 canvas->DrawBitmapInt(*images_[RIGHT], w - images_[RIGHT]->width(), 0); | 192 canvas->DrawBitmapInt(*images_[RIGHT], w - images_[RIGHT]->width(), 0); |
| 192 canvas->TileImageInt(*images_[CENTER], | 193 canvas->TileImage(*images_[CENTER], gfx::Rect(images_[LEFT]->width(), 0, |
| 193 images_[LEFT]->width(), | 194 w - images_[LEFT]->width() - images_[RIGHT]->width(), height_)); |
| 194 0, | |
| 195 w - images_[LEFT]->width() - images_[RIGHT]->width(), | |
| 196 height_); | |
| 197 } | 195 } |
| 198 | 196 |
| 199 } // namespace views | 197 } // namespace views |
| OLD | NEW |