| 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" |
| 11 #include "cc/layers/solid_color_layer.h" | 11 #include "cc/layers/solid_color_layer.h" |
| 12 #include "cc/test/layer_tree_pixel_test.h" | 12 #include "cc/test/layer_tree_pixel_test.h" |
| 13 #include "cc/test/test_in_process_context_provider.h" | 13 #include "cc/test/test_in_process_context_provider.h" |
| 14 #include "gpu/command_buffer/client/gles2_interface.h" | 14 #include "gpu/command_buffer/client/gles2_interface.h" |
| 15 #include "skia/ext/cdl_canvas.h" |
| 16 #include "skia/ext/cdl_paint.h" |
| 15 | 17 |
| 16 #if !defined(OS_ANDROID) | 18 #if !defined(OS_ANDROID) |
| 17 | 19 |
| 18 namespace cc { | 20 namespace cc { |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 class LayerTreeHostScrollbarsPixelTest : public LayerTreePixelTest { | 23 class LayerTreeHostScrollbarsPixelTest : public LayerTreePixelTest { |
| 22 protected: | 24 protected: |
| 23 LayerTreeHostScrollbarsPixelTest() = default; | 25 LayerTreeHostScrollbarsPixelTest() = default; |
| 24 | 26 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 42 ScrollbarOrientation Orientation() const override { return VERTICAL; } | 44 ScrollbarOrientation Orientation() const override { return VERTICAL; } |
| 43 bool IsLeftSideVerticalScrollbar() const override { return false; } | 45 bool IsLeftSideVerticalScrollbar() const override { return false; } |
| 44 gfx::Point Location() const override { return gfx::Point(); } | 46 gfx::Point Location() const override { return gfx::Point(); } |
| 45 bool IsOverlay() const override { return false; } | 47 bool IsOverlay() const override { return false; } |
| 46 bool HasThumb() const override { return thumb_; } | 48 bool HasThumb() const override { return thumb_; } |
| 47 int ThumbThickness() const override { return rect_.width(); } | 49 int ThumbThickness() const override { return rect_.width(); } |
| 48 int ThumbLength() const override { return rect_.height(); } | 50 int ThumbLength() const override { return rect_.height(); } |
| 49 gfx::Rect TrackRect() const override { return rect_; } | 51 gfx::Rect TrackRect() const override { return rect_; } |
| 50 float ThumbOpacity() const override { return 1.f; } | 52 float ThumbOpacity() const override { return 1.f; } |
| 51 bool NeedsPaintPart(ScrollbarPart part) const override { return true; } | 53 bool NeedsPaintPart(ScrollbarPart part) const override { return true; } |
| 52 void PaintPart(SkCanvas* canvas, | 54 void PaintPart(CdlCanvas* canvas, |
| 53 ScrollbarPart part, | 55 ScrollbarPart part, |
| 54 const gfx::Rect& content_rect) override { | 56 const gfx::Rect& content_rect) override { |
| 55 SkPaint paint; | 57 CdlPaint paint; |
| 56 paint.setStyle(SkPaint::kStroke_Style); | 58 paint.setStyle(CdlPaint::kStroke_Style); |
| 57 paint.setStrokeWidth(SkIntToScalar(paint_scale_)); | 59 paint.setStrokeWidth(SkIntToScalar(paint_scale_)); |
| 58 paint.setColor(color_); | 60 paint.setColor(color_); |
| 59 | 61 |
| 60 gfx::Rect inset_rect = content_rect; | 62 gfx::Rect inset_rect = content_rect; |
| 61 while (!inset_rect.IsEmpty()) { | 63 while (!inset_rect.IsEmpty()) { |
| 62 int big = paint_scale_ + 2; | 64 int big = paint_scale_ + 2; |
| 63 int small = paint_scale_; | 65 int small = paint_scale_; |
| 64 inset_rect.Inset(big, big, small, small); | 66 inset_rect.Inset(big, big, small, small); |
| 65 canvas->drawRect(RectToSkRect(inset_rect), paint); | 67 canvas->drawRect(RectToSkRect(inset_rect), paint); |
| 66 inset_rect.Inset(big, big, small, small); | 68 inset_rect.Inset(big, big, small, small); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 layer->SetTransform(scale_transform); | 166 layer->SetTransform(scale_transform); |
| 165 | 167 |
| 166 RunPixelTest(PIXEL_TEST_GL, background, | 168 RunPixelTest(PIXEL_TEST_GL, background, |
| 167 base::FilePath(FILE_PATH_LITERAL("spiral_64_scale.png"))); | 169 base::FilePath(FILE_PATH_LITERAL("spiral_64_scale.png"))); |
| 168 } | 170 } |
| 169 | 171 |
| 170 } // namespace | 172 } // namespace |
| 171 } // namespace cc | 173 } // namespace cc |
| 172 | 174 |
| 173 #endif // OS_ANDROID | 175 #endif // OS_ANDROID |
| OLD | NEW |