|
1 /* |
|
2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
|
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
|
4 * |
|
5 * Redistribution and use in source and binary forms, with or without |
|
6 * modification, are permitted provided that the following conditions |
|
7 * are met: |
|
8 * 1. Redistributions of source code must retain the above copyright |
|
9 * notice, this list of conditions and the following disclaimer. |
|
10 * 2. Redistributions in binary form must reproduce the above copyright |
|
11 * notice, this list of conditions and the following disclaimer in the |
|
12 * documentation and/or other materials provided with the distribution. |
|
13 * |
|
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
|
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
|
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
|
18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|
24 * THE POSSIBILITY OF SUCH DAMAGE. |
|
25 */ |
|
26 |
|
27 #include "ChunkedUpdateDrawingAreaProxy.h" |
|
28 |
|
29 #include "DrawingAreaMessageKinds.h" |
|
30 #include "DrawingAreaProxyMessageKinds.h" |
|
31 #include "UpdateChunk.h" |
|
32 #include "WKAPICast.h" |
|
33 #include "WebPageProxy.h" |
|
34 #include "qgraphicswkview.h" |
|
35 #include <QPainter> |
|
36 |
|
37 using namespace WebCore; |
|
38 |
|
39 namespace WebKit { |
|
40 |
|
41 WebPageProxy* ChunkedUpdateDrawingAreaProxy::page() |
|
42 { |
|
43 return toWK(m_webView->page()->pageRef()); |
|
44 } |
|
45 |
|
46 void ChunkedUpdateDrawingAreaProxy::ensureBackingStore() |
|
47 { |
|
48 if (!m_backingStoreImage.isNull()) |
|
49 return; |
|
50 |
|
51 m_backingStoreImage = QImage(m_viewSize.width(), m_viewSize.height(), QImage::Format_RGB32); |
|
52 } |
|
53 |
|
54 void ChunkedUpdateDrawingAreaProxy::invalidateBackingStore() |
|
55 { |
|
56 m_backingStoreImage = QImage(); |
|
57 } |
|
58 |
|
59 void ChunkedUpdateDrawingAreaProxy::platformPaint(const IntRect& rect, QPainter* painter) |
|
60 { |
|
61 if (m_backingStoreImage.isNull()) |
|
62 return; |
|
63 |
|
64 painter->drawImage(QPoint(0, 0), m_backingStoreImage); |
|
65 } |
|
66 |
|
67 void ChunkedUpdateDrawingAreaProxy::drawUpdateChunkIntoBackingStore(UpdateChunk* updateChunk) |
|
68 { |
|
69 ensureBackingStore(); |
|
70 |
|
71 QImage image(updateChunk->createImage()); |
|
72 const IntRect& updateChunkRect = updateChunk->rect(); |
|
73 |
|
74 QPainter painter(&m_backingStoreImage); |
|
75 painter.drawImage(updateChunkRect.topLeft(), image); |
|
76 |
|
77 m_webView->update(QRect(updateChunkRect)); |
|
78 } |
|
79 |
|
80 } // namespace WebKit |