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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollbarThemeMacNonOverlayAPI.mm

Issue 1422493003: Change Widget subclasses to use a CullRect instead of an IntRect for painting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "platform/scroll/ScrollbarThemeMacNonOverlayAPI.h" 32 #include "platform/scroll/ScrollbarThemeMacNonOverlayAPI.h"
33 33
34 #include "platform/graphics/GraphicsContext.h" 34 #include "platform/graphics/GraphicsContext.h"
35 #include "platform/graphics/ImageBuffer.h" 35 #include "platform/graphics/ImageBuffer.h"
36 #include "platform/graphics/paint/CullRect.h"
36 #include "platform/graphics/paint/DrawingRecorder.h" 37 #include "platform/graphics/paint/DrawingRecorder.h"
37 #include "platform/mac/ThemeMac.h" 38 #include "platform/mac/ThemeMac.h"
38 #include "platform/scroll/ScrollbarThemeClient.h" 39 #include "platform/scroll/ScrollbarThemeClient.h"
39 #include "public/platform/Platform.h" 40 #include "public/platform/Platform.h"
40 #include "public/platform/WebRect.h" 41 #include "public/platform/WebRect.h"
41 #include "public/platform/WebThemeEngine.h" 42 #include "public/platform/WebThemeEngine.h"
42 #include "skia/ext/skia_utils_mac.h" 43 #include "skia/ext/skia_utils_mac.h"
43 #include <Carbon/Carbon.h> 44 #include <Carbon/Carbon.h>
44 45
45 namespace blink { 46 namespace blink {
(...skipping 14 matching lines...) Expand all
60 61
61 void ScrollbarThemeMacNonOverlayAPI::updateButtonPlacement(ScrollbarButtonsPlace ment buttonPlacement) 62 void ScrollbarThemeMacNonOverlayAPI::updateButtonPlacement(ScrollbarButtonsPlace ment buttonPlacement)
62 { 63 {
63 gButtonPlacement = buttonPlacement; 64 gButtonPlacement = buttonPlacement;
64 } 65 }
65 66
66 // Override ScrollbarThemeMacCommon::paint() to add support for the following: 67 // Override ScrollbarThemeMacCommon::paint() to add support for the following:
67 // - drawing using WebThemeEngine functions 68 // - drawing using WebThemeEngine functions
68 // - drawing tickmarks 69 // - drawing tickmarks
69 // - Skia specific changes 70 // - Skia specific changes
70 bool ScrollbarThemeMacNonOverlayAPI::paint(const ScrollbarThemeClient* scrollbar , GraphicsContext* context, const IntRect& damageRect) 71 bool ScrollbarThemeMacNonOverlayAPI::paint(const ScrollbarThemeClient* scrollbar , GraphicsContext* context, const CullRect& cullRect)
71 { 72 {
72 DisplayItem::Type displayItemType = scrollbar->orientation() == HorizontalSc rollbar ? DisplayItem::ScrollbarHorizontal : DisplayItem::ScrollbarVertical; 73 DisplayItem::Type displayItemType = scrollbar->orientation() == HorizontalSc rollbar ? DisplayItem::ScrollbarHorizontal : DisplayItem::ScrollbarVertical;
73 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, displa yItemType)) 74 if (DrawingRecorder::useCachedDrawingIfPossible(*context, *scrollbar, displa yItemType))
74 return true; 75 return true;
75 76
76 DrawingRecorder recorder(*context, *scrollbar, displayItemType, scrollbar->f rameRect()); 77 DrawingRecorder recorder(*context, *scrollbar, displayItemType, scrollbar->f rameRect());
77 78
78 // Get the tickmarks for the frameview. 79 // Get the tickmarks for the frameview.
79 Vector<IntRect> tickmarks; 80 Vector<IntRect> tickmarks;
80 scrollbar->getTickmarks(tickmarks); 81 scrollbar->getTickmarks(tickmarks);
(...skipping 24 matching lines...) Expand all
105 CGAffineTransform currentCTM = gfx::SkMatrixToCGAffineTransform(canvas->getT otalMatrix()); 106 CGAffineTransform currentCTM = gfx::SkMatrixToCGAffineTransform(canvas->getT otalMatrix());
106 107
107 // The Aqua scrollbar is buggy when rotated and scaled. We will just draw i nto a bitmap if we detect a scale or rotation. 108 // The Aqua scrollbar is buggy when rotated and scaled. We will just draw i nto a bitmap if we detect a scale or rotation.
108 bool canDrawDirectly = currentCTM.a == 1.0f && currentCTM.b == 0.0f && curre ntCTM.c == 0.0f && (currentCTM.d == 1.0f || currentCTM.d == -1.0f); 109 bool canDrawDirectly = currentCTM.a == 1.0f && currentCTM.b == 0.0f && curre ntCTM.c == 0.0f && (currentCTM.d == 1.0f || currentCTM.d == -1.0f);
109 OwnPtr<ImageBuffer> imageBuffer; 110 OwnPtr<ImageBuffer> imageBuffer;
110 SkCanvas* drawingCanvas; 111 SkCanvas* drawingCanvas;
111 if (!canDrawDirectly) { 112 if (!canDrawDirectly) {
112 trackInfo.bounds = IntRect(IntPoint(), scrollbar->frameRect().size()); 113 trackInfo.bounds = IntRect(IntPoint(), scrollbar->frameRect().size());
113 114
114 IntRect bufferRect(scrollbar->frameRect()); 115 IntRect bufferRect(scrollbar->frameRect());
115 bufferRect.intersect(damageRect); 116 bufferRect.intersect(cullRect.m_rect);
116 bufferRect.move(-scrollbar->frameRect().x(), -scrollbar->frameRect().y() ); 117 bufferRect.move(-scrollbar->frameRect().x(), -scrollbar->frameRect().y() );
117 118
118 imageBuffer = ImageBuffer::create(bufferRect.size()); 119 imageBuffer = ImageBuffer::create(bufferRect.size());
119 if (!imageBuffer) 120 if (!imageBuffer)
120 return true; 121 return true;
121 122
122 drawingCanvas = imageBuffer->canvas(); 123 drawingCanvas = imageBuffer->canvas();
123 } else { 124 } else {
124 drawingCanvas = canvas; 125 drawingCanvas = canvas;
125 } 126 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 return IntRect(scrollbar->x() + startWidth, scrollbar->y(), scrollbar->w idth() - totalWidth, thickness); 310 return IntRect(scrollbar->x() + startWidth, scrollbar->y(), scrollbar->w idth() - totalWidth, thickness);
310 return IntRect(scrollbar->x(), scrollbar->y() + startWidth, thickness, scrol lbar->height() - totalWidth); 311 return IntRect(scrollbar->x(), scrollbar->y() + startWidth, thickness, scrol lbar->height() - totalWidth);
311 } 312 }
312 313
313 int ScrollbarThemeMacNonOverlayAPI::minimumThumbLength(const ScrollbarThemeClien t* scrollbar) 314 int ScrollbarThemeMacNonOverlayAPI::minimumThumbLength(const ScrollbarThemeClien t* scrollbar)
314 { 315 {
315 return cThumbMinLength[scrollbar->controlSize()]; 316 return cThumbMinLength[scrollbar->controlSize()];
316 } 317 }
317 318
318 } 319 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698