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

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

Issue 1220583004: Refactor DrawingRecorders to check for cached drawings earlier (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 updateEnabledState(scrollbar); 79 updateEnabledState(scrollbar);
80 updateScrollbarOverlayStyle(scrollbar); 80 updateScrollbarOverlayStyle(scrollbar);
81 } 81 }
82 82
83 ScrollbarPainter ScrollbarThemeMacOverlayAPI::painterForScrollbar(ScrollbarTheme Client* scrollbar) 83 ScrollbarPainter ScrollbarThemeMacOverlayAPI::painterForScrollbar(ScrollbarTheme Client* scrollbar)
84 { 84 {
85 return scrollbarPainterMap()->get(scrollbar).get(); 85 return scrollbarPainterMap()->get(scrollbar).get();
86 } 86 }
87 87
88 void ScrollbarThemeMacOverlayAPI::paintTrackBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect) { 88 void ScrollbarThemeMacOverlayAPI::paintTrackBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect) {
89 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa yItem::ScrollbarTrackBackground))
90 return;
91
89 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarTrackBa ckground, rect); 92 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarTrackBa ckground, rect);
90 if (recorder.canUseCachedDrawing())
91 return;
92 93
93 ASSERT(isOverlayAPIAvailable()); 94 ASSERT(isOverlayAPIAvailable());
94 95
95 GraphicsContextStateSaver stateSaver(*context); 96 GraphicsContextStateSaver stateSaver(*context);
96 context->translate(rect.x(), rect.y()); 97 context->translate(rect.x(), rect.y());
97 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s ize())); 98 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s ize()));
98 99
99 CGRect frameRect = scrollbar->frameRect(); 100 CGRect frameRect = scrollbar->frameRect();
100 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); 101 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar);
101 [scrollbarPainter setEnabled:scrollbar->enabled()]; 102 [scrollbarPainter setEnabled:scrollbar->enabled()];
102 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)]; 103 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)];
103 104
104 NSRect trackRect = NSMakeRect(0, 0, frameRect.size.width, frameRect.size.hei ght); 105 NSRect trackRect = NSMakeRect(0, 0, frameRect.size.width, frameRect.size.hei ght);
105 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; 106 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO];
106 } 107 }
107 108
108 void ScrollbarThemeMacOverlayAPI::paintThumb(GraphicsContext* context, Scrollbar ThemeClient* scrollbar, const IntRect& rect) { 109 void ScrollbarThemeMacOverlayAPI::paintThumb(GraphicsContext* context, Scrollbar ThemeClient* scrollbar, const IntRect& rect) {
110 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, Displa yItem::ScrollbarThumb))
111 return;
112
109 // Expand dirty rect to allow for scroll thumb anti-aliasing in minimum thum b size case. 113 // Expand dirty rect to allow for scroll thumb anti-aliasing in minimum thum b size case.
110 IntRect dirtyRect = IntRect(rect); 114 IntRect dirtyRect = IntRect(rect);
111 dirtyRect.inflate(1); 115 dirtyRect.inflate(1);
112 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarThumb, dirtyRect); 116 DrawingRecorder recorder(*context, *scrollbar, DisplayItem::ScrollbarThumb, dirtyRect);
113 if (recorder.canUseCachedDrawing())
114 return;
115 117
116 ASSERT(isOverlayAPIAvailable()); 118 ASSERT(isOverlayAPIAvailable());
117 119
118 GraphicsContextStateSaver stateSaver(*context); 120 GraphicsContextStateSaver stateSaver(*context);
119 context->translate(rect.x(), rect.y()); 121 context->translate(rect.x(), rect.y());
120 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s ize())); 122 LocalCurrentGraphicsContext localContext(context, IntRect(IntPoint(), rect.s ize()));
121 123
122 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); 124 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar);
123 [scrollbarPainter setEnabled:scrollbar->enabled()]; 125 [scrollbarPainter setEnabled:scrollbar->enabled()];
124 [scrollbarPainter setBoundsSize:NSSizeFromCGSize(rect.size())]; 126 [scrollbarPainter setBoundsSize:NSSizeFromCGSize(rect.size())];
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 { 201 {
200 return [painterForScrollbar(scrollbar) knobMinLength]; 202 return [painterForScrollbar(scrollbar) knobMinLength];
201 } 203 }
202 204
203 void ScrollbarThemeMacOverlayAPI::updateEnabledState(ScrollbarThemeClient* scrol lbar) 205 void ScrollbarThemeMacOverlayAPI::updateEnabledState(ScrollbarThemeClient* scrol lbar)
204 { 206 {
205 [painterForScrollbar(scrollbar) setEnabled:scrollbar->enabled()]; 207 [painterForScrollbar(scrollbar) setEnabled:scrollbar->enabled()];
206 } 208 }
207 209
208 } // namespace blink 210 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/scroll/ScrollbarThemeMacNonOverlayAPI.mm ('k') | Source/platform/scroll/ScrollbarThemeMock.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698