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

Side by Side Diff: chrome/browser/chromeos/login/rounded_view.h

Issue 8122013: Allow CanvasSkia to bind to an existing SkCanvas. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 1 more fix Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_ROUNDED_VIEW_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_ROUNDED_VIEW_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ROUNDED_VIEW_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ROUNDED_VIEW_H_
7 7
8 #include "ui/gfx/canvas.h" 8 #include "ui/gfx/canvas.h"
9 #include "ui/gfx/canvas_skia.h" 9 #include "ui/gfx/canvas_skia.h"
10 #include "ui/gfx/rect.h" 10 #include "ui/gfx/rect.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Draws custom frame for the view. 54 // Draws custom frame for the view.
55 virtual void DrawFrame(gfx::Canvas* canvas); 55 virtual void DrawFrame(gfx::Canvas* canvas);
56 }; 56 };
57 57
58 // RoundedView implementation. 58 // RoundedView implementation.
59 59
60 template <typename C> 60 template <typename C>
61 void RoundedView<C>::Paint(gfx::Canvas* canvas) { 61 void RoundedView<C>::Paint(gfx::Canvas* canvas) {
62 // Setup clip region. 62 // Setup clip region.
63 canvas->Save(); 63 canvas->Save();
64 canvas->AsCanvasSkia()->clipPath(GetClipPath()); 64 canvas->GetSkCanvas()->clipPath(GetClipPath());
65 // Do original painting. 65 // Do original painting.
66 C::Paint(canvas); 66 C::Paint(canvas);
67 canvas->Restore(); 67 canvas->Restore();
68 // Add frame. 68 // Add frame.
69 DrawFrame(canvas); 69 DrawFrame(canvas);
70 } 70 }
71 71
72 template <typename C> 72 template <typename C>
73 SkPath RoundedView<C>::GetClipPath() const { 73 SkPath RoundedView<C>::GetClipPath() const {
74 SkPath round_view; 74 SkPath round_view;
(...skipping 30 matching lines...) Expand all
105 105
106 // Used to make nested rounded rects look better. 106 // Used to make nested rounded rects look better.
107 const SkScalar kOriginShift = 1.0; 107 const SkScalar kOriginShift = 1.0;
108 const SkScalar kDelta = 0.3; 108 const SkScalar kDelta = 0.3;
109 109
110 // Draw inner frame. 110 // Draw inner frame.
111 view_rect.fLeft -= kOriginShift; 111 view_rect.fLeft -= kOriginShift;
112 view_rect.fTop -= kOriginShift; 112 view_rect.fTop -= kOriginShift;
113 view_rect.inset(rounded_view::kStrokeWidth, rounded_view::kStrokeWidth); 113 view_rect.inset(rounded_view::kStrokeWidth, rounded_view::kStrokeWidth);
114 paint.setColor(rounded_view::kInnerFrameColor); 114 paint.setColor(rounded_view::kInnerFrameColor);
115 canvas->AsCanvasSkia()-> 115 canvas->GetSkCanvas()->
116 drawRoundRect(view_rect, 116 drawRoundRect(view_rect,
117 rounded_view::kCornerRadius - rounded_view::kStrokeWidth, 117 rounded_view::kCornerRadius - rounded_view::kStrokeWidth,
118 rounded_view::kCornerRadius - rounded_view::kStrokeWidth, 118 rounded_view::kCornerRadius - rounded_view::kStrokeWidth,
119 paint); 119 paint);
120 120
121 // Draw outer frame. 121 // Draw outer frame.
122 view_rect.fLeft -= kDelta; 122 view_rect.fLeft -= kDelta;
123 view_rect.fTop -= kDelta; 123 view_rect.fTop -= kDelta;
124 view_rect.offset(rounded_view::kStrokeWidth - kDelta, 124 view_rect.offset(rounded_view::kStrokeWidth - kDelta,
125 rounded_view::kStrokeWidth - kDelta); 125 rounded_view::kStrokeWidth - kDelta);
126 paint.setColor(rounded_view::kOuterFrameColor); 126 paint.setColor(rounded_view::kOuterFrameColor);
127 canvas->AsCanvasSkia()->drawRoundRect(view_rect, rounded_view::kCornerRadius, 127 canvas->GetSkCanvas()->drawRoundRect(view_rect, rounded_view::kCornerRadius,
128 rounded_view::kCornerRadius, paint); 128 rounded_view::kCornerRadius, paint);
129 } 129 }
130 130
131 } 131 }
132 132
133 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ROUNDED_VIEW_H_ 133 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ROUNDED_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698