| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/web_contents/aura/gesture_nav_simple.h" | 5 #include "content/browser/web_contents/aura/gesture_nav_simple.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 CHECK(!image_.IsEmpty()); | 83 CHECK(!image_.IsEmpty()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 ~ArrowLayerDelegate() override {} | 86 ~ArrowLayerDelegate() override {} |
| 87 | 87 |
| 88 bool left() const { return left_arrow_; } | 88 bool left() const { return left_arrow_; } |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 // ui::LayerDelegate: | 91 // ui::LayerDelegate: |
| 92 void OnPaintLayer(const ui::PaintContext& context) override { | 92 void OnPaintLayer(const ui::PaintContext& context) override { |
| 93 cc::PaintFlags paint; | 93 cc::PaintFlags flags; |
| 94 paint.setColor(SkColorSetARGB(0xa0, 0, 0, 0)); | 94 flags.setColor(SkColorSetARGB(0xa0, 0, 0, 0)); |
| 95 paint.setStyle(cc::PaintFlags::kFill_Style); | 95 flags.setStyle(cc::PaintFlags::kFill_Style); |
| 96 paint.setAntiAlias(true); | 96 flags.setAntiAlias(true); |
| 97 | 97 |
| 98 // Set the recording size to be the size of the |arrow_| layer, and draw a | 98 // Set the recording size to be the size of the |arrow_| layer, and draw a |
| 99 // half circle (the other half will be clipped), then an arrow image inside | 99 // half circle (the other half will be clipped), then an arrow image inside |
| 100 // it. | 100 // it. |
| 101 ui::PaintRecorder recorder(context, gfx::Size(kArrowWidth, kArrowHeight)); | 101 ui::PaintRecorder recorder(context, gfx::Size(kArrowWidth, kArrowHeight)); |
| 102 recorder.canvas()->DrawCircle( | 102 recorder.canvas()->DrawCircle( |
| 103 gfx::Point(left_arrow_ ? 0 : kArrowWidth, kArrowHeight / 2), | 103 gfx::Point(left_arrow_ ? 0 : kArrowWidth, kArrowHeight / 2), |
| 104 kArrowWidth, paint); | 104 kArrowWidth, flags); |
| 105 recorder.canvas()->DrawImageInt( | 105 recorder.canvas()->DrawImageInt( |
| 106 *image_.ToImageSkia(), left_arrow_ ? 0 : kArrowWidth - image_.Width(), | 106 *image_.ToImageSkia(), left_arrow_ ? 0 : kArrowWidth - image_.Width(), |
| 107 (kArrowHeight - image_.Height()) / 2); | 107 (kArrowHeight - image_.Height()) / 2); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} | 110 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} |
| 111 | 111 |
| 112 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} | 112 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
| 113 | 113 |
| 114 const gfx::Image& image_; | 114 const gfx::Image& image_; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 clip_layer_->SetBounds(window->layer()->bounds()); | 231 clip_layer_->SetBounds(window->layer()->bounds()); |
| 232 clip_layer_->SetMasksToBounds(true); | 232 clip_layer_->SetMasksToBounds(true); |
| 233 clip_layer_->Add(arrow_.get()); | 233 clip_layer_->Add(arrow_.get()); |
| 234 | 234 |
| 235 ui::Layer* parent = window->layer()->parent(); | 235 ui::Layer* parent = window->layer()->parent(); |
| 236 parent->Add(clip_layer_.get()); | 236 parent->Add(clip_layer_.get()); |
| 237 parent->StackAtTop(clip_layer_.get()); | 237 parent->StackAtTop(clip_layer_.get()); |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace content | 240 } // namespace content |
| OLD | NEW |