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

Side by Side Diff: Source/web/PageWidgetDelegate.cpp

Issue 1154783007: Use SkPictureBuilder in PageWidgetDelegate (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
« no previous file with comments | « Source/core/svg/graphics/SVGImage.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 24 matching lines...) Expand all
35 #include "core/frame/LocalFrame.h" 35 #include "core/frame/LocalFrame.h"
36 #include "core/input/EventHandler.h" 36 #include "core/input/EventHandler.h"
37 #include "core/layout/LayoutView.h" 37 #include "core/layout/LayoutView.h"
38 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" 38 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h"
39 #include "core/page/AutoscrollController.h" 39 #include "core/page/AutoscrollController.h"
40 #include "core/page/Page.h" 40 #include "core/page/Page.h"
41 #include "core/paint/TransformRecorder.h" 41 #include "core/paint/TransformRecorder.h"
42 #include "platform/Logging.h" 42 #include "platform/Logging.h"
43 #include "platform/graphics/GraphicsContext.h" 43 #include "platform/graphics/GraphicsContext.h"
44 #include "platform/graphics/paint/ClipRecorder.h" 44 #include "platform/graphics/paint/ClipRecorder.h"
45 #include "platform/graphics/paint/DisplayItemListContextRecorder.h"
46 #include "platform/graphics/paint/DrawingRecorder.h" 45 #include "platform/graphics/paint/DrawingRecorder.h"
46 #include "platform/graphics/paint/SkPictureBuilder.h"
47 #include "platform/transforms/AffineTransform.h" 47 #include "platform/transforms/AffineTransform.h"
48 #include "public/web/WebInputEvent.h" 48 #include "public/web/WebInputEvent.h"
49 #include "web/PageOverlayList.h" 49 #include "web/PageOverlayList.h"
50 #include "web/WebInputEventConversion.h" 50 #include "web/WebInputEventConversion.h"
51 #include "wtf/CurrentTime.h" 51 #include "wtf/CurrentTime.h"
52 52
53 namespace blink { 53 namespace blink {
54 54
55 void PageWidgetDelegate::animate(Page& page, double monotonicFrameBeginTime, Loc alFrame& root) 55 void PageWidgetDelegate::animate(Page& page, double monotonicFrameBeginTime, Loc alFrame& root)
56 { 56 {
57 RefPtrWillBeRawPtr<FrameView> view = root.view(); 57 RefPtrWillBeRawPtr<FrameView> view = root.view();
58 if (!view) 58 if (!view)
59 return; 59 return;
60 page.autoscrollController().animate(monotonicFrameBeginTime); 60 page.autoscrollController().animate(monotonicFrameBeginTime);
61 page.animator().serviceScriptedAnimations(monotonicFrameBeginTime); 61 page.animator().serviceScriptedAnimations(monotonicFrameBeginTime);
62 } 62 }
63 63
64 void PageWidgetDelegate::layout(Page& page, LocalFrame& root) 64 void PageWidgetDelegate::layout(Page& page, LocalFrame& root)
65 { 65 {
66 page.animator().updateLayoutAndStyleForPainting(&root); 66 page.animator().updateLayoutAndStyleForPainting(&root);
67 } 67 }
68 68
69 void PageWidgetDelegate::paint(Page& page, PageOverlayList* overlays, WebCanvas* canvas, 69 void PageWidgetDelegate::paint(Page& page, PageOverlayList* overlays, WebCanvas* canvas,
70 const WebRect& rect, LocalFrame& root) 70 const WebRect& rect, LocalFrame& root)
71 { 71 {
72 if (rect.isEmpty()) 72 if (rect.isEmpty())
73 return; 73 return;
74 74
75 OwnPtr<GraphicsContext> context = GraphicsContext::deprecatedCreateWithCanva s(canvas); 75 IntRect intRect(rect);
76 SkPictureBuilder pictureBuilder(intRect);
76 { 77 {
77 DisplayItemListContextRecorder contextRecorder(*context); 78 GraphicsContext& paintContext = pictureBuilder.context();
78 GraphicsContext& paintContext = contextRecorder.context();
79 79
80 // FIXME: device scale factor settings are layering violations and shoul d not 80 // FIXME: device scale factor settings are layering violations and shoul d not
81 // be used within Blink paint code. 81 // be used within Blink paint code.
82 float scaleFactor = page.deviceScaleFactor(); 82 float scaleFactor = page.deviceScaleFactor();
83 paintContext.setDeviceScaleFactor(scaleFactor); 83 paintContext.setDeviceScaleFactor(scaleFactor);
84 84
85 AffineTransform scale; 85 AffineTransform scale;
86 scale.scale(scaleFactor); 86 scale.scale(scaleFactor);
87 TransformRecorder scaleRecorder(paintContext, root, scale); 87 TransformRecorder scaleRecorder(paintContext, root, scale);
88 88
89 IntRect dirtyRect(rect); 89 IntRect dirtyRect(rect);
90 FrameView* view = root.view(); 90 FrameView* view = root.view();
91 if (view) { 91 if (view) {
92 ClipRecorder clipRecorder(paintContext, root, DisplayItem::PageWidge tDelegateClip, LayoutRect(dirtyRect)); 92 ClipRecorder clipRecorder(paintContext, root, DisplayItem::PageWidge tDelegateClip, LayoutRect(dirtyRect));
93 93
94 view->paint(&paintContext, dirtyRect); 94 view->paint(&paintContext, dirtyRect);
95 if (overlays) 95 if (overlays)
96 overlays->paintWebFrame(paintContext); 96 overlays->paintWebFrame(paintContext);
97 } else { 97 } else {
98 DrawingRecorder drawingRecorder(paintContext, root, DisplayItem::Pag eWidgetDelegateBackgroundFallback, dirtyRect); 98 DrawingRecorder drawingRecorder(paintContext, root, DisplayItem::Pag eWidgetDelegateBackgroundFallback, dirtyRect);
99 if (!drawingRecorder.canUseCachedDrawing()) 99 if (!drawingRecorder.canUseCachedDrawing())
100 paintContext.fillRect(dirtyRect, Color::white); 100 paintContext.fillRect(dirtyRect, Color::white);
101 } 101 }
102 } 102 }
103 pictureBuilder.endRecording()->playback(canvas);
103 } 104 }
104 105
105 bool PageWidgetDelegate::handleInputEvent(PageWidgetEventHandler& handler, const WebInputEvent& event, LocalFrame* root) 106 bool PageWidgetDelegate::handleInputEvent(PageWidgetEventHandler& handler, const WebInputEvent& event, LocalFrame* root)
106 { 107 {
107 switch (event.type) { 108 switch (event.type) {
108 109
109 // FIXME: WebKit seems to always return false on mouse events processing 110 // FIXME: WebKit seems to always return false on mouse events processing
110 // methods. For now we'll assume it has processed them (as we are only 111 // methods. For now we'll assume it has processed them (as we are only
111 // interested in whether keyboard events are processed). 112 // interested in whether keyboard events are processed).
112 // FIXME: Why do we return true when there is no root or the root is 113 // FIXME: Why do we return true when there is no root or the root is
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 { 206 {
206 return mainFrame.eventHandler().handleWheelEvent(PlatformWheelEventBuilder(m ainFrame.view(), event)); 207 return mainFrame.eventHandler().handleWheelEvent(PlatformWheelEventBuilder(m ainFrame.view(), event));
207 } 208 }
208 209
209 bool PageWidgetEventHandler::handleTouchEvent(LocalFrame& mainFrame, const WebTo uchEvent& event) 210 bool PageWidgetEventHandler::handleTouchEvent(LocalFrame& mainFrame, const WebTo uchEvent& event)
210 { 211 {
211 return mainFrame.eventHandler().handleTouchEvent(PlatformTouchEventBuilder(m ainFrame.view(), event)); 212 return mainFrame.eventHandler().handleTouchEvent(PlatformTouchEventBuilder(m ainFrame.view(), event));
212 } 213 }
213 214
214 } // namespace blink 215 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/svg/graphics/SVGImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698