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

Side by Side Diff: Source/platform/scroll/ScrollbarThemeMacCommon.mm

Issue 1170523002: Removing GraphicsContext from ImageBuffer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix for shape bug Created 5 years, 6 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 /* 1 /*
2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 void ScrollbarThemeMacCommon::registerScrollbar(ScrollbarThemeClient* scrollbar) 91 void ScrollbarThemeMacCommon::registerScrollbar(ScrollbarThemeClient* scrollbar)
92 { 92 {
93 scrollbarSet().add(scrollbar); 93 scrollbarSet().add(scrollbar);
94 } 94 }
95 95
96 void ScrollbarThemeMacCommon::unregisterScrollbar(ScrollbarThemeClient* scrollba r) 96 void ScrollbarThemeMacCommon::unregisterScrollbar(ScrollbarThemeClient* scrollba r)
97 { 97 {
98 scrollbarSet().remove(scrollbar); 98 scrollbarSet().remove(scrollbar);
99 } 99 }
100 100
101 void ScrollbarThemeMacCommon::paintGivenTickmarks(GraphicsContext* context, Scro llbarThemeClient* scrollbar, const IntRect& rect, const Vector<IntRect>& tickmar ks) 101 void ScrollbarThemeMacCommon::paintGivenTickmarks(SkCanvas* canvas, ScrollbarThe meClient* scrollbar, const IntRect& rect, const Vector<IntRect>& tickmarks)
102 { 102 {
103 if (scrollbar->orientation() != VerticalScrollbar) 103 if (scrollbar->orientation() != VerticalScrollbar)
104 return; 104 return;
105 105
106 if (rect.height() <= 0 || rect.width() <= 0) 106 if (rect.height() <= 0 || rect.width() <= 0)
107 return; // nothing to draw on. 107 return; // nothing to draw on.
108 108
109 if (!tickmarks.size()) 109 if (!tickmarks.size())
110 return; 110 return;
111 111
112 GraphicsContextStateSaver stateSaver(*context); 112 SkAutoCanvasRestore stateSaver(canvas, true);
113 context->setShouldAntialias(false); 113
114 context->setStrokeColor(Color(0xCC, 0xAA, 0x00, 0xFF)); 114 SkPaint strokePaint;
115 context->setFillColor(Color(0xFF, 0xDD, 0x00, 0xFF)); 115 strokePaint.setAntiAlias(false);
116 strokePaint.setColor(SkColorSetRGB(0xCC, 0xAA, 0x00));
117 strokePaint.setStyle(SkPaint::kStroke_Style);
118
119 SkPaint fillPaint;
120 fillPaint.setAntiAlias(false);
121 fillPaint.setColor(SkColorSetRGB(0xFF, 0xDD, 0x00));
122 fillPaint.setStyle(SkPaint::kFill_Style);
116 123
117 for (Vector<IntRect>::const_iterator i = tickmarks.begin(); i != tickmarks.e nd(); ++i) { 124 for (Vector<IntRect>::const_iterator i = tickmarks.begin(); i != tickmarks.e nd(); ++i) {
118 // Calculate how far down (in %) the tick-mark should appear. 125 // Calculate how far down (in %) the tick-mark should appear.
119 const float percent = static_cast<float>(i->y()) / scrollbar->totalSize( ); 126 const float percent = static_cast<float>(i->y()) / scrollbar->totalSize( );
120 if (percent < 0.0 || percent > 1.0) 127 if (percent < 0.0 || percent > 1.0)
121 continue; 128 continue;
122 129
123 // Calculate how far down (in pixels) the tick-mark should appear. 130 // Calculate how far down (in pixels) the tick-mark should appear.
124 const int yPos = rect.y() + (rect.height() * percent); 131 const int yPos = rect.y() + (rect.height() * percent);
125 132
126 // Paint. 133 // Paint.
127 FloatRect tickRect(rect.x(), yPos, rect.width(), 2); 134 FloatRect tickRect(rect.x(), yPos, rect.width(), 2);
128 context->fillRect(tickRect); 135 canvas->drawRect(tickRect, fillPaint);
129 context->strokeRect(tickRect, 1); 136 canvas->drawRect(tickRect, strokePaint);
130 } 137 }
131 } 138 }
132 139
133 void ScrollbarThemeMacCommon::paintTickmarks(GraphicsContext* context, Scrollbar ThemeClient* scrollbar, const IntRect& rect) 140 void ScrollbarThemeMacCommon::paintTickmarks(GraphicsContext* context, Scrollbar ThemeClient* scrollbar, const IntRect& rect)
134 { 141 {
135 // Note: This is only used for css-styled scrollbars on mac. 142 // Note: This is only used for css-styled scrollbars on mac.
136 if (scrollbar->orientation() != VerticalScrollbar) 143 if (scrollbar->orientation() != VerticalScrollbar)
137 return; 144 return;
138 145
139 if (rect.height() <= 0 || rect.width() <= 0) 146 if (rect.height() <= 0 || rect.width() <= 0)
140 return; 147 return;
141 148
142 Vector<IntRect> tickmarks; 149 Vector<IntRect> tickmarks;
143 scrollbar->getTickmarks(tickmarks); 150 scrollbar->getTickmarks(tickmarks);
144 if (!tickmarks.size()) 151 if (!tickmarks.size())
145 return; 152 return;
146 153
147 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarTickmar ks, rect); 154 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarTickmar ks, rect);
148 if (recorder.canUseCachedDrawing()) 155 if (recorder.canUseCachedDrawing())
149 return; 156 return;
150 157
151 // Inset a bit. 158 // Inset a bit.
152 IntRect tickmarkTrackRect = rect; 159 IntRect tickmarkTrackRect = rect;
153 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); 160 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1);
154 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); 161 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2);
155 paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks); 162 paintGivenTickmarks(context->canvas(), scrollbar, tickmarkTrackRect, tickmar ks);
156 } 163 }
157 164
158 ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon() 165 ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon()
159 { 166 {
160 } 167 }
161 168
162 void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float autoscrollButtonDelay, NSScrollerStyle preferredScrollerStyle, bool redraw) 169 void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float autoscrollButtonDelay, NSScrollerStyle preferredScrollerStyle, bool redraw)
163 { 170 {
164 updateButtonPlacement(); 171 updateButtonPlacement();
165 gInitialButtonDelay = initialButtonDelay; 172 gInitialButtonDelay = initialButtonDelay;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // static 232 // static
226 bool ScrollbarThemeMacCommon::isOverlayAPIAvailable() 233 bool ScrollbarThemeMacCommon::isOverlayAPIAvailable()
227 { 234 {
228 static bool apiAvailable = 235 static bool apiAvailable =
229 [NSClassFromString(@"NSScrollerImp") respondsToSelector:@selector(scroll erImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] 236 [NSClassFromString(@"NSScrollerImp") respondsToSelector:@selector(scroll erImpWithStyle:controlSize:horizontal:replacingScrollerImp:)]
230 && [NSClassFromString(@"NSScrollerImpPair") instancesRespondToSelector:@ selector(scrollerStyle)]; 237 && [NSClassFromString(@"NSScrollerImpPair") instancesRespondToSelector:@ selector(scrollerStyle)];
231 return apiAvailable; 238 return apiAvailable;
232 } 239 }
233 240
234 } // namespace blink 241 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/scroll/ScrollbarThemeMacCommon.h ('k') | Source/platform/scroll/ScrollbarThemeMacNonOverlayAPI.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698