Merge "Delete a bunch of dead code" into mnc-dev

This commit is contained in:
John Reck
2015-05-07 18:11:04 +00:00
committed by Android (Google) Code Review
4 changed files with 14 additions and 65 deletions

View File

@@ -21,10 +21,12 @@ package android.graphics;
*/ */
public class Atlas { public class Atlas {
/** /**
* This flag indicates whether the packing algorithm will attempt * WARNING: These flag values are part of the on-disk configuration information,
* to rotate entries to make them fit better in the atlas. * do not change their values.
*/ */
public static final int FLAG_ALLOW_ROTATIONS = 0x1;
/** DELETED: FLAG_ROTATION = 0x01 */
/** /**
* This flag indicates whether the packing algorithm should leave * This flag indicates whether the packing algorithm should leave
* an empty 1 pixel wide border around each bitmap. This border can * an empty 1 pixel wide border around each bitmap. This border can
@@ -52,9 +54,7 @@ public class Atlas {
/** /**
* Represents a bitmap packed in the atlas. Each entry has a location in * Represents a bitmap packed in the atlas. Each entry has a location in
* pixels in the atlas and a rotation flag. If the entry was rotated, the * pixels in the atlas and a rotation flag.
* bitmap must be rotated by 90 degrees (in either direction as long as
* the origin remains the same) before being rendered into the atlas.
*/ */
public static class Entry { public static class Entry {
/** /**
@@ -65,11 +65,6 @@ public class Atlas {
* Location, in pixels, of the bitmap on the Y axis in the atlas. * Location, in pixels, of the bitmap on the Y axis in the atlas.
*/ */
public int y; public int y;
/**
* If true, the bitmap must be rotated 90 degrees in the atlas.
*/
public boolean rotated;
} }
private final Policy mPolicy; private final Policy mPolicy;
@@ -239,7 +234,6 @@ public class Atlas {
private final SplitDecision mSplitDecision; private final SplitDecision mSplitDecision;
private final boolean mAllowRotation;
private final int mPadding; private final int mPadding;
/** /**
@@ -263,7 +257,6 @@ public class Atlas {
} }
SlicePolicy(int width, int height, int flags, SplitDecision splitDecision) { SlicePolicy(int width, int height, int flags, SplitDecision splitDecision) {
mAllowRotation = (flags & FLAG_ALLOW_ROTATIONS) != 0;
mPadding = (flags & FLAG_ADD_PADDING) != 0 ? 1 : 0; mPadding = (flags & FLAG_ADD_PADDING) != 0 ? 1 : 0;
// The entire atlas is empty at first, minus padding // The entire atlas is empty at first, minus padding
@@ -360,26 +353,9 @@ public class Atlas {
* *
* @return True if the rectangle was packed in the atlas, false otherwise * @return True if the rectangle was packed in the atlas, false otherwise
*/ */
@SuppressWarnings("SuspiciousNameCombination")
private boolean insert(Cell cell, Cell prev, int width, int height, Entry entry) { private boolean insert(Cell cell, Cell prev, int width, int height, Entry entry) {
boolean rotated = false;
// If the rectangle doesn't fit we'll try to rotate it
// if possible before giving up
if (cell.width < width || cell.height < height) { if (cell.width < width || cell.height < height) {
if (mAllowRotation) { return false;
if (cell.width < height || cell.height < width) {
return false;
}
// Rotate the rectangle
int temp = width;
width = height;
height = temp;
rotated = true;
} else {
return false;
}
} }
// Remaining free space after packing the rectangle // Remaining free space after packing the rectangle
@@ -433,7 +409,6 @@ public class Atlas {
// Return the location and rotation of the packed rectangle // Return the location and rotation of the packed rectangle
entry.x = cell.x; entry.x = cell.x;
entry.y = cell.y; entry.y = cell.y;
entry.rotated = rotated;
return true; return true;
} }

View File

@@ -112,9 +112,6 @@ private:
Texture* const mDelegate; Texture* const mDelegate;
}; // struct DelegateTexture }; // struct DelegateTexture
/**
* TODO: This method does not take the rotation flag into account
*/
void AssetAtlas::createEntries(Caches& caches, int64_t* map, int count) { void AssetAtlas::createEntries(Caches& caches, int64_t* map, int count) {
const float width = float(mTexture->width); const float width = float(mTexture->width);
const float height = float(mTexture->height); const float height = float(mTexture->height);
@@ -128,7 +125,6 @@ void AssetAtlas::createEntries(Caches& caches, int64_t* map, int count) {
// pointers on 64 bit architectures. // pointers on 64 bit architectures.
const int x = static_cast<int>(map[i++]); const int x = static_cast<int>(map[i++]);
const int y = static_cast<int>(map[i++]); const int y = static_cast<int>(map[i++]);
bool rotated = map[i++] > 0;
// Bitmaps should never be null, we're just extra paranoid // Bitmaps should never be null, we're just extra paranoid
if (!pixelRef) continue; if (!pixelRef) continue;
@@ -142,7 +138,7 @@ void AssetAtlas::createEntries(Caches& caches, int64_t* map, int count) {
texture->width = pixelRef->info().width(); texture->width = pixelRef->info().width();
texture->height = pixelRef->info().height(); texture->height = pixelRef->info().height();
Entry* entry = new Entry(pixelRef, x, y, rotated, texture, mapper, *this); Entry* entry = new Entry(pixelRef, texture, mapper, *this);
texture->uvMapper = &entry->uvMapper; texture->uvMapper = &entry->uvMapper;
mEntries.add(entry->pixelRef, entry); mEntries.add(entry->pixelRef, entry);

View File

@@ -45,8 +45,8 @@ class Image;
class AssetAtlas { class AssetAtlas {
public: public:
/** /**
* Entry representing the position and rotation of a * Entry representing the texture and uvMapper of a PixelRef in the
* bitmap inside the atlas. * atlas
*/ */
class Entry { class Entry {
public: public:
@@ -77,31 +77,16 @@ public:
*/ */
SkPixelRef* pixelRef; SkPixelRef* pixelRef;
/**
* Location of the bitmap inside the atlas, in pixels.
*/
int x;
int y;
/**
* If set, the bitmap is rotated 90 degrees (clockwise)
* inside the atlas.
*/
bool rotated;
/** /**
* Atlas this entry belongs to. * Atlas this entry belongs to.
*/ */
const AssetAtlas& atlas; const AssetAtlas& atlas;
Entry(SkPixelRef* pixelRef, int x, int y, bool rotated, Entry(SkPixelRef* pixelRef, Texture* texture, const UvMapper& mapper,
Texture* texture, const UvMapper& mapper, const AssetAtlas& atlas) const AssetAtlas& atlas)
: texture(texture) : texture(texture)
, uvMapper(mapper) , uvMapper(mapper)
, pixelRef(pixelRef) , pixelRef(pixelRef)
, x(x)
, y(y)
, rotated(rotated)
, atlas(atlas) { , atlas(atlas) {
} }
@@ -120,8 +105,7 @@ public:
* Initializes the atlas with the specified buffer and * Initializes the atlas with the specified buffer and
* map. The buffer is a gralloc'd texture that will be * map. The buffer is a gralloc'd texture that will be
* used as an EGLImage. The map is a list of SkBitmap* * used as an EGLImage. The map is a list of SkBitmap*
* and their (x, y) positions as well as their rotation * and their (x, y) positions
* flags.
* *
* This method returns immediately if the atlas is already * This method returns immediately if the atlas is already
* initialized. To re-initialize the atlas, you must * initialized. To re-initialize the atlas, you must

View File

@@ -119,7 +119,6 @@ public class AssetAtlasService extends IAssetAtlas.Stub {
// long0: SkBitmap*, the native bitmap object // long0: SkBitmap*, the native bitmap object
// long1: x position // long1: x position
// long2: y position // long2: y position
// long3: rotated, 1 if the bitmap must be rotated, 0 otherwise
private long[] mAtlasMap; private long[] mAtlasMap;
/** /**
@@ -236,7 +235,7 @@ public class AssetAtlasService extends IAssetAtlas.Stub {
/** /**
* Renders a list of bitmaps into the atlas. The position of each bitmap * Renders a list of bitmaps into the atlas. The position of each bitmap
* was decided by the packing algorithm and will be honored by this * was decided by the packing algorithm and will be honored by this
* method. If need be this method will also rotate bitmaps. * method.
* *
* @param buffer The buffer to render the atlas entries into * @param buffer The buffer to render the atlas entries into
* @param atlas The atlas to pack the bitmaps into * @param atlas The atlas to pack the bitmaps into
@@ -280,16 +279,11 @@ public class AssetAtlasService extends IAssetAtlas.Stub {
canvas.save(); canvas.save();
canvas.translate(entry.x, entry.y); canvas.translate(entry.x, entry.y);
if (entry.rotated) {
canvas.translate(bitmap.getHeight(), 0.0f);
canvas.rotate(90.0f);
}
canvas.drawBitmap(bitmap, 0.0f, 0.0f, null); canvas.drawBitmap(bitmap, 0.0f, 0.0f, null);
canvas.restore(); canvas.restore();
atlasMap[mapIndex++] = bitmap.refSkPixelRef(); atlasMap[mapIndex++] = bitmap.refSkPixelRef();
atlasMap[mapIndex++] = entry.x; atlasMap[mapIndex++] = entry.x;
atlasMap[mapIndex++] = entry.y; atlasMap[mapIndex++] = entry.y;
atlasMap[mapIndex++] = entry.rotated ? 1 : 0;
} }
} }