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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.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" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 canvas->sk_canvas()->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), | 58 canvas->sk_canvas()->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), |
59 SkIntToScalar(size.width()), | 59 SkIntToScalar(size.width()), |
60 SkIntToScalar(size.height()), paint); | 60 SkIntToScalar(size.height()), paint); |
61 } | 61 } |
62 | 62 |
63 private: | 63 private: |
64 // If |horizontal_| is true then the gradiant is painted horizontally. | 64 // If |horizontal_| is true then the gradiant is painted horizontally. |
65 bool horizontal_; | 65 bool horizontal_; |
66 // The gradient colors. | 66 // The gradient colors. |
67 scoped_array<SkColor> colors_; | 67 scoped_ptr<SkColor[]> colors_; |
68 // The relative positions of the corresponding gradient colors. | 68 // The relative positions of the corresponding gradient colors. |
69 scoped_array<SkScalar> pos_; | 69 scoped_ptr<SkScalar[]> pos_; |
70 // The number of elements in |colors_| and |pos_|. | 70 // The number of elements in |colors_| and |pos_|. |
71 size_t count_; | 71 size_t count_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(GradientPainter); | 73 DISALLOW_COPY_AND_ASSIGN(GradientPainter); |
74 }; | 74 }; |
75 | 75 |
76 // ImagePainter stores and paints nine images as a scalable grid. | 76 // ImagePainter stores and paints nine images as a scalable grid. |
77 class VIEWS_EXPORT ImagePainter : public Painter { | 77 class VIEWS_EXPORT ImagePainter : public Painter { |
78 public: | 78 public: |
79 // Construct an ImagePainter with the specified image resource ids. | 79 // Construct an ImagePainter with the specified image resource ids. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 return; | 224 return; |
225 } | 225 } |
226 canvas->DrawImageInt(*images_[LEFT], 0, 0); | 226 canvas->DrawImageInt(*images_[LEFT], 0, 0); |
227 canvas->DrawImageInt(*images_[RIGHT], | 227 canvas->DrawImageInt(*images_[RIGHT], |
228 size.width() - images_[RIGHT]->width(), 0); | 228 size.width() - images_[RIGHT]->width(), 0); |
229 canvas->TileImageInt(*images_[CENTER], images_[LEFT]->width(), 0, | 229 canvas->TileImageInt(*images_[CENTER], images_[LEFT]->width(), 0, |
230 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(), height_); | 230 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(), height_); |
231 } | 231 } |
232 | 232 |
233 } // namespace views | 233 } // namespace views |
OLD | NEW |