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

Side by Side Diff: Source/platform/scroll/ScrollbarThemeAura.cpp

Issue 1220583004: Refactor DrawingRecorders to check for cached drawings earlier (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix some !'s and &&'s. De Morgan would be proud. Created 5 years, 5 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 /* 1 /*
2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. 2 * Copyright (c) 2008, 2009, Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Horiz and Vert scrollbars are the same thickness. 65 // Horiz and Vert scrollbars are the same thickness.
66 // In unit tests we don't have the mock theme engine (because of layering vi olations), so we hard code the size (see bug 327470). 66 // In unit tests we don't have the mock theme engine (because of layering vi olations), so we hard code the size (see bug 327470).
67 if (useMockTheme()) 67 if (useMockTheme())
68 return 15; 68 return 15;
69 IntSize scrollbarSize = Platform::current()->themeEngine()->getSize(WebTheme Engine::PartScrollbarVerticalTrack); 69 IntSize scrollbarSize = Platform::current()->themeEngine()->getSize(WebTheme Engine::PartScrollbarVerticalTrack);
70 return scrollbarSize.width(); 70 return scrollbarSize.width();
71 } 71 }
72 72
73 void ScrollbarThemeAura::paintTrackPiece(GraphicsContext* gc, ScrollbarThemeClie nt* scrollbar, const IntRect& rect, ScrollbarPart partType) 73 void ScrollbarThemeAura::paintTrackPiece(GraphicsContext* gc, ScrollbarThemeClie nt* scrollbar, const IntRect& rect, ScrollbarPart partType)
74 { 74 {
75 DisplayItem::Type displayItemType = trackPiecePartToDisplayItemType(partType );
76 if (DrawingRecorder::useCachedDrawingIfPossible(*gc, *scrollbar, displayItem Type))
77 return;
78
79 DrawingRecorder recorder(*gc, *scrollbar, displayItemType, rect);
80
75 WebThemeEngine::State state = scrollbar->hoveredPart() == partType ? WebThem eEngine::StateHover : WebThemeEngine::StateNormal; 81 WebThemeEngine::State state = scrollbar->hoveredPart() == partType ? WebThem eEngine::StateHover : WebThemeEngine::StateNormal;
76 82
77 if (useMockTheme() && !scrollbar->enabled()) 83 if (useMockTheme() && !scrollbar->enabled())
78 state = WebThemeEngine::StateDisabled; 84 state = WebThemeEngine::StateDisabled;
79 85
80 DrawingRecorder recorder(*gc, *scrollbar, trackPiecePartToDisplayItemType(pa rtType), rect);
81 if (recorder.canUseCachedDrawing())
82 return;
83
84 IntRect alignRect = trackRect(scrollbar, false); 86 IntRect alignRect = trackRect(scrollbar, false);
85 WebThemeEngine::ExtraParams extraParams; 87 WebThemeEngine::ExtraParams extraParams;
86 extraParams.scrollbarTrack.isBack = (partType == BackTrackPart); 88 extraParams.scrollbarTrack.isBack = (partType == BackTrackPart);
87 extraParams.scrollbarTrack.trackX = alignRect.x(); 89 extraParams.scrollbarTrack.trackX = alignRect.x();
88 extraParams.scrollbarTrack.trackY = alignRect.y(); 90 extraParams.scrollbarTrack.trackY = alignRect.y();
89 extraParams.scrollbarTrack.trackWidth = alignRect.width(); 91 extraParams.scrollbarTrack.trackWidth = alignRect.width();
90 extraParams.scrollbarTrack.trackHeight = alignRect.height(); 92 extraParams.scrollbarTrack.trackHeight = alignRect.height();
91 Platform::current()->themeEngine()->paint(gc->canvas(), scrollbar->orientati on() == HorizontalScrollbar ? WebThemeEngine::PartScrollbarHorizontalTrack : Web ThemeEngine::PartScrollbarVerticalTrack, state, WebRect(rect), &extraParams); 93 Platform::current()->themeEngine()->paint(gc->canvas(), scrollbar->orientati on() == HorizontalScrollbar ? WebThemeEngine::PartScrollbarHorizontalTrack : Web ThemeEngine::PartScrollbarVerticalTrack, state, WebRect(rect), &extraParams);
92 } 94 }
93 95
(...skipping 19 matching lines...) Expand all
113 paintPart = WebThemeEngine::PartScrollbarUpArrow; 115 paintPart = WebThemeEngine::PartScrollbarUpArrow;
114 checkMin = true; 116 checkMin = true;
115 } else if (useMockTheme() && part != ForwardButtonEndPart) { 117 } else if (useMockTheme() && part != ForwardButtonEndPart) {
116 return; 118 return;
117 } else { 119 } else {
118 paintPart = WebThemeEngine::PartScrollbarDownArrow; 120 paintPart = WebThemeEngine::PartScrollbarDownArrow;
119 checkMax = true; 121 checkMax = true;
120 } 122 }
121 } 123 }
122 124
123 DrawingRecorder recorder(*gc, *scrollbar, buttonPartToDisplayItemType(part), rect); 125 DisplayItem::Type displayItemType = buttonPartToDisplayItemType(part);
124 if (recorder.canUseCachedDrawing()) 126 if (DrawingRecorder::useCachedDrawingIfPossible(*gc, *scrollbar, displayItem Type))
125 return; 127 return;
126 128
129 DrawingRecorder recorder(*gc, *scrollbar, displayItemType, rect);
130
127 if (useMockTheme() && !scrollbar->enabled()) { 131 if (useMockTheme() && !scrollbar->enabled()) {
128 state = WebThemeEngine::StateDisabled; 132 state = WebThemeEngine::StateDisabled;
129 } else if (!useMockTheme() && ((checkMin && (scrollbar->currentPos() <= 0)) 133 } else if (!useMockTheme() && ((checkMin && (scrollbar->currentPos() <= 0))
130 || (checkMax && scrollbar->currentPos() >= scrollbar->maximum()))) { 134 || (checkMax && scrollbar->currentPos() >= scrollbar->maximum()))) {
131 state = WebThemeEngine::StateDisabled; 135 state = WebThemeEngine::StateDisabled;
132 } else { 136 } else {
133 if (part == scrollbar->pressedPart()) 137 if (part == scrollbar->pressedPart())
134 state = WebThemeEngine::StatePressed; 138 state = WebThemeEngine::StatePressed;
135 else if (part == scrollbar->hoveredPart()) 139 else if (part == scrollbar->hoveredPart())
136 state = WebThemeEngine::StateHover; 140 state = WebThemeEngine::StateHover;
137 } 141 }
138 Platform::current()->themeEngine()->paint(gc->canvas(), paintPart, state, We bRect(rect), 0); 142 Platform::current()->themeEngine()->paint(gc->canvas(), paintPart, state, We bRect(rect), 0);
139 } 143 }
140 144
141 void ScrollbarThemeAura::paintThumb(GraphicsContext* gc, ScrollbarThemeClient* s crollbar, const IntRect& rect) 145 void ScrollbarThemeAura::paintThumb(GraphicsContext* gc, ScrollbarThemeClient* s crollbar, const IntRect& rect)
142 { 146 {
147 if (DrawingRecorder::useCachedDrawingIfPossible(*gc, *scrollbar, DisplayItem ::ScrollbarThumb))
148 return;
149
143 DrawingRecorder recorder(*gc, *scrollbar, DisplayItem::ScrollbarThumb, rect) ; 150 DrawingRecorder recorder(*gc, *scrollbar, DisplayItem::ScrollbarThumb, rect) ;
144 if (recorder.canUseCachedDrawing())
145 return;
146 151
147 WebThemeEngine::State state; 152 WebThemeEngine::State state;
148 WebCanvas* canvas = gc->canvas(); 153 WebCanvas* canvas = gc->canvas();
149 if (scrollbar->pressedPart() == ThumbPart) 154 if (scrollbar->pressedPart() == ThumbPart)
150 state = WebThemeEngine::StatePressed; 155 state = WebThemeEngine::StatePressed;
151 else if (scrollbar->hoveredPart() == ThumbPart) 156 else if (scrollbar->hoveredPart() == ThumbPart)
152 state = WebThemeEngine::StateHover; 157 state = WebThemeEngine::StateHover;
153 else 158 else
154 state = WebThemeEngine::StateNormal; 159 state = WebThemeEngine::StateNormal;
155 Platform::current()->themeEngine()->paint(canvas, scrollbar->orientation() = = HorizontalScrollbar ? WebThemeEngine::PartScrollbarHorizontalThumb : WebThemeE ngine::PartScrollbarVerticalThumb, state, WebRect(rect), 0); 160 Platform::current()->themeEngine()->paint(canvas, scrollbar->orientation() = = HorizontalScrollbar ? WebThemeEngine::PartScrollbarHorizontalThumb : WebThemeE ngine::PartScrollbarVerticalThumb, state, WebRect(rect), 0);
(...skipping 16 matching lines...) Expand all
172 if (scrollbar->orientation() == VerticalScrollbar) { 177 if (scrollbar->orientation() == VerticalScrollbar) {
173 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngin e::PartScrollbarVerticalThumb); 178 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngin e::PartScrollbarVerticalThumb);
174 return size.height(); 179 return size.height();
175 } 180 }
176 181
177 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::P artScrollbarHorizontalThumb); 182 IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::P artScrollbarHorizontalThumb);
178 return size.width(); 183 return size.width();
179 } 184 }
180 185
181 } // namespace blink 186 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698