Home | History | Annotate | Download | only in UIProcess
      1 /*
      2  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  * 1. Redistributions of source code must retain the above copyright
      8  *    notice, this list of conditions and the following disclaimer.
      9  * 2. Redistributions in binary form must reproduce the above copyright
     10  *    notice, this list of conditions and the following disclaimer in the
     11  *    documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
     14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
     17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     23  * THE POSSIBILITY OF SUCH DAMAGE.
     24  */
     25 
     26 #ifndef TiledDrawingAreaTile_h
     27 #define TiledDrawingAreaTile_h
     28 
     29 #include "IntPoint.h"
     30 #include "IntPointHash.h"
     31 #include "IntRect.h"
     32 #include "GraphicsContext.h"
     33 #include <wtf/PassRefPtr.h>
     34 #include <wtf/RefCounted.h>
     35 
     36 #if PLATFORM(QT)
     37 #include <QPixmap>
     38 #include <QRegion>
     39 #endif
     40 
     41 namespace WebKit {
     42 
     43 class TiledDrawingAreaProxy;
     44 class UpdateChunk;
     45 
     46 class TiledDrawingAreaTile : public RefCounted<TiledDrawingAreaTile> {
     47 public:
     48     typedef WebCore::IntPoint Coordinate;
     49 
     50     static PassRefPtr<TiledDrawingAreaTile> create(TiledDrawingAreaProxy* proxy, const Coordinate& tileCoordinate) { return adoptRef(new TiledDrawingAreaTile(proxy, tileCoordinate)); }
     51     ~TiledDrawingAreaTile();
     52 
     53     bool isDirty() const;
     54     void invalidate(const WebCore::IntRect&);
     55     void updateBackBuffer();
     56     bool hasReadyBackBuffer() const;
     57     void swapBackBufferToFront();
     58     bool isReadyToPaint() const;
     59     void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);
     60     bool hasBackBufferUpdatePending() const { return m_hasUpdatePending; }
     61 
     62     const TiledDrawingAreaTile::Coordinate& coordinate() const { return m_coordinate; }
     63     const WebCore::IntRect& rect() const { return m_rect; }
     64     void resize(const WebCore::IntSize&);
     65 
     66     void updateFromChunk(UpdateChunk* updateChunk, float);
     67 
     68     int ID() const { return m_ID; }
     69 
     70 private:
     71     TiledDrawingAreaTile(TiledDrawingAreaProxy* proxy, const TiledDrawingAreaTile::Coordinate& tileCoordinate);
     72 
     73     TiledDrawingAreaProxy* m_proxy;
     74     Coordinate m_coordinate;
     75     WebCore::IntRect m_rect;
     76 
     77     int m_ID;
     78     bool m_hasUpdatePending;
     79 
     80 #if PLATFORM(QT)
     81     QPixmap m_buffer;
     82     QPixmap m_backBuffer;
     83     QRegion m_dirtyRegion;
     84 #endif
     85 };
     86 
     87 }
     88 
     89 #endif
     90