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 "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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 colors_[1] = bottom; | 26 colors_[1] = bottom; |
27 } | 27 } |
28 | 28 |
29 virtual ~GradientPainter() { | 29 virtual ~GradientPainter() { |
30 } | 30 } |
31 | 31 |
32 // Overridden from Painter: | 32 // Overridden from Painter: |
33 virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE { | 33 virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE { |
34 SkPaint paint; | 34 SkPaint paint; |
35 SkPoint p[2]; | 35 SkPoint p[2]; |
36 p[0].set(SkIntToScalar(0), SkIntToScalar(0)); | 36 p[0].iset(0, 0); |
37 if (horizontal_) | 37 if (horizontal_) |
38 p[1].set(SkIntToScalar(size.width()), SkIntToScalar(0)); | 38 p[1].iset(size.width(), 0); |
39 else | 39 else |
40 p[1].set(SkIntToScalar(0), SkIntToScalar(size.height())); | 40 p[1].iset(0, size.height()); |
41 | 41 |
42 SkShader* s = | 42 SkShader* s = SkGradientShader::CreateLinear(p, colors_, NULL, 2, |
43 SkGradientShader::CreateLinear(p, colors_, NULL, 2, | 43 SkShader::kClamp_TileMode, NULL); |
44 SkShader::kClamp_TileMode, NULL); | |
45 paint.setStyle(SkPaint::kFill_Style); | 44 paint.setStyle(SkPaint::kFill_Style); |
46 paint.setShader(s); | 45 paint.setShader(s); |
47 // Need to unref shader, otherwise never deleted. | 46 // Need to unref shader, otherwise never deleted. |
48 s->unref(); | 47 s->unref(); |
49 | 48 |
50 canvas->GetSkCanvas()->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), | 49 canvas->GetSkCanvas()->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), |
51 SkIntToScalar(size.width()), | 50 SkIntToScalar(size.width()), |
52 SkIntToScalar(size.height()), paint); | 51 SkIntToScalar(size.height()), paint); |
53 } | 52 } |
54 | 53 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 return; | 194 return; |
196 } | 195 } |
197 canvas->DrawBitmapInt(*images_[LEFT], 0, 0); | 196 canvas->DrawBitmapInt(*images_[LEFT], 0, 0); |
198 canvas->DrawBitmapInt(*images_[RIGHT], | 197 canvas->DrawBitmapInt(*images_[RIGHT], |
199 size.width() - images_[RIGHT]->width(), 0); | 198 size.width() - images_[RIGHT]->width(), 0); |
200 canvas->TileImageInt(*images_[CENTER], images_[LEFT]->width(), 0, | 199 canvas->TileImageInt(*images_[CENTER], images_[LEFT]->width(), 0, |
201 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(), height_); | 200 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(), height_); |
202 } | 201 } |
203 | 202 |
204 } // namespace views | 203 } // namespace views |
OLD | NEW |