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

Side by Side Diff: chrome/browser/ui/views/infobars/infobar_container_view.cc

Issue 1831883002: Use sk_sp-based shader creation APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/infobars/infobar_container_view.h" 5 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
6 6
7 #include "chrome/browser/ui/infobar_container_delegate.h" 7 #include "chrome/browser/ui/infobar_container_delegate.h"
8 #include "chrome/browser/ui/view_ids.h" 8 #include "chrome/browser/ui/view_ids.h"
9 #include "chrome/browser/ui/views/infobars/infobar_view.h" 9 #include "chrome/browser/ui/views/infobars/infobar_view.h"
10 #include "chrome/grit/generated_resources.h" 10 #include "chrome/grit/generated_resources.h"
(...skipping 19 matching lines...) Expand all
30 SetPaintToLayer(true); 30 SetPaintToLayer(true);
31 layer()->SetFillsBoundsOpaquely(false); 31 layer()->SetFillsBoundsOpaquely(false);
32 } 32 }
33 ~ContentShadow() override {} 33 ~ContentShadow() override {}
34 34
35 protected: 35 protected:
36 // views::View: 36 // views::View:
37 void OnPaint(gfx::Canvas* canvas) override { 37 void OnPaint(gfx::Canvas* canvas) override {
38 // The first shader (small shadow) blurs from 0 to kSmallShadowHeight. 38 // The first shader (small shadow) blurs from 0 to kSmallShadowHeight.
39 SkPaint paint; 39 SkPaint paint;
40 skia::RefPtr<SkShader> shader = gfx::CreateGradientShader( 40 paint.setShader(gfx::CreateGradientShader(
41 0, kSmallShadowHeight, SkColorSetA(SK_ColorBLACK, kSmallShadowAlpha), 41 0, kSmallShadowHeight, SkColorSetA(SK_ColorBLACK, kSmallShadowAlpha),
42 SkColorSetA(SK_ColorBLACK, SK_AlphaTRANSPARENT)); 42 SkColorSetA(SK_ColorBLACK, SK_AlphaTRANSPARENT)));
43 paint.setShader(shader.get());
44 gfx::Rect small_shadow_bounds = GetLocalBounds(); 43 gfx::Rect small_shadow_bounds = GetLocalBounds();
45 small_shadow_bounds.set_height(kSmallShadowHeight); 44 small_shadow_bounds.set_height(kSmallShadowHeight);
46 canvas->DrawRect(small_shadow_bounds, paint); 45 canvas->DrawRect(small_shadow_bounds, paint);
47 46
48 // The second shader (large shadow) is solid from 0 to kSmallShadowHeight 47 // The second shader (large shadow) is solid from 0 to kSmallShadowHeight
49 // (blending with the first shader) and then blurs from kSmallShadowHeight 48 // (blending with the first shader) and then blurs from kSmallShadowHeight
50 // to kLargeShadowHeight. 49 // to kLargeShadowHeight.
51 shader = gfx::CreateGradientShader( 50 paint.setShader(gfx::CreateGradientShader(
52 kSmallShadowHeight, height(), 51 kSmallShadowHeight, height(),
53 SkColorSetA(SK_ColorBLACK, kLargeShadowAlpha), 52 SkColorSetA(SK_ColorBLACK, kLargeShadowAlpha),
54 SkColorSetA(SK_ColorBLACK, SK_AlphaTRANSPARENT)); 53 SkColorSetA(SK_ColorBLACK, SK_AlphaTRANSPARENT)));
55 paint.setShader(shader.get());
56 canvas->DrawRect(GetLocalBounds(), paint); 54 canvas->DrawRect(GetLocalBounds(), paint);
57 } 55 }
58 56
59 private: 57 private:
60 DISALLOW_COPY_AND_ASSIGN(ContentShadow); 58 DISALLOW_COPY_AND_ASSIGN(ContentShadow);
61 }; 59 };
62 60
63 } // namespace 61 } // namespace
64 62
65 // static 63 // static
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 infobars::InfoBar* infobar, 131 infobars::InfoBar* infobar,
134 size_t position) { 132 size_t position) {
135 AddChildViewAt(static_cast<InfoBarView*>(infobar), 133 AddChildViewAt(static_cast<InfoBarView*>(infobar),
136 static_cast<int>(position)); 134 static_cast<int>(position));
137 } 135 }
138 136
139 void InfoBarContainerView::PlatformSpecificRemoveInfoBar( 137 void InfoBarContainerView::PlatformSpecificRemoveInfoBar(
140 infobars::InfoBar* infobar) { 138 infobars::InfoBar* infobar) {
141 RemoveChildView(static_cast<InfoBarView*>(infobar)); 139 RemoveChildView(static_cast<InfoBarView*>(infobar));
142 } 140 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc ('k') | skia/ext/pixel_ref_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698