| 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/views/painter.h" | 5 #include "ui/views/painter.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 return gfx::Size(); | 62 return gfx::Size(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void SolidRoundRectPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { | 65 void SolidRoundRectPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { |
| 66 gfx::ScopedCanvas scoped_canvas(canvas); | 66 gfx::ScopedCanvas scoped_canvas(canvas); |
| 67 const float scale = canvas->UndoDeviceScaleFactor(); | 67 const float scale = canvas->UndoDeviceScaleFactor(); |
| 68 | 68 |
| 69 gfx::RectF border_rect_f(gfx::ScaleToEnclosingRect(gfx::Rect(size), scale)); | 69 gfx::RectF border_rect_f(gfx::ScaleToEnclosingRect(gfx::Rect(size), scale)); |
| 70 const SkScalar scaled_corner_radius = SkFloatToScalar(radius_ * scale); | 70 const SkScalar scaled_corner_radius = SkFloatToScalar(radius_ * scale); |
| 71 | 71 |
| 72 SkPaint paint; | 72 CdlPaint paint; |
| 73 paint.setAntiAlias(true); | 73 paint.setAntiAlias(true); |
| 74 paint.setStyle(SkPaint::kFill_Style); | 74 paint.setStyle(CdlPaint::kFill_Style); |
| 75 paint.setColor(bg_color_); | 75 paint.setColor(bg_color_); |
| 76 canvas->DrawRoundRect(border_rect_f, scaled_corner_radius, paint); | 76 canvas->DrawRoundRect(border_rect_f, scaled_corner_radius, paint); |
| 77 | 77 |
| 78 border_rect_f.Inset(gfx::InsetsF(0.5f)); | 78 border_rect_f.Inset(gfx::InsetsF(0.5f)); |
| 79 paint.setStyle(SkPaint::kStroke_Style); | 79 paint.setStyle(CdlPaint::kStroke_Style); |
| 80 paint.setStrokeWidth(1); | 80 paint.setStrokeWidth(1); |
| 81 paint.setColor(stroke_color_); | 81 paint.setColor(stroke_color_); |
| 82 canvas->DrawRoundRect(border_rect_f, scaled_corner_radius, paint); | 82 canvas->DrawRoundRect(border_rect_f, scaled_corner_radius, paint); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // DashedFocusPainter ---------------------------------------------------------- | 85 // DashedFocusPainter ---------------------------------------------------------- |
| 86 | 86 |
| 87 class DashedFocusPainter : public Painter { | 87 class DashedFocusPainter : public Painter { |
| 88 public: | 88 public: |
| 89 explicit DashedFocusPainter(const gfx::Insets& insets); | 89 explicit DashedFocusPainter(const gfx::Insets& insets); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 197 } |
| 198 | 198 |
| 199 GradientPainter::~GradientPainter() { | 199 GradientPainter::~GradientPainter() { |
| 200 } | 200 } |
| 201 | 201 |
| 202 gfx::Size GradientPainter::GetMinimumSize() const { | 202 gfx::Size GradientPainter::GetMinimumSize() const { |
| 203 return gfx::Size(); | 203 return gfx::Size(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void GradientPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { | 206 void GradientPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { |
| 207 SkPaint paint; | 207 CdlPaint paint; |
| 208 SkPoint p[2]; | 208 SkPoint p[2]; |
| 209 p[0].iset(0, 0); | 209 p[0].iset(0, 0); |
| 210 if (horizontal_) | 210 if (horizontal_) |
| 211 p[1].iset(size.width(), 0); | 211 p[1].iset(size.width(), 0); |
| 212 else | 212 else |
| 213 p[1].iset(0, size.height()); | 213 p[1].iset(0, size.height()); |
| 214 | 214 |
| 215 paint.setShader(SkGradientShader::MakeLinear( | 215 paint.setShader(WrapSkShader(SkGradientShader::MakeLinear( |
| 216 p, colors_.get(), pos_.get(), count_, SkShader::kClamp_TileMode)); | 216 p, colors_.get(), pos_.get(), count_, SkShader::kClamp_TileMode))); |
| 217 paint.setStyle(SkPaint::kFill_Style); | 217 paint.setStyle(CdlPaint::kFill_Style); |
| 218 | 218 |
| 219 canvas->sk_canvas()->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), | 219 canvas->sk_canvas()->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), |
| 220 SkIntToScalar(size.width()), | 220 SkIntToScalar(size.width()), |
| 221 SkIntToScalar(size.height()), paint); | 221 SkIntToScalar(size.height()), paint); |
| 222 } | 222 } |
| 223 | 223 |
| 224 // ImagePainter --------------------------------------------------------------- | 224 // ImagePainter --------------------------------------------------------------- |
| 225 | 225 |
| 226 // ImagePainter stores and paints nine images as a scalable grid. | 226 // ImagePainter stores and paints nine images as a scalable grid. |
| 227 class ImagePainter : public Painter { | 227 class ImagePainter : public Painter { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 canvas->DrawImageInt(*images_[LEFT], 0, 0); | 403 canvas->DrawImageInt(*images_[LEFT], 0, 0); |
| 404 canvas->DrawImageInt(*images_[RIGHT], size.width() - images_[RIGHT]->width(), | 404 canvas->DrawImageInt(*images_[RIGHT], size.width() - images_[RIGHT]->width(), |
| 405 0); | 405 0); |
| 406 canvas->TileImageInt( | 406 canvas->TileImageInt( |
| 407 *images_[CENTER], images_[LEFT]->width(), 0, | 407 *images_[CENTER], images_[LEFT]->width(), 0, |
| 408 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(), | 408 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(), |
| 409 images_[LEFT]->height()); | 409 images_[LEFT]->height()); |
| 410 } | 410 } |
| 411 | 411 |
| 412 } // namespace views | 412 } // namespace views |
| OLD | NEW |