diff options
| author | 2010-12-17 11:41:08 -0800 | |
|---|---|---|
| committer | 2010-12-17 11:41:08 -0800 | |
| commit | e27cdeeecba5b445e307d653d9cb7da007adfac3 (patch) | |
| tree | 2bd196f42ef3d904c610f2b327642391a6724e20 /libs | |
| parent | 60e41fa4456ce6bc37a33b1e4b81a56e9411199b (diff) | |
API reaview cleanup
Change-Id: Ib1aaf81130ffa6b5e6c60096c27c969e8891db3f
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java | 7 | ||||
| -rw-r--r-- | libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java | 4 | ||||
| -rw-r--r-- | libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java | 25 | ||||
| -rw-r--r-- | libs/rs/java/Samples/src/com/android/samples/RsListRS.java | 2 | ||||
| -rw-r--r-- | libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java | 16 | ||||
| -rw-r--r-- | libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java | 2 | ||||
| -rw-r--r-- | libs/rs/rs.spec | 2 | ||||
| -rw-r--r-- | libs/rs/rsFont.cpp | 36 | ||||
| -rw-r--r-- | libs/rs/rsFont.h | 6 |
9 files changed, 40 insertions, 60 deletions
diff --git a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java index 6cb50b8122fd..7d996864d1c9 100644 --- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java +++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java @@ -23,6 +23,7 @@ import java.util.Vector; import android.content.res.Resources; import android.renderscript.*; import android.renderscript.Element.Builder; +import android.renderscript.Font.Style; import android.renderscript.ProgramStore.DepthFunc; import android.util.Log; @@ -186,22 +187,20 @@ public class SceneGraphRS { FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.robot); FileA3D.IndexEntry entry = model.getIndexEntry(0); - if (entry == null || entry.getClassID() != FileA3D.ClassID.MESH) { + if (entry == null || entry.getEntryType() != FileA3D.EntryType.MESH) { Log.e("rs", "could not load model"); } else { mMesh = (Mesh)entry.getObject(); mScript.set_gTestMesh(mMesh); } - mItalic = Font.create(mRS, mRes, "DroidSerif-Italic.ttf", 8); + mItalic = Font.create(mRS, mRes, "serif", Font.Style.ITALIC, 8); mScript.set_gItalic(mItalic); initTextAllocation(); initTransformHierarchy(); - Log.v("========SceneGraph========", "transform hierarchy initialized"); - mScript.bind_gRootNode(mRootTransform.getField()); mScript.bind_gGroup(mGroup1.mParent.mChildField); diff --git a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java index 747463a051d6..5451ca10506b 100644 --- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java +++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java @@ -148,14 +148,14 @@ public class SimpleModelRS { FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.robot); FileA3D.IndexEntry entry = model.getIndexEntry(0); - if (entry == null || entry.getClassID() != FileA3D.ClassID.MESH) { + if (entry == null || entry.getEntryType() != FileA3D.EntryType.MESH) { Log.e("rs", "could not load model"); } else { mMesh = (Mesh)entry.getObject(); mScript.set_gTestMesh(mMesh); } - mItalic = Font.create(mRS, mRes, "DroidSerif-Italic.ttf", 8); + mItalic = Font.create(mRS, mRes, "serif", Font.Style.ITALIC, 8); mScript.set_gItalic(mItalic); initTextAllocation(); diff --git a/libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java b/libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java index ddb05b38b1c5..b3e8026439a5 100644 --- a/libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java +++ b/libs/rs/java/Samples/src/com/android/samples/RsBenchRS.java @@ -315,22 +315,15 @@ public class RsBenchRS { private void initFonts() { // Sans font by family name - mFontSans = Font.createFromFamily(mRS, mRes, "sans-serif", - Font.Style.NORMAL, 8); - // Create font by file name - mFontSerif = Font.create(mRS, mRes, "DroidSerif-Regular.ttf", 8); + mFontSans = Font.create(mRS, mRes, "sans-serif", Font.Style.NORMAL, 8); + mFontSerif = Font.create(mRS, mRes, "serif", Font.Style.NORMAL, 8); // Create fonts by family and style - mFontSerifBold = Font.createFromFamily(mRS, mRes, "serif", - Font.Style.BOLD, 8); - mFontSerifItalic = Font.createFromFamily(mRS, mRes, "serif", - Font.Style.ITALIC, 8); - mFontSerifBoldItalic = Font.createFromFamily(mRS, mRes, "serif", - Font.Style.BOLD_ITALIC, 8); - mFontMono = Font.createFromFamily(mRS, mRes, "mono", - Font.Style.NORMAL, 8); - - mTextAlloc = Allocation.createFromString(mRS, "String from allocation", - Allocation.USAGE_SCRIPT); + mFontSerifBold = Font.create(mRS, mRes, "serif", Font.Style.BOLD, 8); + mFontSerifItalic = Font.create(mRS, mRes, "serif", Font.Style.ITALIC, 8); + mFontSerifBoldItalic = Font.create(mRS, mRes, "serif", Font.Style.BOLD_ITALIC, 8); + mFontMono = Font.create(mRS, mRes, "mono", Font.Style.NORMAL, 8); + + mTextAlloc = Allocation.createFromString(mRS, "String from allocation", Allocation.USAGE_SCRIPT); mScript.set_gFontSans(mFontSans); mScript.set_gFontSerif(mFontSerif); @@ -351,7 +344,7 @@ public class RsBenchRS { FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.torus); FileA3D.IndexEntry entry = model.getIndexEntry(0); - if (entry == null || entry.getClassID() != FileA3D.ClassID.MESH) { + if (entry == null || entry.getEntryType() != FileA3D.EntryType.MESH) { Log.e("rs", "could not load model"); } else { mTorus = (Mesh)entry.getObject(); diff --git a/libs/rs/java/Samples/src/com/android/samples/RsListRS.java b/libs/rs/java/Samples/src/com/android/samples/RsListRS.java index 223f5528e908..8e2d51f0dbe9 100644 --- a/libs/rs/java/Samples/src/com/android/samples/RsListRS.java +++ b/libs/rs/java/Samples/src/com/android/samples/RsListRS.java @@ -134,7 +134,7 @@ public class RsListRS { mScript.bind_gList(mListAllocs); - mItalic = Font.createFromFamily(mRS, mRes, "serif", Font.Style.BOLD_ITALIC, 8); + mItalic = Font.create(mRS, mRes, "serif", Font.Style.BOLD_ITALIC, 8); mScript.set_gItalic(mItalic); mRS.bindRootScript(mScript); diff --git a/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java b/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java index 75e8d998d60f..636a48614006 100644 --- a/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java +++ b/libs/rs/java/Samples/src/com/android/samples/RsRenderStatesRS.java @@ -23,6 +23,7 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.renderscript.*; import android.renderscript.Allocation.CubemapLayout; +import android.renderscript.Font.Style; import android.renderscript.Program.TextureType; import android.renderscript.ProgramStore.DepthFunc; import android.renderscript.Sampler.Value; @@ -304,14 +305,13 @@ public class RsRenderStatesRS { private void initFonts() { // Sans font by family name - mFontSans = Font.createFromFamily(mRS, mRes, "sans-serif", Font.Style.NORMAL, 8); - // Create font by file name - mFontSerif = Font.create(mRS, mRes, "DroidSerif-Regular.ttf", 8); + mFontSans = Font.create(mRS, mRes, "sans-serif", Font.Style.NORMAL, 8); + mFontSerif = Font.create(mRS, mRes, "serif", Font.Style.NORMAL, 8); // Create fonts by family and style - mFontSerifBold = Font.createFromFamily(mRS, mRes, "serif", Font.Style.BOLD, 8); - mFontSerifItalic = Font.createFromFamily(mRS, mRes, "serif", Font.Style.ITALIC, 8); - mFontSerifBoldItalic = Font.createFromFamily(mRS, mRes, "serif", Font.Style.BOLD_ITALIC, 8); - mFontMono = Font.createFromFamily(mRS, mRes, "mono", Font.Style.NORMAL, 8); + mFontSerifBold = Font.create(mRS, mRes, "serif", Font.Style.BOLD, 8); + mFontSerifItalic = Font.create(mRS, mRes, "serif", Font.Style.ITALIC, 8); + mFontSerifBoldItalic = Font.create(mRS, mRes, "serif", Font.Style.BOLD_ITALIC, 8); + mFontMono = Font.create(mRS, mRes, "mono", Font.Style.NORMAL, 8); mTextAlloc = Allocation.createFromString(mRS, "String from allocation", Allocation.USAGE_SCRIPT); @@ -330,7 +330,7 @@ public class RsRenderStatesRS { FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.torus); FileA3D.IndexEntry entry = model.getIndexEntry(0); - if (entry == null || entry.getClassID() != FileA3D.ClassID.MESH) { + if (entry == null || entry.getEntryType() != FileA3D.EntryType.MESH) { Log.e("rs", "could not load model"); } else { mTorus = (Mesh)entry.getObject(); diff --git a/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java b/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java index 265e1d6af299..a50321e10ef9 100644 --- a/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java +++ b/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java @@ -94,7 +94,7 @@ public class RSTestCore { mScript.bind_gList(mListAllocs); - mFont = Font.createFromFamily(mRS, mRes, "serif", Font.Style.BOLD, 8); + mFont = Font.create(mRS, mRes, "serif", Font.Style.BOLD, 8); mScript.set_gFont(mFont); mRS.bindRootScript(mScript); diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 5daba089bb7d..cf94060e42fb 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -420,7 +420,7 @@ FileOpen { FontCreateFromFile { param const char *name - param uint32_t fontSize + param float fontSize param uint32_t dpi ret RsFont } diff --git a/libs/rs/rsFont.cpp b/libs/rs/rsFont.cpp index 2fa1f0aabf9f..80bca4391f44 100644 --- a/libs/rs/rsFont.cpp +++ b/libs/rs/rsFont.cpp @@ -40,20 +40,15 @@ Font::Font(Context *rsc) : ObjectBase(rsc), mCachedGlyphs(NULL) { mFace = NULL; } -bool Font::init(const char *name, uint32_t fontSize, uint32_t dpi) { +bool Font::init(const char *name, float fontSize, uint32_t dpi) { if (mInitialized) { LOGE("Reinitialization of fonts not supported"); return false; } - String8 fontsDir("/fonts/"); - String8 fullPath(getenv("ANDROID_ROOT")); - fullPath += fontsDir; - fullPath += name; - - FT_Error error = FT_New_Face(mRSC->mStateFont.getLib(), fullPath.string(), 0, &mFace); + FT_Error error = FT_New_Face(mRSC->mStateFont.getLib(), name, 0, &mFace); if (error) { - LOGE("Unable to initialize font %s", fullPath.string()); + LOGE("Unable to initialize font %s", name); return false; } @@ -61,9 +56,9 @@ bool Font::init(const char *name, uint32_t fontSize, uint32_t dpi) { mFontSize = fontSize; mDpi = dpi; - error = FT_Set_Char_Size(mFace, fontSize * 64, 0, dpi, 0); + error = FT_Set_Char_Size(mFace, (FT_F26Dot6)(fontSize * 64.0f), 0, dpi, 0); if (error) { - LOGE("Unable to set font size on %s", fullPath.string()); + LOGE("Unable to set font size on %s", name); return false; } @@ -278,7 +273,7 @@ Font::CachedGlyphInfo *Font::cacheGlyph(uint32_t glyph) { return newGlyph; } -Font * Font::create(Context *rsc, const char *name, uint32_t fontSize, uint32_t dpi) { +Font * Font::create(Context *rsc, const char *name, float fontSize, uint32_t dpi) { rsc->mStateFont.checkInit(); Vector<Font*> &activeFonts = rsc->mStateFont.mActiveFonts; @@ -332,31 +327,20 @@ FontState::FontState() { // Get the gamma float gamma = DEFAULT_TEXT_GAMMA; if (property_get(PROPERTY_TEXT_GAMMA, property, NULL) > 0) { - LOGD(" Setting text gamma to %s", property); gamma = atof(property); - } else { - LOGD(" Using default text gamma of %.2f", DEFAULT_TEXT_GAMMA); } // Get the black gamma threshold int32_t blackThreshold = DEFAULT_TEXT_BLACK_GAMMA_THRESHOLD; if (property_get(PROPERTY_TEXT_BLACK_GAMMA_THRESHOLD, property, NULL) > 0) { - LOGD(" Setting text black gamma threshold to %s", property); blackThreshold = atoi(property); - } else { - LOGD(" Using default text black gamma threshold of %d", - DEFAULT_TEXT_BLACK_GAMMA_THRESHOLD); } mBlackThreshold = (float)(blackThreshold) / 255.0f; // Get the white gamma threshold int32_t whiteThreshold = DEFAULT_TEXT_WHITE_GAMMA_THRESHOLD; if (property_get(PROPERTY_TEXT_WHITE_GAMMA_THRESHOLD, property, NULL) > 0) { - LOGD(" Setting text white gamma threshold to %s", property); whiteThreshold = atoi(property); - } else { - LOGD(" Using default white black gamma threshold of %d", - DEFAULT_TEXT_WHITE_GAMMA_THRESHOLD); } mWhiteThreshold = (float)(whiteThreshold) / 255.0f; @@ -735,7 +719,11 @@ void FontState::renderText(const char *text, uint32_t len, int32_t x, int32_t y, Font *currentFont = mRSC->getFont(); if (!currentFont) { if (!mDefault.get()) { - mDefault.set(Font::create(mRSC, "DroidSans.ttf", 16, 96)); + String8 fontsDir("/fonts/DroidSans.ttf"); + String8 fullPath(getenv("ANDROID_ROOT")); + fullPath += fontsDir; + + mDefault.set(Font::create(mRSC, fullPath.string(), 16, 96)); } currentFont = mDefault.get(); } @@ -815,7 +803,7 @@ void FontState::deinit(Context *rsc) { namespace android { namespace renderscript { -RsFont rsi_FontCreateFromFile(Context *rsc, char const *name, uint32_t fontSize, uint32_t dpi) { +RsFont rsi_FontCreateFromFile(Context *rsc, char const *name, float fontSize, uint32_t dpi) { Font *newFont = Font::create(rsc, name, fontSize, dpi); if (newFont) { newFont->incUserRef(); diff --git a/libs/rs/rsFont.h b/libs/rs/rsFont.h index 0f6815d218db..c24c9f180647 100644 --- a/libs/rs/rsFont.h +++ b/libs/rs/rsFont.h @@ -73,7 +73,7 @@ public: return RS_A3D_CLASS_ID_UNKNOWN; } - static Font * create(Context *rsc, const char *name, uint32_t fontSize, uint32_t dpi); + static Font * create(Context *rsc, const char *name, float fontSize, uint32_t dpi); protected: @@ -112,11 +112,11 @@ protected: }; String8 mFontName; - uint32_t mFontSize; + float mFontSize; uint32_t mDpi; Font(Context *rsc); - bool init(const char *name, uint32_t fontSize, uint32_t dpi); + bool init(const char *name, float fontSize, uint32_t dpi); FT_Face mFace; bool mInitialized; |