Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
4edbf5a0
Kaydet (Commit)
4edbf5a0
authored
Tem 18, 2015
tarafından
Pranav Kant
Kaydeden (comit)
Miklos Vajna
Tem 28, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
lokdocview: Make paintTile() async
Change-Id: I57db9e3adf26996e6e1e105b8b95f53e88e7760f
üst
a433ea9f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
40 deletions
+91
-40
lokdocview.cxx
libreofficekit/source/gtk/lokdocview.cxx
+10
-2
tilebuffer.cxx
libreofficekit/source/gtk/tilebuffer.cxx
+57
-34
tilebuffer.hxx
libreofficekit/source/gtk/tilebuffer.hxx
+24
-4
No files found.
libreofficekit/source/gtk/lokdocview.cxx
Dosyayı görüntüle @
4edbf5a0
...
...
@@ -520,7 +520,7 @@ setTilesInvalid (LOKDocView* pDocView, const GdkRectangle& rRectangle)
for
(
int
i
=
aStart
.
x
;
i
<
aEnd
.
x
;
i
++
)
for
(
int
j
=
aStart
.
y
;
j
<
aEnd
.
y
;
j
++
)
priv
->
m_aTileBuffer
.
setInvalid
(
i
,
j
);
priv
->
m_aTileBuffer
.
setInvalid
(
i
,
j
,
priv
->
m_fZoom
);
}
static
gboolean
...
...
@@ -741,6 +741,12 @@ renderGraphicHandle(LOKDocView* pDocView,
}
}
static
void
renderDocumentCallback
(
GObject
*
source_object
,
GAsyncResult
*
,
gpointer
)
{
LOKDocView
*
pDocView
=
LOK_DOC_VIEW
(
source_object
);
gtk_widget_queue_draw
(
GTK_WIDGET
(
pDocView
));
}
static
gboolean
renderDocument
(
LOKDocView
*
pDocView
,
cairo_t
*
pCairo
)
...
...
@@ -790,7 +796,9 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo)
if
(
bPaint
)
{
Tile
&
currentTile
=
priv
->
m_aTileBuffer
.
getTile
(
nRow
,
nColumn
,
priv
->
m_fZoom
);
GTask
*
task
=
g_task_new
(
pDocView
,
NULL
,
renderDocumentCallback
,
NULL
);
Tile
&
currentTile
=
priv
->
m_aTileBuffer
.
getTile
(
nRow
,
nColumn
,
priv
->
m_fZoom
,
task
);
GdkPixbuf
*
pPixBuf
=
currentTile
.
getBuffer
();
gdk_cairo_set_source_pixbuf
(
pCairo
,
pPixBuf
,
twipToPixel
(
aTileRectangleTwips
.
x
,
priv
->
m_fZoom
),
...
...
libreofficekit/source/gtk/tilebuffer.cxx
Dosyayı görüntüle @
4edbf5a0
...
...
@@ -27,6 +27,42 @@ float twipToPixel(float fInput, float zoom)
return
fInput
/
1440.0
f
*
DPI
*
zoom
;
}
static
void
getTileFunc
(
GTask
*
,
gpointer
,
gpointer
task_data
,
GCancellable
*
)
{
GdkPixbuf
*
pPixBuf
=
gdk_pixbuf_new
(
GDK_COLORSPACE_RGB
,
TRUE
,
8
,
nTileSizePixels
,
nTileSizePixels
);
GetTileCallbackData
*
pCallback
=
static_cast
<
GetTileCallbackData
*>
(
task_data
);
TileBuffer
*
buffer
=
pCallback
->
m_pBuffer
;
int
index
=
pCallback
->
m_nX
*
buffer
->
m_nWidth
+
pCallback
->
m_nY
;
if
(
!
pPixBuf
)
{
g_info
(
"Error allocating memory to pixbuf"
);
return
;
}
unsigned
char
*
pBuffer
=
gdk_pixbuf_get_pixels
(
pPixBuf
);
GdkRectangle
aTileRectangle
;
aTileRectangle
.
x
=
pixelToTwip
(
nTileSizePixels
,
pCallback
->
m_fZoom
)
*
pCallback
->
m_nY
;
aTileRectangle
.
y
=
pixelToTwip
(
nTileSizePixels
,
pCallback
->
m_fZoom
)
*
pCallback
->
m_nX
;
g_test_timer_start
();
buffer
->
m_pLOKDocument
->
pClass
->
paintTile
(
buffer
->
m_pLOKDocument
,
pBuffer
,
nTileSizePixels
,
nTileSizePixels
,
aTileRectangle
.
x
,
aTileRectangle
.
y
,
pixelToTwip
(
nTileSizePixels
,
pCallback
->
m_fZoom
),
pixelToTwip
(
nTileSizePixels
,
pCallback
->
m_fZoom
));
double
elapsedTime
=
g_test_timer_elapsed
();
g_info
(
"Rendered (%d, %d) in %f seconds"
,
pCallback
->
m_nX
,
pCallback
->
m_nY
,
elapsedTime
);
//create a mapping for it
buffer
->
m_mTiles
[
index
].
setPixbuf
(
pPixBuf
);
buffer
->
m_mTiles
[
index
].
valid
=
true
;
}
/* ----------------------------
Tile class member functions
----------------------------
...
...
@@ -56,55 +92,42 @@ void TileBuffer::resetAllTiles()
std
::
map
<
int
,
Tile
>::
iterator
it
=
m_mTiles
.
begin
();
for
(;
it
!=
m_mTiles
.
end
();
++
it
)
{
it
->
second
.
release
()
;
it
->
second
.
valid
=
false
;
}
m_mTiles
.
clear
();
}
void
TileBuffer
::
setInvalid
(
int
x
,
int
y
)
void
TileBuffer
::
setInvalid
(
int
x
,
int
y
,
float
fZoom
)
{
int
index
=
x
*
m_nWidth
+
y
;
g_info
(
"Setting tile invalid (%d, %d)"
,
x
,
y
);
if
(
m_mTiles
.
find
(
index
)
!=
m_mTiles
.
end
())
{
m_mTiles
[
index
].
valid
=
false
;
m_mTiles
[
index
].
release
();
m_mTiles
.
erase
(
index
);
GTask
*
task
=
g_task_new
(
this
,
NULL
,
NULL
,
NULL
);
GetTileCallbackData
*
pCallback
=
new
GetTileCallbackData
(
x
,
y
,
fZoom
,
this
);
g_task_set_task_data
(
task
,
pCallback
,
g_free
);
g_task_run_in_thread
(
task
,
getTileFunc
);
}
}
Tile
&
TileBuffer
::
getTile
(
int
x
,
int
y
,
float
aZoom
)
Tile
&
TileBuffer
::
getTile
(
int
x
,
int
y
,
float
aZoom
,
GTask
*
task
)
{
int
index
=
x
*
m_nWidth
+
y
;
if
(
m_mTiles
.
find
(
index
)
==
m_mTiles
.
end
()
||
!
m_mTiles
[
index
].
valid
)
{
GdkPixbuf
*
pPixBuf
=
gdk_pixbuf_new
(
GDK_COLORSPACE_RGB
,
TRUE
,
8
,
nTileSizePixels
,
nTileSizePixels
);
if
(
!
pPixBuf
)
{
g_info
(
"Error allocating memory to pixbuf"
);
return
m_mTiles
[
index
];
}
unsigned
char
*
pBuffer
=
gdk_pixbuf_get_pixels
(
pPixBuf
);
GdkRectangle
aTileRectangle
;
aTileRectangle
.
x
=
pixelToTwip
(
nTileSizePixels
,
aZoom
)
*
y
;
aTileRectangle
.
y
=
pixelToTwip
(
nTileSizePixels
,
aZoom
)
*
x
;
g_test_timer_start
();
m_pLOKDocument
->
pClass
->
paintTile
(
m_pLOKDocument
,
pBuffer
,
nTileSizePixels
,
nTileSizePixels
,
aTileRectangle
.
x
,
aTileRectangle
.
y
,
pixelToTwip
(
nTileSizePixels
,
aZoom
),
pixelToTwip
(
nTileSizePixels
,
aZoom
));
double
elapsedTime
=
g_test_timer_elapsed
();
g_info
(
"Rendered (%d, %d) in %f seconds"
,
x
,
y
,
elapsedTime
);
//create a mapping for it
m_mTiles
[
index
].
setPixbuf
(
pPixBuf
);
m_mTiles
[
index
].
valid
=
true
;
if
(
m_mTiles
.
find
(
index
)
!=
m_mTiles
.
end
()
&&
!
m_mTiles
[
index
].
valid
)
{
GetTileCallbackData
*
pCallback
=
new
GetTileCallbackData
(
x
,
y
,
aZoom
,
this
);
g_task_set_task_data
(
task
,
pCallback
,
g_free
);
g_task_run_in_thread
(
task
,
getTileFunc
);
return
m_mTiles
[
index
];
}
else
if
(
m_mTiles
.
find
(
index
)
==
m_mTiles
.
end
())
{
GetTileCallbackData
*
pCallback
=
new
GetTileCallbackData
(
x
,
y
,
aZoom
,
this
);
g_task_set_task_data
(
task
,
pCallback
,
g_free
);
g_info
(
"running in thread new tile"
);
g_task_run_in_thread
(
task
,
getTileFunc
);
return
m_DummyTile
;
}
return
m_mTiles
[
index
];
...
...
libreofficekit/source/gtk/tilebuffer.hxx
Dosyayı görüntüle @
4edbf5a0
...
...
@@ -86,7 +86,10 @@ class TileBuffer
int
columns
)
:
m_pLOKDocument
(
document
)
,
m_nWidth
(
columns
)
{
}
{
GdkPixbuf
*
pPixBuf
=
gdk_pixbuf_new
(
GDK_COLORSPACE_RGB
,
TRUE
,
8
,
nTileSizePixels
,
nTileSizePixels
);
m_DummyTile
.
setPixbuf
(
pPixBuf
);
}
~
TileBuffer
()
{}
...
...
@@ -104,7 +107,7 @@ class TileBuffer
@return the tile at the mentioned position (x, y)
*/
Tile
&
getTile
(
int
x
,
int
y
,
float
aZoom
);
Tile
&
getTile
(
int
x
,
int
y
,
float
aZoom
,
GTask
*
);
/// Destroys all the tiles in the tile buffer; also frees the memory allocated
/// for all the Tile objects.
void
resetAllTiles
();
...
...
@@ -115,17 +118,34 @@ class TileBuffer
@param x the position of tile along x-axis
@param y the position of tile along y-axis
*/
void
setInvalid
(
int
x
,
int
y
);
void
setInvalid
(
int
x
,
int
y
,
float
zoom
);
private
:
/// Contains the reference to the LOK Document that this tile buffer is for.
LibreOfficeKitDocument
*
m_pLOKDocument
;
/// Stores all the tiles cached by this tile buffer.
std
::
map
<
int
,
Tile
>
m_mTiles
;
/// Width of the current tile buffer (number of columns)
int
m_nWidth
;
/// Dummy tile
Tile
m_DummyTile
;
};
struct
GetTileCallbackData
{
int
m_nX
;
int
m_nY
;
float
m_fZoom
;
TileBuffer
*
m_pBuffer
;
GetTileCallbackData
(
int
x
,
int
y
,
float
zoom
,
TileBuffer
*
buffer
)
:
m_nX
(
x
),
m_nY
(
y
),
m_fZoom
(
zoom
),
m_pBuffer
(
buffer
)
{
}
};
#endif // INCLUDED_TILEBUFFER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment