Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Side by Side Diff: content/browser/web_contents/aura/gesture_nav_simple.cc

Issue 1057873004: Pass a ui::PaintContext from ui::Layer to layer delegates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: layer-paintcontext: mac Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "cc/layers/layer.h" 7 #include "cc/layers/layer.h"
8 #include "content/browser/frame_host/navigation_controller_impl.h" 8 #include "content/browser/frame_host/navigation_controller_impl.h"
9 #include "content/browser/renderer_host/overscroll_controller.h" 9 #include "content/browser/renderer_host/overscroll_controller.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
11 #include "content/browser/web_contents/web_contents_view.h" 11 #include "content/browser/web_contents/web_contents_view.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/overscroll_configuration.h" 13 #include "content/public/browser/overscroll_configuration.h"
14 #include "content/public/common/content_client.h" 14 #include "content/public/common/content_client.h"
15 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
16 #include "ui/compositor/layer.h" 16 #include "ui/compositor/layer.h"
17 #include "ui/compositor/layer_animation_observer.h" 17 #include "ui/compositor/layer_animation_observer.h"
18 #include "ui/compositor/layer_delegate.h" 18 #include "ui/compositor/layer_delegate.h"
19 #include "ui/compositor/paint_context.h"
19 #include "ui/compositor/scoped_layer_animation_settings.h" 20 #include "ui/compositor/scoped_layer_animation_settings.h"
20 #include "ui/gfx/animation/tween.h" 21 #include "ui/gfx/animation/tween.h"
21 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
22 #include "ui/gfx/image/image.h" 23 #include "ui/gfx/image/image.h"
23 #include "ui/resources/grit/ui_resources.h" 24 #include "ui/resources/grit/ui_resources.h"
24 25
25 namespace content { 26 namespace content {
26 27
27 namespace { 28 namespace {
28 29
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 left_arrow_(resource_id == IDR_BACK_ARROW) { 78 left_arrow_(resource_id == IDR_BACK_ARROW) {
78 CHECK(!image_.IsEmpty()); 79 CHECK(!image_.IsEmpty());
79 } 80 }
80 81
81 ~ArrowLayerDelegate() override {} 82 ~ArrowLayerDelegate() override {}
82 83
83 bool left() const { return left_arrow_; } 84 bool left() const { return left_arrow_; }
84 85
85 private: 86 private:
86 // ui::LayerDelegate: 87 // ui::LayerDelegate:
87 void OnPaintLayer(gfx::Canvas* canvas) override { 88 void OnPaintLayer(const ui::PaintContext& context) override {
88 SkPaint paint; 89 SkPaint paint;
89 paint.setColor(SkColorSetARGB(0xa0, 0, 0, 0)); 90 paint.setColor(SkColorSetARGB(0xa0, 0, 0, 0));
90 paint.setStyle(SkPaint::kFill_Style); 91 paint.setStyle(SkPaint::kFill_Style);
91 paint.setAntiAlias(true); 92 paint.setAntiAlias(true);
92 93
94 gfx::Canvas* canvas = context.canvas();
93 canvas->DrawCircle( 95 canvas->DrawCircle(
94 gfx::Point(left_arrow_ ? 0 : kArrowWidth, kArrowHeight / 2), 96 gfx::Point(left_arrow_ ? 0 : kArrowWidth, kArrowHeight / 2),
95 kArrowWidth, 97 kArrowWidth,
96 paint); 98 paint);
97 canvas->DrawImageInt(*image_.ToImageSkia(), 99 canvas->DrawImageInt(*image_.ToImageSkia(),
98 left_arrow_ ? 0 : kArrowWidth - image_.Width(), 100 left_arrow_ ? 0 : kArrowWidth - image_.Width(),
99 (kArrowHeight - image_.Height()) / 2); 101 (kArrowHeight - image_.Height()) / 2);
100 } 102 }
101 103
102 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} 104 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {}
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 clip_layer_->SetBounds(window->layer()->bounds()); 228 clip_layer_->SetBounds(window->layer()->bounds());
227 clip_layer_->SetMasksToBounds(true); 229 clip_layer_->SetMasksToBounds(true);
228 clip_layer_->Add(arrow_.get()); 230 clip_layer_->Add(arrow_.get());
229 231
230 ui::Layer* parent = window->layer()->parent(); 232 ui::Layer* parent = window->layer()->parent();
231 parent->Add(clip_layer_.get()); 233 parent->Add(clip_layer_.get());
232 parent->StackAtTop(clip_layer_.get()); 234 parent->StackAtTop(clip_layer_.get());
233 } 235 }
234 236
235 } // namespace content 237 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698