OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/shadow_layer_delegate.h" | 5 #include "content/browser/web_contents/aura/shadow_layer_delegate.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "third_party/skia/include/effects/SkGradientShader.h" | 8 #include "third_party/skia/include/effects/SkGradientShader.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
11 #include "ui/compositor/paint_context.h" | 11 #include "ui/compositor/paint_recorder.h" |
12 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
13 #include "ui/gfx/skia_util.h" | 13 #include "ui/gfx/skia_util.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 const SkColor kShadowLightColor = SkColorSetARGB(0x0, 0, 0, 0); | 17 const SkColor kShadowLightColor = SkColorSetARGB(0x0, 0, 0, 0); |
18 const SkColor kShadowDarkColor = SkColorSetARGB(0x70, 0, 0, 0); | 18 const SkColor kShadowDarkColor = SkColorSetARGB(0x70, 0, 0, 0); |
19 const int kShadowThick = 7; | 19 const int kShadowThick = 7; |
20 | 20 |
21 } // namespace | 21 } // namespace |
(...skipping 20 matching lines...) Expand all Loading... |
42 points[1].iset(kShadowThick, 0); | 42 points[1].iset(kShadowThick, 0); |
43 | 43 |
44 skia::RefPtr<SkShader> shader = skia::AdoptRef( | 44 skia::RefPtr<SkShader> shader = skia::AdoptRef( |
45 SkGradientShader::CreateLinear(points, kShadowColors, NULL, | 45 SkGradientShader::CreateLinear(points, kShadowColors, NULL, |
46 arraysize(points), SkShader::kRepeat_TileMode)); | 46 arraysize(points), SkShader::kRepeat_TileMode)); |
47 | 47 |
48 gfx::Rect paint_rect = gfx::Rect(0, 0, kShadowThick, | 48 gfx::Rect paint_rect = gfx::Rect(0, 0, kShadowThick, |
49 layer_->bounds().height()); | 49 layer_->bounds().height()); |
50 SkPaint paint; | 50 SkPaint paint; |
51 paint.setShader(shader.get()); | 51 paint.setShader(shader.get()); |
52 context.canvas()->sk_canvas()->drawRect(gfx::RectToSkRect(paint_rect), paint); | 52 ui::PaintRecorder recorder(context); |
| 53 recorder.canvas()->sk_canvas()->drawRect(gfx::RectToSkRect(paint_rect), |
| 54 paint); |
53 } | 55 } |
54 | 56 |
55 void ShadowLayerDelegate::OnDelegatedFrameDamage( | 57 void ShadowLayerDelegate::OnDelegatedFrameDamage( |
56 const gfx::Rect& damage_rect_in_dip) { | 58 const gfx::Rect& damage_rect_in_dip) { |
57 } | 59 } |
58 | 60 |
59 void ShadowLayerDelegate::OnDeviceScaleFactorChanged(float scale_factor) { | 61 void ShadowLayerDelegate::OnDeviceScaleFactorChanged(float scale_factor) { |
60 } | 62 } |
61 | 63 |
62 base::Closure ShadowLayerDelegate::PrepareForLayerBoundsChange() { | 64 base::Closure ShadowLayerDelegate::PrepareForLayerBoundsChange() { |
63 return base::Bind(&base::DoNothing); | 65 return base::Bind(&base::DoNothing); |
64 } | 66 } |
65 | 67 |
66 } // namespace content | 68 } // namespace content |
OLD | NEW |