[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 6 commits - android/Bootstrap android/experimental

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Thu Jan 15 00:59:45 PST 2015


 android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java                   |   10 
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java              |    3 
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java        |    6 
 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java  |  108 ++++++----
 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DynamicTileLayer.java   |    5 
 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java |    5 
 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java   |    4 
 7 files changed, 94 insertions(+), 47 deletions(-)

New commits:
commit 2f89ed31ceec05e9efed812b36e3040cc25ae153
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Jan 15 17:56:14 2015 +0900

    android: store tiles in Map for faster access to tiles
    
    Change-Id: I54c5fbe0b24ecf82de2d3d9f72d7f72d59125d58

diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
index 6f288d5..862d2c8 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
@@ -14,14 +14,18 @@ import org.libreoffice.LOKitShell;
 import org.libreoffice.TileIdentifier;
 import org.mozilla.gecko.util.FloatUtils;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 public abstract class ComposedTileLayer extends Layer implements ComponentCallbacks2 {
     private static final String LOGTAG = ComposedTileLayer.class.getSimpleName();
 
-    protected final List<SubTile> tiles = new CopyOnWriteArrayList<SubTile>();
+    protected final ConcurrentMap<TileIdentifier, SubTile> tiles = new ConcurrentHashMap<TileIdentifier, SubTile>();
+    protected final Set<TileIdentifier> newTileIds = Collections.newSetFromMap(new ConcurrentHashMap<TileIdentifier, Boolean>());
 
     protected final IntSize tileSize;
     protected RectF currentViewport = new RectF();
@@ -38,7 +42,7 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
     }
 
     public void invalidate() {
-        for (SubTile tile : tiles) {
+        for (SubTile tile : tiles.values()) {
             tile.invalidate();
         }
     }
@@ -46,14 +50,14 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
     @Override
     public void beginTransaction() {
         super.beginTransaction();
-        for (SubTile tile : tiles) {
+        for (SubTile tile : tiles.values()) {
             tile.beginTransaction();
         }
     }
 
     @Override
     public void endTransaction() {
-        for (SubTile tile : tiles) {
+        for (SubTile tile : tiles.values()) {
             tile.endTransaction();
         }
         super.endTransaction();
@@ -61,7 +65,7 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
 
     @Override
     public void draw(RenderContext context) {
-        for (SubTile tile : tiles) {
+        for (SubTile tile : tiles.values()) {
             if (RectF.intersects(tile.getBounds(context), context.viewport)) {
                 tile.draw(context);
             }
@@ -72,7 +76,7 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
     protected void performUpdates(RenderContext context) {
         super.performUpdates(context);
 
-        for (SubTile tile : tiles) {
+        for (SubTile tile : tiles.values()) {
             tile.beginTransaction();
             tile.refreshTileMetrics();
             tile.endTransaction();
@@ -83,7 +87,7 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
     @Override
     public Region getValidRegion(RenderContext context) {
         Region validRegion = new Region();
-        for (SubTile tile : tiles) {
+        for (SubTile tile : tiles.values()) {
             validRegion.op(tile.getValidRegion(context), Region.Op.UNION);
         }
 
@@ -93,7 +97,7 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
     @Override
     public void setResolution(float newResolution) {
         super.setResolution(newResolution);
-        for (SubTile tile : tiles) {
+        for (SubTile tile : tiles.values()) {
             tile.setResolution(newResolution);
         }
     }
@@ -163,14 +167,9 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
                 if (x > pageRect.width()) {
                     continue;
                 }
-                boolean contains = false;
-                for (SubTile tile : tiles) {
-                    if (tile.id.x == x && tile.id.y == y && tile.id.zoom == currentZoom) {
-                        contains = true;
-                    }
-                }
-                if (!contains) {
-                    TileIdentifier tileId = new TileIdentifier((int) x, (int) y, currentZoom, tileSize);
+                TileIdentifier tileId = new TileIdentifier((int) x, (int) y, currentZoom, tileSize);
+                if (!tiles.containsKey(tileId) && !newTileIds.contains(tileId)) {
+                    newTileIds.add(tileId);
                     LOEvent event = LOEventFactory.tileRequest(this, tileId, true);
                     event.mPriority = getTilePriority();
                     LOKitShell.sendEvent(event);
@@ -180,18 +179,18 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
     }
 
     private void clearMarkedTiles() {
-        List<SubTile> tilesToRemove = new ArrayList<SubTile>();
-        for (SubTile tile : tiles) {
+        Iterator<Map.Entry<TileIdentifier, SubTile>> iterator;
+        for (iterator = tiles.entrySet().iterator(); iterator.hasNext();) {
+            SubTile tile = iterator.next().getValue();
             if (tile.markedForRemoval) {
                 tile.destroy();
-                tilesToRemove.add(tile);
+                iterator.remove();
             }
         }
-        tiles.removeAll(tilesToRemove);
     }
 
     private void markTiles() {
-        for (SubTile tile : tiles) {
+        for (SubTile tile : tiles.values()) {
             if (FloatUtils.fuzzyEquals(tile.id.zoom, currentZoom)) {
                 RectF tileRect = tile.id.getRect();
                 if (!RectF.intersects(currentViewport, tileRect)) {
@@ -210,7 +209,8 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
 
     public void addTile(SubTile tile) {
         tile.beginTransaction();
-        tiles.add(tile);
+        tiles.put(tile.id, tile);
+        newTileIds.remove(tile.id);
     }
 
     public boolean isStillValid(TileIdentifier tileId) {
@@ -223,7 +223,7 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
     public void invalidateTiles(RectF rect) {
         RectF zoomedRect = RectUtils.inverseScale(rect, currentZoom);
 
-        for (SubTile tile : tiles) {
+        for (SubTile tile : tiles.values()) {
             if (RectF.intersects(rect, tile.id.getRect())) {
                 LOKitShell.sendEvent(LOEventFactory.tileRerender(this, tile));
             }
@@ -246,7 +246,7 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
             Log.i(LOGTAG, "Trimming memory - TRIM_MEMORY_RUNNING_LOW");
         } else if (level >= 15 /*TRIM_MEMORY_RUNNING_CRITICAL*/) {
             Log.i(LOGTAG, "Trimming memory - TRIM_MEMORY_RUNNING_CRITICAL");
-            clearAndReset();
+            //clearAndReset();
         }
     }
 }
\ No newline at end of file
commit 66536fd61261a93a574afd85a5b8142501026445
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Jan 15 16:41:12 2015 +0900

    android: create tile outside of beginTransaction
    
    Change-Id: Iaf8339f1cadc4f77dfefb1e268126745d6ed7eaa

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index a488240..30af98d 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -28,8 +28,8 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
 
     private void tileRequest(ComposedTileLayer composedTileLayer, TileIdentifier tileId, boolean forceRedraw) {
         if (composedTileLayer.isStillValid(tileId)) {
-            mLayerClient.beginDrawing();
             CairoImage image = mTileProvider.createTile(tileId.x, tileId.y, tileId.size, tileId.zoom);
+            mLayerClient.beginDrawing();
             SubTile tile = new SubTile(image, tileId);
             composedTileLayer.addTile(tile);
             mLayerClient.endDrawing(mViewportMetrics);
@@ -43,7 +43,6 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
         if (composedTileLayer.isStillValid(tile.id) && !tile.markedForRemoval) {
             mLayerClient.beginDrawing();
             mTileProvider.rerenderTile(tile.getImage(), tile.id.x, tile.id.y, tile.id.size, tile.id.zoom);
-            tile.invalidate();
             mLayerClient.endDrawing(mViewportMetrics);
             mLayerClient.forceRender();
         }
commit ab781dc5df22577ead1c6a4101ec6b27d95ea6ee
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Jan 15 16:12:05 2015 +0900

    android: simplify methods with currentZoom / currentViewport
    
    Change-Id: I6134d434ca34c0f3e839a3d78b67c5cefff53a48

diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
index 512559f..6f288d5 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
@@ -132,7 +132,7 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
 
     public void reevaluateTiles(ImmutableViewportMetrics viewportMetrics, DisplayPortMetrics mDisplayPort) {
         RectF newCurrentViewPort = getViewPort(viewportMetrics);
-        float newZoom = viewportMetrics.zoomFactor;
+        float newZoom = getZoom(viewportMetrics);
 
         if (!currentViewport.equals(newCurrentViewPort) || currentZoom != newZoom) {
             if (newZoom == 1.0f) {
@@ -140,10 +140,11 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
             }
             currentViewport = newCurrentViewPort;
             currentZoom = newZoom;
+            RectF pageRect = viewportMetrics.getPageRect();
 
             clearMarkedTiles();
-            addNewTiles(viewportMetrics);
-            markTiles(viewportMetrics);
+            addNewTiles(pageRect);
+            markTiles();
         }
     }
 
@@ -153,25 +154,23 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
 
     protected abstract int getTilePriority();
 
-    private void addNewTiles(ImmutableViewportMetrics viewportMetrics) {
-        float zoom = getZoom(viewportMetrics);
-
+    private void addNewTiles(RectF pageRect) {
         for (float y = currentViewport.top; y < currentViewport.bottom; y += tileSize.height) {
-            if (y > viewportMetrics.getPageHeight()) {
+            if (y > pageRect.height()) {
                 continue;
             }
             for (float x = currentViewport.left; x < currentViewport.right; x += tileSize.width) {
-                if (x > viewportMetrics.getPageWidth()) {
+                if (x > pageRect.width()) {
                     continue;
                 }
                 boolean contains = false;
                 for (SubTile tile : tiles) {
-                    if (tile.id.x == x && tile.id.y == y && tile.id.zoom == zoom) {
+                    if (tile.id.x == x && tile.id.y == y && tile.id.zoom == currentZoom) {
                         contains = true;
                     }
                 }
                 if (!contains) {
-                    TileIdentifier tileId = new TileIdentifier((int) x, (int) y, zoom, tileSize);
+                    TileIdentifier tileId = new TileIdentifier((int) x, (int) y, currentZoom, tileSize);
                     LOEvent event = LOEventFactory.tileRequest(this, tileId, true);
                     event.mPriority = getTilePriority();
                     LOKitShell.sendEvent(event);
@@ -191,8 +190,7 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
         tiles.removeAll(tilesToRemove);
     }
 
-    private void markTiles(ImmutableViewportMetrics viewportMetrics) {
-        float zoom = getZoom(viewportMetrics);
+    private void markTiles() {
         for (SubTile tile : tiles) {
             if (FloatUtils.fuzzyEquals(tile.id.zoom, currentZoom)) {
                 RectF tileRect = tile.id.getRect();
commit cda1d75a2262622aad9072e5abf2fc46c63fbd39
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Jan 15 15:57:46 2015 +0900

    android: add onTrimMemory to ComposedTileLayer
    
    Change-Id: I9c85aa5de1495e16ec67f68043784c661c2b66ab

diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
index 37b1aeb..512559f 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
@@ -1,6 +1,9 @@
 package org.mozilla.gecko.gfx;
 
+import android.app.ActivityManager;
+import android.content.ComponentCallbacks2;
 import android.content.Context;
+import android.content.res.Configuration;
 import android.graphics.RectF;
 import android.graphics.Region;
 import android.util.Log;
@@ -15,7 +18,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
-public abstract class ComposedTileLayer extends Layer {
+public abstract class ComposedTileLayer extends Layer implements ComponentCallbacks2 {
     private static final String LOGTAG = ComposedTileLayer.class.getSimpleName();
 
     protected final List<SubTile> tiles = new CopyOnWriteArrayList<SubTile>();
@@ -24,7 +27,13 @@ public abstract class ComposedTileLayer extends Layer {
     protected RectF currentViewport = new RectF();
     protected float currentZoom;
 
+    private static int getMemoryClass(Context context) {
+        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+        return activityManager.getMemoryClass() * 1024 * 1024;
+    }
+
     public ComposedTileLayer(Context context) {
+        context.registerComponentCallbacks(this);
         this.tileSize = new IntSize(256, 256);
     }
 
@@ -185,7 +194,7 @@ public abstract class ComposedTileLayer extends Layer {
     private void markTiles(ImmutableViewportMetrics viewportMetrics) {
         float zoom = getZoom(viewportMetrics);
         for (SubTile tile : tiles) {
-            if (FloatUtils.fuzzyEquals(tile.id.zoom, zoom)) {
+            if (FloatUtils.fuzzyEquals(tile.id.zoom, currentZoom)) {
                 RectF tileRect = tile.id.getRect();
                 if (!RectF.intersects(currentViewport, tileRect)) {
                     tile.markForRemoval();
@@ -222,4 +231,24 @@ public abstract class ComposedTileLayer extends Layer {
             }
         }
     }
+
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+    }
+
+    @Override
+    public void onLowMemory() {
+        Log.i(LOGTAG, "onLowMemory");
+    }
+
+    @Override
+    public void onTrimMemory(int level) {
+        Log.i(LOGTAG, "Trimming memory " + level);
+        if (level >= 10 /*TRIM_MEMORY_RUNNING_LOW*/) {
+            Log.i(LOGTAG, "Trimming memory - TRIM_MEMORY_RUNNING_LOW");
+        } else if (level >= 15 /*TRIM_MEMORY_RUNNING_CRITICAL*/) {
+            Log.i(LOGTAG, "Trimming memory - TRIM_MEMORY_RUNNING_CRITICAL");
+            clearAndReset();
+        }
+    }
 }
\ No newline at end of file
commit f63d83318b21aeb59656372df24ac4e71b77cca1
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Jan 15 15:50:03 2015 +0900

    android: provide context to ComposedTileLayer
    
    Change-Id: If42dc9487fe11e2950becaf6b9ec857496dc6669

diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
index 31c7a07..37b1aeb 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
@@ -1,5 +1,6 @@
 package org.mozilla.gecko.gfx;
 
+import android.content.Context;
 import android.graphics.RectF;
 import android.graphics.Region;
 import android.util.Log;
@@ -23,14 +24,10 @@ public abstract class ComposedTileLayer extends Layer {
     protected RectF currentViewport = new RectF();
     protected float currentZoom;
 
-    public ComposedTileLayer() {
+    public ComposedTileLayer(Context context) {
         this.tileSize = new IntSize(256, 256);
     }
 
-    public ComposedTileLayer(IntSize tileSize) {
-        this.tileSize = tileSize;
-    }
-
     public void invalidate() {
         for (SubTile tile : tiles) {
             tile.invalidate();
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DynamicTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DynamicTileLayer.java
index 38d6d80..ea95c03 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DynamicTileLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/DynamicTileLayer.java
@@ -1,8 +1,13 @@
 package org.mozilla.gecko.gfx;
 
+import android.content.Context;
 import android.graphics.RectF;
 
 public class DynamicTileLayer extends ComposedTileLayer {
+    public DynamicTileLayer(Context context) {
+        super(context);
+    }
+
     @Override
     protected RectF getViewPort(ImmutableViewportMetrics viewportMetrics) {
         RectF rect = viewportMetrics.getViewport();
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java
index 2db6a1d..e86494c 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/FixedZoomTileLayer.java
@@ -1,8 +1,13 @@
 package org.mozilla.gecko.gfx;
 
+import android.content.Context;
 import android.graphics.RectF;
 
 public class FixedZoomTileLayer extends ComposedTileLayer {
+    public FixedZoomTileLayer(Context context) {
+        super(context);
+    }
+
     @Override
     protected RectF getViewPort(ImmutableViewportMetrics viewportMetrics) {
         float zoom = getZoom(viewportMetrics);
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
index 1bb15bc..3e70698 100644
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -108,8 +108,8 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener {
     public void notifyReady() {
         mGeckoIsReady = true;
 
-        mRootLayer = new DynamicTileLayer();
-        mLowResLayer = new FixedZoomTileLayer();
+        mRootLayer = new DynamicTileLayer(mContext);
+        mLowResLayer = new FixedZoomTileLayer(mContext);
 
         mLayerRenderer = new LayerRenderer(mView);
 
commit 5be3aecc8c88ac71a1b6acc3c328de4962ea8282
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Jan 15 15:33:58 2015 +0900

    android: guard buffer allocation and return null if alloc. fails
    
    Change-Id: I684c7af245cc755b94f69e175c652d161e0f643a

diff --git a/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java b/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
index 0e30e45..670e397 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
@@ -87,4 +87,14 @@ public final class DirectBufferAllocator {
         // can't free buffer - leave this to the VM
         return null;
     }
+
+    public static ByteBuffer guardedAllocate(int size) {
+        ByteBuffer buffer = null;
+        try {
+            buffer = allocate(size);
+        } catch (OutOfMemoryError oomException) {
+            return null;
+        }
+        return buffer;
+    }
 }
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 0e2db4b..752e0a9 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -4,6 +4,7 @@ import android.graphics.Bitmap;
 import android.graphics.RectF;
 import android.util.Log;
 
+import org.libreoffice.kit.DirectBufferAllocator;
 import org.libreoffice.kit.Document;
 import org.libreoffice.kit.LibreOfficeKit;
 import org.libreoffice.kit.Office;
@@ -189,7 +190,10 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
 
     @Override
     public CairoImage createTile(float x, float y, IntSize tileSize, float zoom) {
-        ByteBuffer buffer = ByteBuffer.allocateDirect(tileSize.width * tileSize.height * 4);
+        ByteBuffer buffer = DirectBufferAllocator.guardedAllocate(tileSize.width * tileSize.height * 4);
+        if (buffer == null)
+            return null;
+
         CairoImage image = new BufferedCairoImage(buffer, tileSize.width, tileSize.height, CairoImage.FORMAT_ARGB32);
         rerenderTile(image, x, y, tileSize, zoom);
         return image;


More information about the Libreoffice-commits mailing list