| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "cc/input/scrollbar.h" | 9 #include "cc/input/scrollbar.h" |
| 10 #include "cc/layers/painted_scrollbar_layer.h" | 10 #include "cc/layers/painted_scrollbar_layer.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 bool IsOverlay() const override { return false; } | 46 bool IsOverlay() const override { return false; } |
| 47 bool HasThumb() const override { return thumb_; } | 47 bool HasThumb() const override { return thumb_; } |
| 48 int ThumbThickness() const override { return rect_.width(); } | 48 int ThumbThickness() const override { return rect_.width(); } |
| 49 int ThumbLength() const override { return rect_.height(); } | 49 int ThumbLength() const override { return rect_.height(); } |
| 50 gfx::Rect TrackRect() const override { return rect_; } | 50 gfx::Rect TrackRect() const override { return rect_; } |
| 51 float ThumbOpacity() const override { return 1.f; } | 51 float ThumbOpacity() const override { return 1.f; } |
| 52 bool NeedsPaintPart(ScrollbarPart part) const override { return true; } | 52 bool NeedsPaintPart(ScrollbarPart part) const override { return true; } |
| 53 void PaintPart(PaintCanvas* canvas, | 53 void PaintPart(PaintCanvas* canvas, |
| 54 ScrollbarPart part, | 54 ScrollbarPart part, |
| 55 const gfx::Rect& content_rect) override { | 55 const gfx::Rect& content_rect) override { |
| 56 PaintFlags paint; | 56 PaintFlags flags; |
| 57 paint.setStyle(PaintFlags::kStroke_Style); | 57 flags.setStyle(PaintFlags::kStroke_Style); |
| 58 paint.setStrokeWidth(SkIntToScalar(paint_scale_)); | 58 flags.setStrokeWidth(SkIntToScalar(paint_scale_)); |
| 59 paint.setColor(color_); | 59 flags.setColor(color_); |
| 60 | 60 |
| 61 gfx::Rect inset_rect = content_rect; | 61 gfx::Rect inset_rect = content_rect; |
| 62 while (!inset_rect.IsEmpty()) { | 62 while (!inset_rect.IsEmpty()) { |
| 63 int big = paint_scale_ + 2; | 63 int big = paint_scale_ + 2; |
| 64 int small = paint_scale_; | 64 int small = paint_scale_; |
| 65 inset_rect.Inset(big, big, small, small); | 65 inset_rect.Inset(big, big, small, small); |
| 66 canvas->drawRect(RectToSkRect(inset_rect), paint); | 66 canvas->drawRect(RectToSkRect(inset_rect), flags); |
| 67 inset_rect.Inset(big, big, small, small); | 67 inset_rect.Inset(big, big, small, small); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 void set_paint_scale(int scale) { paint_scale_ = scale; } | 71 void set_paint_scale(int scale) { paint_scale_ = scale; } |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 int paint_scale_ = 4; | 74 int paint_scale_ = 4; |
| 75 bool thumb_ = false; | 75 bool thumb_ = false; |
| 76 SkColor color_ = SK_ColorGREEN; | 76 SkColor color_ = SK_ColorGREEN; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 layer->SetTransform(scale_transform); | 165 layer->SetTransform(scale_transform); |
| 166 | 166 |
| 167 RunPixelTest(PIXEL_TEST_GL, background, | 167 RunPixelTest(PIXEL_TEST_GL, background, |
| 168 base::FilePath(FILE_PATH_LITERAL("spiral_64_scale.png"))); | 168 base::FilePath(FILE_PATH_LITERAL("spiral_64_scale.png"))); |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace | 171 } // namespace |
| 172 } // namespace cc | 172 } // namespace cc |
| 173 | 173 |
| 174 #endif // OS_ANDROID | 174 #endif // OS_ANDROID |
| OLD | NEW |