Merge "XmlAdapters sample example no longer depends on hidden XmlDocumentProvider"
diff --git a/build/Android.mk b/build/Android.mk
index 7e5d180..e4eeb0a 100644
--- a/build/Android.mk
+++ b/build/Android.mk
@@ -66,12 +66,20 @@
 ALL_SDK_FILES += $(android_jar_full_target)
 
 
-android-support-v4_build_module := $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android-support-v4_intermediates/javalib.jar
-android-support-v4_intermediates := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/android-support-v4_intermediates
-android-support-v4_full_target := $(android-support-v4_intermediates)/android-support-v4.jar
-$(android-support-v4_full_target): $(android-support-v4_build_module)
-	@echo Package android-support-v4.jar: $@
-	$(hide)mkdir -p $(dir $@)
-	$(hide)$(ACP) $< $@
+# $(1): the Java library name
+define _package_sdk_library
+$(eval _psm_build_module := $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/$(1)_intermediates/javalib.jar)
+$(eval _psm_packaging_target := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(1)_intermediates/$(1).jar)
+$(_psm_packaging_target) : $(_psm_build_module) | $(ACP)
+	@echo "Package $(1).jar: $$@"
+	$(hide) mkdir -p $$(dir $$@)
+	$(hide) $(ACP) $$< $$@
 
-ALL_SDK_FILES += $(android-support-v4_full_target)
+ALL_SDK_FILES += $(_psm_packaging_target)
+$(eval _psm_build_module :=)
+$(eval _psm_packaging_target :=)
+endef
+
+ANDROID_SUPPORT_LIBRARIES := android-support-v4 android-support-v13
+
+$(foreach lib, $(ANDROID_SUPPORT_LIBRARIES), $(eval $(call _package_sdk_library,$(lib))))
diff --git a/build/sdk.atree b/build/sdk.atree
index 688154c..e3de14c 100644
--- a/build/sdk.atree
+++ b/build/sdk.atree
@@ -154,7 +154,6 @@
 development/samples/AccessibilityService       samples/${PLATFORM_NAME}/AccessibilityService
 development/samples/AccelerometerPlay          samples/${PLATFORM_NAME}/AccelerometerPlay
 development/samples/ApiDemos                   samples/${PLATFORM_NAME}/ApiDemos
-${OUT_DIR}/target/common/obj/PACKAGING/android-support-v4_intermediates/android-support-v4.jar    samples/${PLATFORM_NAME}/ApiDemos/libs/android-support-v4.jar
 development/samples/BackupRestore              samples/${PLATFORM_NAME}/BackupRestore
 development/samples/BasicGLSurfaceView         samples/${PLATFORM_NAME}/BasicGLSurfaceView
 development/samples/BluetoothChat              samples/${PLATFORM_NAME}/BluetoothChat
@@ -167,6 +166,7 @@
 development/samples/LunarLander                samples/${PLATFORM_NAME}/LunarLander
 development/samples/MultiResolution            samples/${PLATFORM_NAME}/MultiResolution
 development/samples/NotePad                    samples/${PLATFORM_NAME}/NotePad
+development/samples/RandomMusicPlayer          samples/${PLATFORM_NAME}/RandomMusicPlayer
 development/samples/SampleSyncAdapter          samples/${PLATFORM_NAME}/SampleSyncAdapter
 development/samples/SearchableDictionary       samples/${PLATFORM_NAME}/SearchableDictionary
 development/samples/SipDemo                    samples/${PLATFORM_NAME}/SipDemo
@@ -211,4 +211,7 @@
 sdk/files/sdk_files_NOTICE.txt                                                                    extras/android/compatibility/NOTICE.txt
 ${OUT_DIR}/target/common/obj/PACKAGING/android-support-v4_intermediates/android-support-v4.jar    extras/android/compatibility/v4/android-support-v4.jar
 frameworks/support/v4                                                                             extras/android/compatibility/v4/src
-development/samples/ApiDemos                                                                      extras/android/compatibility/v4/samples/ApiDemos
+development/samples/Support4Demos                                                                 extras/android/compatibility/v4/samples/Support4Demos
+${OUT_DIR}/target/common/obj/PACKAGING/android-support-v13_intermediates/android-support-v13.jar  extras/android/compatibility/v13/android-support-v13.jar
+frameworks/support/v13                                                                            extras/android/compatibility/v13/src
+development/samples/Support13Demos                                                                extras/android/compatibility/v13/samples/Support13Demos
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeyGetFrameRateEvent.java b/cmds/monkey/src/com/android/commands/monkey/MonkeyGetFrameRateEvent.java
new file mode 100644
index 0000000..164d936
--- /dev/null
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeyGetFrameRateEvent.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.commands.monkey;
+
+import android.app.IActivityManager;
+import android.util.Log;
+import android.view.IWindowManager;
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.text.DecimalFormat;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+/**
+ * Events for running a special shell command to capture the frame rate.
+ * To run this test, the system property viewancestor.profile_rendering
+ * must be set to true to force the currently focused window to render at
+ * 60 Hz.
+ */
+public class MonkeyGetFrameRateEvent extends MonkeyEvent {
+
+    private String GET_FRAMERATE_CMD = "service call SurfaceFlinger 1013";
+    private String mStatus;
+    private static long mStartTime; // in millisecond
+    private static long mEndTime; // in millisecond
+    private static float mDuration; // in seconds
+    private static String mTestCaseName = null;
+    private static int mStartFrameNo;
+    private static int mEndFrameNo;
+
+    private static final String TAG = "MonkeyGetFrameRateEvent";
+    private static final String LOG_FILE = "/sdcard/avgFrameRateOut.txt";
+
+    private static final Pattern NO_OF_FRAMES_PATTERN =
+        Pattern.compile(".*\\(([a-f[A-F][0-9]].*?)\\s.*\\)");
+
+    public MonkeyGetFrameRateEvent(String status, String testCaseName) {
+        super(EVENT_TYPE_ACTIVITY);
+        mStatus = status;
+        mTestCaseName = testCaseName;
+    }
+
+    public MonkeyGetFrameRateEvent(String status) {
+        super(EVENT_TYPE_ACTIVITY);
+        mStatus = status;
+    }
+
+    //Calculate the average frame rate
+    private float getAverageFrameRate(int totalNumberOfFrame, float duration) {
+        float avgFrameRate = 0;
+        if (duration > 0) {
+            avgFrameRate = (totalNumberOfFrame / duration);
+        }
+        return avgFrameRate;
+    }
+
+    /**
+     * Calculate the frame rate and write the output to a file on the SD card.
+     */
+    private void writeAverageFrameRate() {
+        FileWriter writer = null;
+        float avgFrameRate;
+        int totalNumberOfFrame = 0;
+        try {
+            writer = new FileWriter(LOG_FILE, true); // true = append
+            totalNumberOfFrame = mEndFrameNo - mStartFrameNo;
+            avgFrameRate = getAverageFrameRate(totalNumberOfFrame, mDuration);
+            writer.write(String.format("%s:%.2f\n",mTestCaseName,avgFrameRate));
+            writer.close();
+        } catch (IOException e) {
+            Log.w(TAG, "Can't write sdcard log file", e);
+        } finally {
+            try {
+                if (writer != null) writer.close();
+            } catch (IOException e) {
+                Log.e(TAG, "IOException " + e.toString());
+            }
+        }
+    }
+
+    // Parse the output of the surfaceFlinge shell command call
+    private String getNumberOfFrames(String input){
+        String noOfFrames = null;
+        Matcher m = NO_OF_FRAMES_PATTERN.matcher(input);
+        if (m.matches()){
+            noOfFrames = m.group(1);
+        }
+        return noOfFrames;
+    }
+
+    @Override
+    public int injectEvent(IWindowManager iwm, IActivityManager iam, int verbose) {
+        java.lang.Process p = null;
+        BufferedReader result = null;
+        try {
+            p = Runtime.getRuntime().exec(GET_FRAMERATE_CMD);
+            int status = p.waitFor();
+            if (status != 0) {
+                System.err.println(String.format("// Shell command %s status was %s",
+                        GET_FRAMERATE_CMD, status));
+            }
+            result = new BufferedReader(new InputStreamReader(p.getInputStream()));
+
+            //Only need the first line of the output
+            String output = result.readLine();
+
+            if (output != null) {
+                if (mStatus == "start") {
+                    mStartFrameNo = Integer.parseInt(getNumberOfFrames(output), 16);
+                    mStartTime = System.currentTimeMillis();
+                } else if (mStatus == "end") {
+                    mEndFrameNo = Integer.parseInt(getNumberOfFrames(output), 16);
+                    mEndTime = System.currentTimeMillis();
+                    long diff = mEndTime - mStartTime;
+                    mDuration = (float)(diff/1000.0);
+                    writeAverageFrameRate();
+                }
+            }
+        } catch (Exception e) {
+            System.err.println("// Exception from " + GET_FRAMERATE_CMD + ":");
+            System.err.println(e.toString());
+        } finally {
+            try {
+                if (result != null) {
+                    result.close();
+                }
+                if (p != null) {
+                    p.destroy();
+                }
+            } catch (IOException e) {
+                System.err.println(e.toString());
+            }
+        }
+        return MonkeyEvent.INJECT_SUCCESS;
+    }
+}
\ No newline at end of file
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java
index 09ec8e9..2808f04 100644
--- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java
@@ -117,6 +117,10 @@
 
     private static final String EVENT_KEYWORD_DRAG = "Drag";
 
+    private static final String EVENT_KEYWORD_START_FRAMERATE_CAPTURE = "StartCaptureFramerate";
+
+    private static final String EVENT_KEYWORD_END_FRAMERATE_CAPTURE = "EndCaptureFramerate";
+
     // a line at the end of the header
     private static final String STARTING_DATA_LINE = "start data >>";
 
@@ -523,6 +527,21 @@
             return;
         }
 
+        if (s.indexOf(EVENT_KEYWORD_START_FRAMERATE_CAPTURE) >= 0) {
+            MonkeyGetFrameRateEvent e = new MonkeyGetFrameRateEvent("start");
+            mQ.addLast(e);
+            return;
+        }
+
+        if (s.indexOf(EVENT_KEYWORD_END_FRAMERATE_CAPTURE) >= 0 && args.length == 1) {
+            String input = args[0];
+            MonkeyGetFrameRateEvent e = new MonkeyGetFrameRateEvent("end", input);
+            mQ.addLast(e);
+            return;
+        }
+
+
+
     }
 
     /**
diff --git a/ndk/platforms/android-3/arch-x86/lib/crtbegin_dynamic.o b/ndk/platforms/android-3/arch-x86/lib/crtbegin_dynamic.o
deleted file mode 100644
index c620c30..0000000
--- a/ndk/platforms/android-3/arch-x86/lib/crtbegin_dynamic.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-x86/lib/crtbegin_static.o b/ndk/platforms/android-3/arch-x86/lib/crtbegin_static.o
deleted file mode 100644
index c7505ee..0000000
--- a/ndk/platforms/android-3/arch-x86/lib/crtbegin_static.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-x86/lib/crtend_android.o b/ndk/platforms/android-3/arch-x86/lib/crtend_android.o
deleted file mode 100644
index 2a835b7..0000000
--- a/ndk/platforms/android-3/arch-x86/lib/crtend_android.o
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-x86/lib/libc.a b/ndk/platforms/android-3/arch-x86/lib/libc.a
deleted file mode 100644
index 15403b1..0000000
--- a/ndk/platforms/android-3/arch-x86/lib/libc.a
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-x86/lib/libc.so b/ndk/platforms/android-3/arch-x86/lib/libc.so
deleted file mode 100755
index fb6851c..0000000
--- a/ndk/platforms/android-3/arch-x86/lib/libc.so
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-x86/lib/libc_common.a b/ndk/platforms/android-3/arch-x86/lib/libc_common.a
deleted file mode 100644
index aed18c7..0000000
--- a/ndk/platforms/android-3/arch-x86/lib/libc_common.a
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-x86/lib/libdl.so b/ndk/platforms/android-3/arch-x86/lib/libdl.so
deleted file mode 100755
index 3f2cbeb..0000000
--- a/ndk/platforms/android-3/arch-x86/lib/libdl.so
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-x86/lib/libm.a b/ndk/platforms/android-3/arch-x86/lib/libm.a
deleted file mode 100644
index 4e7c1f9..0000000
--- a/ndk/platforms/android-3/arch-x86/lib/libm.a
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-x86/lib/libm.so b/ndk/platforms/android-3/arch-x86/lib/libm.so
deleted file mode 100755
index 1f46494..0000000
--- a/ndk/platforms/android-3/arch-x86/lib/libm.so
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-x86/lib/libstdc++.a b/ndk/platforms/android-3/arch-x86/lib/libstdc++.a
deleted file mode 100644
index ff5c78e..0000000
--- a/ndk/platforms/android-3/arch-x86/lib/libstdc++.a
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-x86/lib/libstdc++.so b/ndk/platforms/android-3/arch-x86/lib/libstdc++.so
deleted file mode 100755
index 79124d1..0000000
--- a/ndk/platforms/android-3/arch-x86/lib/libstdc++.so
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-x86/lib/libthread_db.a b/ndk/platforms/android-3/arch-x86/lib/libthread_db.a
deleted file mode 100644
index abe0957..0000000
--- a/ndk/platforms/android-3/arch-x86/lib/libthread_db.a
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-x86/lib/libthread_db.so b/ndk/platforms/android-3/arch-x86/lib/libthread_db.so
deleted file mode 100755
index 8614274..0000000
--- a/ndk/platforms/android-3/arch-x86/lib/libthread_db.so
+++ /dev/null
Binary files differ
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/a.out.h b/ndk/platforms/android-9/arch-x86/include/asm/a.out.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/a.out.h
rename to ndk/platforms/android-9/arch-x86/include/asm/a.out.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/acpi.h b/ndk/platforms/android-9/arch-x86/include/asm/acpi.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/acpi.h
rename to ndk/platforms/android-9/arch-x86/include/asm/acpi.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/acpi_32.h b/ndk/platforms/android-9/arch-x86/include/asm/acpi_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/acpi_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/acpi_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/alternative.h b/ndk/platforms/android-9/arch-x86/include/asm/alternative.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/alternative.h
rename to ndk/platforms/android-9/arch-x86/include/asm/alternative.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/alternative_32.h b/ndk/platforms/android-9/arch-x86/include/asm/alternative_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/alternative_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/alternative_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/apic.h b/ndk/platforms/android-9/arch-x86/include/asm/apic.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/apic.h
rename to ndk/platforms/android-9/arch-x86/include/asm/apic.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/apic_32.h b/ndk/platforms/android-9/arch-x86/include/asm/apic_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/apic_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/apic_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/apicdef.h b/ndk/platforms/android-9/arch-x86/include/asm/apicdef.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/apicdef.h
rename to ndk/platforms/android-9/arch-x86/include/asm/apicdef.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/apicdef_32.h b/ndk/platforms/android-9/arch-x86/include/asm/apicdef_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/apicdef_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/apicdef_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/atomic.h b/ndk/platforms/android-9/arch-x86/include/asm/atomic.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/atomic.h
rename to ndk/platforms/android-9/arch-x86/include/asm/atomic.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/atomic_32.h b/ndk/platforms/android-9/arch-x86/include/asm/atomic_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/atomic_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/atomic_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/auxvec.h b/ndk/platforms/android-9/arch-x86/include/asm/auxvec.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/auxvec.h
rename to ndk/platforms/android-9/arch-x86/include/asm/auxvec.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/bitops.h b/ndk/platforms/android-9/arch-x86/include/asm/bitops.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/bitops.h
rename to ndk/platforms/android-9/arch-x86/include/asm/bitops.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/bitops_32.h b/ndk/platforms/android-9/arch-x86/include/asm/bitops_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/bitops_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/bitops_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/bug.h b/ndk/platforms/android-9/arch-x86/include/asm/bug.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/bug.h
rename to ndk/platforms/android-9/arch-x86/include/asm/bug.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/byteorder.h b/ndk/platforms/android-9/arch-x86/include/asm/byteorder.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/byteorder.h
rename to ndk/platforms/android-9/arch-x86/include/asm/byteorder.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/cache.h b/ndk/platforms/android-9/arch-x86/include/asm/cache.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/cache.h
rename to ndk/platforms/android-9/arch-x86/include/asm/cache.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/cacheflush.h b/ndk/platforms/android-9/arch-x86/include/asm/cacheflush.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/cacheflush.h
rename to ndk/platforms/android-9/arch-x86/include/asm/cacheflush.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/cmpxchg.h b/ndk/platforms/android-9/arch-x86/include/asm/cmpxchg.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/cmpxchg.h
rename to ndk/platforms/android-9/arch-x86/include/asm/cmpxchg.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/cmpxchg_32.h b/ndk/platforms/android-9/arch-x86/include/asm/cmpxchg_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/cmpxchg_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/cmpxchg_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/cpufeature.h b/ndk/platforms/android-9/arch-x86/include/asm/cpufeature.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/cpufeature.h
rename to ndk/platforms/android-9/arch-x86/include/asm/cpufeature.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/cpufeature_32.h b/ndk/platforms/android-9/arch-x86/include/asm/cpufeature_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/cpufeature_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/cpufeature_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/cputime.h b/ndk/platforms/android-9/arch-x86/include/asm/cputime.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/cputime.h
rename to ndk/platforms/android-9/arch-x86/include/asm/cputime.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/current.h b/ndk/platforms/android-9/arch-x86/include/asm/current.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/current.h
rename to ndk/platforms/android-9/arch-x86/include/asm/current.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/current_32.h b/ndk/platforms/android-9/arch-x86/include/asm/current_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/current_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/current_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/delay.h b/ndk/platforms/android-9/arch-x86/include/asm/delay.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/delay.h
rename to ndk/platforms/android-9/arch-x86/include/asm/delay.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/desc.h b/ndk/platforms/android-9/arch-x86/include/asm/desc.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/desc.h
rename to ndk/platforms/android-9/arch-x86/include/asm/desc.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/desc_32.h b/ndk/platforms/android-9/arch-x86/include/asm/desc_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/desc_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/desc_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/desc_defs.h b/ndk/platforms/android-9/arch-x86/include/asm/desc_defs.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/desc_defs.h
rename to ndk/platforms/android-9/arch-x86/include/asm/desc_defs.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/div64.h b/ndk/platforms/android-9/arch-x86/include/asm/div64.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/div64.h
rename to ndk/platforms/android-9/arch-x86/include/asm/div64.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/dma-mapping.h b/ndk/platforms/android-9/arch-x86/include/asm/dma-mapping.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/dma-mapping.h
rename to ndk/platforms/android-9/arch-x86/include/asm/dma-mapping.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/dma-mapping_32.h b/ndk/platforms/android-9/arch-x86/include/asm/dma-mapping_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/dma-mapping_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/dma-mapping_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/dma.h b/ndk/platforms/android-9/arch-x86/include/asm/dma.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/dma.h
rename to ndk/platforms/android-9/arch-x86/include/asm/dma.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/dma_32.h b/ndk/platforms/android-9/arch-x86/include/asm/dma_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/dma_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/dma_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/dwarf2.h b/ndk/platforms/android-9/arch-x86/include/asm/dwarf2.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/dwarf2.h
rename to ndk/platforms/android-9/arch-x86/include/asm/dwarf2.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/dwarf2_32.h b/ndk/platforms/android-9/arch-x86/include/asm/dwarf2_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/dwarf2_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/dwarf2_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/e820.h b/ndk/platforms/android-9/arch-x86/include/asm/e820.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/e820.h
rename to ndk/platforms/android-9/arch-x86/include/asm/e820.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/elf.h b/ndk/platforms/android-9/arch-x86/include/asm/elf.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/elf.h
rename to ndk/platforms/android-9/arch-x86/include/asm/elf.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/errno.h b/ndk/platforms/android-9/arch-x86/include/asm/errno.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/errno.h
rename to ndk/platforms/android-9/arch-x86/include/asm/errno.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/fcntl.h b/ndk/platforms/android-9/arch-x86/include/asm/fcntl.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/fcntl.h
rename to ndk/platforms/android-9/arch-x86/include/asm/fcntl.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/fixmap.h b/ndk/platforms/android-9/arch-x86/include/asm/fixmap.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/fixmap.h
rename to ndk/platforms/android-9/arch-x86/include/asm/fixmap.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/fixmap_32.h b/ndk/platforms/android-9/arch-x86/include/asm/fixmap_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/fixmap_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/fixmap_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/genapic.h b/ndk/platforms/android-9/arch-x86/include/asm/genapic.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/genapic.h
rename to ndk/platforms/android-9/arch-x86/include/asm/genapic.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/genapic_32.h b/ndk/platforms/android-9/arch-x86/include/asm/genapic_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/genapic_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/genapic_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/hardirq.h b/ndk/platforms/android-9/arch-x86/include/asm/hardirq.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/hardirq.h
rename to ndk/platforms/android-9/arch-x86/include/asm/hardirq.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/hardirq_32.h b/ndk/platforms/android-9/arch-x86/include/asm/hardirq_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/hardirq_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/hardirq_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/highmem.h b/ndk/platforms/android-9/arch-x86/include/asm/highmem.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/highmem.h
rename to ndk/platforms/android-9/arch-x86/include/asm/highmem.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/hw_irq.h b/ndk/platforms/android-9/arch-x86/include/asm/hw_irq.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/hw_irq.h
rename to ndk/platforms/android-9/arch-x86/include/asm/hw_irq.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/hw_irq_32.h b/ndk/platforms/android-9/arch-x86/include/asm/hw_irq_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/hw_irq_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/hw_irq_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/i387.h b/ndk/platforms/android-9/arch-x86/include/asm/i387.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/i387.h
rename to ndk/platforms/android-9/arch-x86/include/asm/i387.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/i387_32.h b/ndk/platforms/android-9/arch-x86/include/asm/i387_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/i387_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/i387_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/i8253.h b/ndk/platforms/android-9/arch-x86/include/asm/i8253.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/i8253.h
rename to ndk/platforms/android-9/arch-x86/include/asm/i8253.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/i8259.h b/ndk/platforms/android-9/arch-x86/include/asm/i8259.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/i8259.h
rename to ndk/platforms/android-9/arch-x86/include/asm/i8259.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/ia32_unistd.h b/ndk/platforms/android-9/arch-x86/include/asm/ia32_unistd.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/ia32_unistd.h
rename to ndk/platforms/android-9/arch-x86/include/asm/ia32_unistd.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/io.h b/ndk/platforms/android-9/arch-x86/include/asm/io.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/io.h
rename to ndk/platforms/android-9/arch-x86/include/asm/io.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/io_32.h b/ndk/platforms/android-9/arch-x86/include/asm/io_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/io_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/io_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/io_apic.h b/ndk/platforms/android-9/arch-x86/include/asm/io_apic.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/io_apic.h
rename to ndk/platforms/android-9/arch-x86/include/asm/io_apic.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/io_apic_32.h b/ndk/platforms/android-9/arch-x86/include/asm/io_apic_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/io_apic_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/io_apic_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/ioctl.h b/ndk/platforms/android-9/arch-x86/include/asm/ioctl.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/ioctl.h
rename to ndk/platforms/android-9/arch-x86/include/asm/ioctl.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/ioctls.h b/ndk/platforms/android-9/arch-x86/include/asm/ioctls.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/ioctls.h
rename to ndk/platforms/android-9/arch-x86/include/asm/ioctls.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/ipcbuf.h b/ndk/platforms/android-9/arch-x86/include/asm/ipcbuf.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/ipcbuf.h
rename to ndk/platforms/android-9/arch-x86/include/asm/ipcbuf.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/irq.h b/ndk/platforms/android-9/arch-x86/include/asm/irq.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/irq.h
rename to ndk/platforms/android-9/arch-x86/include/asm/irq.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/irq_32.h b/ndk/platforms/android-9/arch-x86/include/asm/irq_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/irq_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/irq_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/irqflags.h b/ndk/platforms/android-9/arch-x86/include/asm/irqflags.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/irqflags.h
rename to ndk/platforms/android-9/arch-x86/include/asm/irqflags.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/irqflags_32.h b/ndk/platforms/android-9/arch-x86/include/asm/irqflags_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/irqflags_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/irqflags_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/ist.h b/ndk/platforms/android-9/arch-x86/include/asm/ist.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/ist.h
rename to ndk/platforms/android-9/arch-x86/include/asm/ist.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/kmap_types.h b/ndk/platforms/android-9/arch-x86/include/asm/kmap_types.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/kmap_types.h
rename to ndk/platforms/android-9/arch-x86/include/asm/kmap_types.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/ldt.h b/ndk/platforms/android-9/arch-x86/include/asm/ldt.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/ldt.h
rename to ndk/platforms/android-9/arch-x86/include/asm/ldt.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/linkage.h b/ndk/platforms/android-9/arch-x86/include/asm/linkage.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/linkage.h
rename to ndk/platforms/android-9/arch-x86/include/asm/linkage.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/linkage_32.h b/ndk/platforms/android-9/arch-x86/include/asm/linkage_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/linkage_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/linkage_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/local.h b/ndk/platforms/android-9/arch-x86/include/asm/local.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/local.h
rename to ndk/platforms/android-9/arch-x86/include/asm/local.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/local_32.h b/ndk/platforms/android-9/arch-x86/include/asm/local_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/local_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/local_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/math_emu.h b/ndk/platforms/android-9/arch-x86/include/asm/math_emu.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/math_emu.h
rename to ndk/platforms/android-9/arch-x86/include/asm/math_emu.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/mc146818rtc.h b/ndk/platforms/android-9/arch-x86/include/asm/mc146818rtc.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/mc146818rtc.h
rename to ndk/platforms/android-9/arch-x86/include/asm/mc146818rtc.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/mc146818rtc_32.h b/ndk/platforms/android-9/arch-x86/include/asm/mc146818rtc_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/mc146818rtc_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/mc146818rtc_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/mman.h b/ndk/platforms/android-9/arch-x86/include/asm/mman.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/mman.h
rename to ndk/platforms/android-9/arch-x86/include/asm/mman.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/mmsegment.h b/ndk/platforms/android-9/arch-x86/include/asm/mmsegment.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/mmsegment.h
rename to ndk/platforms/android-9/arch-x86/include/asm/mmsegment.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/mmu.h b/ndk/platforms/android-9/arch-x86/include/asm/mmu.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/mmu.h
rename to ndk/platforms/android-9/arch-x86/include/asm/mmu.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/module.h b/ndk/platforms/android-9/arch-x86/include/asm/module.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/module.h
rename to ndk/platforms/android-9/arch-x86/include/asm/module.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/module_32.h b/ndk/platforms/android-9/arch-x86/include/asm/module_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/module_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/module_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/mpspec.h b/ndk/platforms/android-9/arch-x86/include/asm/mpspec.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/mpspec.h
rename to ndk/platforms/android-9/arch-x86/include/asm/mpspec.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/mpspec_32.h b/ndk/platforms/android-9/arch-x86/include/asm/mpspec_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/mpspec_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/mpspec_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/mpspec_def.h b/ndk/platforms/android-9/arch-x86/include/asm/mpspec_def.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/mpspec_def.h
rename to ndk/platforms/android-9/arch-x86/include/asm/mpspec_def.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/msgbuf.h b/ndk/platforms/android-9/arch-x86/include/asm/msgbuf.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/msgbuf.h
rename to ndk/platforms/android-9/arch-x86/include/asm/msgbuf.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/msr-index.h b/ndk/platforms/android-9/arch-x86/include/asm/msr-index.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/msr-index.h
rename to ndk/platforms/android-9/arch-x86/include/asm/msr-index.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/msr.h b/ndk/platforms/android-9/arch-x86/include/asm/msr.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/msr.h
rename to ndk/platforms/android-9/arch-x86/include/asm/msr.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/page.h b/ndk/platforms/android-9/arch-x86/include/asm/page.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/page.h
rename to ndk/platforms/android-9/arch-x86/include/asm/page.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/page_32.h b/ndk/platforms/android-9/arch-x86/include/asm/page_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/page_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/page_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/param.h b/ndk/platforms/android-9/arch-x86/include/asm/param.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/param.h
rename to ndk/platforms/android-9/arch-x86/include/asm/param.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/paravirt.h b/ndk/platforms/android-9/arch-x86/include/asm/paravirt.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/paravirt.h
rename to ndk/platforms/android-9/arch-x86/include/asm/paravirt.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/pda.h b/ndk/platforms/android-9/arch-x86/include/asm/pda.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/pda.h
rename to ndk/platforms/android-9/arch-x86/include/asm/pda.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/percpu.h b/ndk/platforms/android-9/arch-x86/include/asm/percpu.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/percpu.h
rename to ndk/platforms/android-9/arch-x86/include/asm/percpu.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/percpu_32.h b/ndk/platforms/android-9/arch-x86/include/asm/percpu_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/percpu_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/percpu_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/pgalloc.h b/ndk/platforms/android-9/arch-x86/include/asm/pgalloc.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/pgalloc.h
rename to ndk/platforms/android-9/arch-x86/include/asm/pgalloc.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/pgalloc_32.h b/ndk/platforms/android-9/arch-x86/include/asm/pgalloc_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/pgalloc_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/pgalloc_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/pgtable-2level-defs.h b/ndk/platforms/android-9/arch-x86/include/asm/pgtable-2level-defs.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/pgtable-2level-defs.h
rename to ndk/platforms/android-9/arch-x86/include/asm/pgtable-2level-defs.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/pgtable-2level.h b/ndk/platforms/android-9/arch-x86/include/asm/pgtable-2level.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/pgtable-2level.h
rename to ndk/platforms/android-9/arch-x86/include/asm/pgtable-2level.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/pgtable.h b/ndk/platforms/android-9/arch-x86/include/asm/pgtable.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/pgtable.h
rename to ndk/platforms/android-9/arch-x86/include/asm/pgtable.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/pgtable_32.h b/ndk/platforms/android-9/arch-x86/include/asm/pgtable_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/pgtable_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/pgtable_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/poll.h b/ndk/platforms/android-9/arch-x86/include/asm/poll.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/poll.h
rename to ndk/platforms/android-9/arch-x86/include/asm/poll.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/posix_types.h b/ndk/platforms/android-9/arch-x86/include/asm/posix_types.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/posix_types.h
rename to ndk/platforms/android-9/arch-x86/include/asm/posix_types.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/posix_types_32.h b/ndk/platforms/android-9/arch-x86/include/asm/posix_types_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/posix_types_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/posix_types_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/prctl.h b/ndk/platforms/android-9/arch-x86/include/asm/prctl.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/prctl.h
rename to ndk/platforms/android-9/arch-x86/include/asm/prctl.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/processor-flags.h b/ndk/platforms/android-9/arch-x86/include/asm/processor-flags.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/processor-flags.h
rename to ndk/platforms/android-9/arch-x86/include/asm/processor-flags.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/processor.h b/ndk/platforms/android-9/arch-x86/include/asm/processor.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/processor.h
rename to ndk/platforms/android-9/arch-x86/include/asm/processor.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/processor_32.h b/ndk/platforms/android-9/arch-x86/include/asm/processor_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/processor_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/processor_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/ptrace-abi.h b/ndk/platforms/android-9/arch-x86/include/asm/ptrace-abi.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/ptrace-abi.h
rename to ndk/platforms/android-9/arch-x86/include/asm/ptrace-abi.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/ptrace.h b/ndk/platforms/android-9/arch-x86/include/asm/ptrace.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/ptrace.h
rename to ndk/platforms/android-9/arch-x86/include/asm/ptrace.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/required-features.h b/ndk/platforms/android-9/arch-x86/include/asm/required-features.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/required-features.h
rename to ndk/platforms/android-9/arch-x86/include/asm/required-features.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/resource.h b/ndk/platforms/android-9/arch-x86/include/asm/resource.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/resource.h
rename to ndk/platforms/android-9/arch-x86/include/asm/resource.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/rwlock.h b/ndk/platforms/android-9/arch-x86/include/asm/rwlock.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/rwlock.h
rename to ndk/platforms/android-9/arch-x86/include/asm/rwlock.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/scatterlist.h b/ndk/platforms/android-9/arch-x86/include/asm/scatterlist.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/scatterlist.h
rename to ndk/platforms/android-9/arch-x86/include/asm/scatterlist.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/scatterlist_32.h b/ndk/platforms/android-9/arch-x86/include/asm/scatterlist_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/scatterlist_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/scatterlist_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/sections.h b/ndk/platforms/android-9/arch-x86/include/asm/sections.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/sections.h
rename to ndk/platforms/android-9/arch-x86/include/asm/sections.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/segment.h b/ndk/platforms/android-9/arch-x86/include/asm/segment.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/segment.h
rename to ndk/platforms/android-9/arch-x86/include/asm/segment.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/segment_32.h b/ndk/platforms/android-9/arch-x86/include/asm/segment_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/segment_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/segment_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/semaphore.h b/ndk/platforms/android-9/arch-x86/include/asm/semaphore.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/semaphore.h
rename to ndk/platforms/android-9/arch-x86/include/asm/semaphore.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/semaphore_32.h b/ndk/platforms/android-9/arch-x86/include/asm/semaphore_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/semaphore_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/semaphore_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/sembuf.h b/ndk/platforms/android-9/arch-x86/include/asm/sembuf.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/sembuf.h
rename to ndk/platforms/android-9/arch-x86/include/asm/sembuf.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/setup.h b/ndk/platforms/android-9/arch-x86/include/asm/setup.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/setup.h
rename to ndk/platforms/android-9/arch-x86/include/asm/setup.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/shmbuf.h b/ndk/platforms/android-9/arch-x86/include/asm/shmbuf.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/shmbuf.h
rename to ndk/platforms/android-9/arch-x86/include/asm/shmbuf.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/shmparam.h b/ndk/platforms/android-9/arch-x86/include/asm/shmparam.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/shmparam.h
rename to ndk/platforms/android-9/arch-x86/include/asm/shmparam.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/sigcontext.h b/ndk/platforms/android-9/arch-x86/include/asm/sigcontext.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/sigcontext.h
rename to ndk/platforms/android-9/arch-x86/include/asm/sigcontext.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/siginfo.h b/ndk/platforms/android-9/arch-x86/include/asm/siginfo.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/siginfo.h
rename to ndk/platforms/android-9/arch-x86/include/asm/siginfo.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/signal.h b/ndk/platforms/android-9/arch-x86/include/asm/signal.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/signal.h
rename to ndk/platforms/android-9/arch-x86/include/asm/signal.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/smp.h b/ndk/platforms/android-9/arch-x86/include/asm/smp.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/smp.h
rename to ndk/platforms/android-9/arch-x86/include/asm/smp.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/smp_32.h b/ndk/platforms/android-9/arch-x86/include/asm/smp_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/smp_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/smp_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/socket.h b/ndk/platforms/android-9/arch-x86/include/asm/socket.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/socket.h
rename to ndk/platforms/android-9/arch-x86/include/asm/socket.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/sockios.h b/ndk/platforms/android-9/arch-x86/include/asm/sockios.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/sockios.h
rename to ndk/platforms/android-9/arch-x86/include/asm/sockios.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/spinlock.h b/ndk/platforms/android-9/arch-x86/include/asm/spinlock.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/spinlock.h
rename to ndk/platforms/android-9/arch-x86/include/asm/spinlock.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/spinlock_32.h b/ndk/platforms/android-9/arch-x86/include/asm/spinlock_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/spinlock_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/spinlock_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/spinlock_types.h b/ndk/platforms/android-9/arch-x86/include/asm/spinlock_types.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/spinlock_types.h
rename to ndk/platforms/android-9/arch-x86/include/asm/spinlock_types.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/stat.h b/ndk/platforms/android-9/arch-x86/include/asm/stat.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/stat.h
rename to ndk/platforms/android-9/arch-x86/include/asm/stat.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/statfs.h b/ndk/platforms/android-9/arch-x86/include/asm/statfs.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/statfs.h
rename to ndk/platforms/android-9/arch-x86/include/asm/statfs.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/string.h b/ndk/platforms/android-9/arch-x86/include/asm/string.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/string.h
rename to ndk/platforms/android-9/arch-x86/include/asm/string.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/string_32.h b/ndk/platforms/android-9/arch-x86/include/asm/string_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/string_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/string_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/swiotlb.h b/ndk/platforms/android-9/arch-x86/include/asm/swiotlb.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/swiotlb.h
rename to ndk/platforms/android-9/arch-x86/include/asm/swiotlb.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/system.h b/ndk/platforms/android-9/arch-x86/include/asm/system.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/system.h
rename to ndk/platforms/android-9/arch-x86/include/asm/system.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/system_32.h b/ndk/platforms/android-9/arch-x86/include/asm/system_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/system_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/system_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/termbits.h b/ndk/platforms/android-9/arch-x86/include/asm/termbits.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/termbits.h
rename to ndk/platforms/android-9/arch-x86/include/asm/termbits.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/termios.h b/ndk/platforms/android-9/arch-x86/include/asm/termios.h
similarity index 90%
rename from ndk/platforms/android-3/arch-x86/include/asm/termios.h
rename to ndk/platforms/android-9/arch-x86/include/asm/termios.h
index 01bdca4..6542c78 100644
--- a/ndk/platforms/android-3/arch-x86/include/asm/termios.h
+++ b/ndk/platforms/android-9/arch-x86/include/asm/termios.h
@@ -53,15 +53,15 @@
 #define N_PPP 3
 #define N_STRIP 4
 #define N_AX25 5
-#define N_X25 6
+#define N_X25 6  
 #define N_6PACK 7
-#define N_MASC 8
-#define N_R3964 9
-#define N_PROFIBUS_FDL 10
-#define N_IRDA 11
-#define N_SMSBLOCK 12
-#define N_HDLC 13
+#define N_MASC 8  
+#define N_R3964 9  
+#define N_PROFIBUS_FDL 10  
+#define N_IRDA 11  
+#define N_SMSBLOCK 12  
+#define N_HDLC 13  
 #define N_SYNC_PPP 14
-#define N_HCI 15
+#define N_HCI 15  
 
 #endif
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/thread_info.h b/ndk/platforms/android-9/arch-x86/include/asm/thread_info.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/thread_info.h
rename to ndk/platforms/android-9/arch-x86/include/asm/thread_info.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/thread_info_32.h b/ndk/platforms/android-9/arch-x86/include/asm/thread_info_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/thread_info_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/thread_info_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/tlbflush.h b/ndk/platforms/android-9/arch-x86/include/asm/tlbflush.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/tlbflush.h
rename to ndk/platforms/android-9/arch-x86/include/asm/tlbflush.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/tlbflush_32.h b/ndk/platforms/android-9/arch-x86/include/asm/tlbflush_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/tlbflush_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/tlbflush_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/tsc.h b/ndk/platforms/android-9/arch-x86/include/asm/tsc.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/tsc.h
rename to ndk/platforms/android-9/arch-x86/include/asm/tsc.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/types.h b/ndk/platforms/android-9/arch-x86/include/asm/types.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/types.h
rename to ndk/platforms/android-9/arch-x86/include/asm/types.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/uaccess.h b/ndk/platforms/android-9/arch-x86/include/asm/uaccess.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/uaccess.h
rename to ndk/platforms/android-9/arch-x86/include/asm/uaccess.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/uaccess_32.h b/ndk/platforms/android-9/arch-x86/include/asm/uaccess_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/uaccess_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/uaccess_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/unaligned.h b/ndk/platforms/android-9/arch-x86/include/asm/unaligned.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/unaligned.h
rename to ndk/platforms/android-9/arch-x86/include/asm/unaligned.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/unistd.h b/ndk/platforms/android-9/arch-x86/include/asm/unistd.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/unistd.h
rename to ndk/platforms/android-9/arch-x86/include/asm/unistd.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/unistd_32.h b/ndk/platforms/android-9/arch-x86/include/asm/unistd_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/unistd_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/unistd_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/user.h b/ndk/platforms/android-9/arch-x86/include/asm/user.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/user.h
rename to ndk/platforms/android-9/arch-x86/include/asm/user.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/user32.h b/ndk/platforms/android-9/arch-x86/include/asm/user32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/user32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/user32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/user_32.h b/ndk/platforms/android-9/arch-x86/include/asm/user_32.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/user_32.h
rename to ndk/platforms/android-9/arch-x86/include/asm/user_32.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/vm86.h b/ndk/platforms/android-9/arch-x86/include/asm/vm86.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/vm86.h
rename to ndk/platforms/android-9/arch-x86/include/asm/vm86.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/voyager.h b/ndk/platforms/android-9/arch-x86/include/asm/voyager.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/voyager.h
rename to ndk/platforms/android-9/arch-x86/include/asm/voyager.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/vsyscall.h b/ndk/platforms/android-9/arch-x86/include/asm/vsyscall.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/vsyscall.h
rename to ndk/platforms/android-9/arch-x86/include/asm/vsyscall.h
diff --git a/ndk/platforms/android-3/arch-x86/include/asm/xen/hypercall.h b/ndk/platforms/android-9/arch-x86/include/asm/xen/hypercall.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/asm/xen/hypercall.h
rename to ndk/platforms/android-9/arch-x86/include/asm/xen/hypercall.h
diff --git a/ndk/platforms/android-3/arch-x86/include/endian.h b/ndk/platforms/android-9/arch-x86/include/endian.h
similarity index 89%
rename from ndk/platforms/android-3/arch-x86/include/endian.h
rename to ndk/platforms/android-9/arch-x86/include/endian.h
index ad37919..4a70536 100644
--- a/ndk/platforms/android-3/arch-x86/include/endian.h
+++ b/ndk/platforms/android-9/arch-x86/include/endian.h
@@ -31,14 +31,14 @@
 
 #if defined(_KERNEL) && !defined(I386_CPU)
 #define	__swap32md(x) ({						\
-	u_int32_t __swap32md_x = (x);					\
+	uint32_t __swap32md_x = (x);					\
 									\
 	__asm ("bswap %1" : "+r" (__swap32md_x));			\
 	__swap32md_x;							\
 })
 #else
 #define	__swap32md(x) ({						\
-	u_int32_t __swap32md_x = (x);					\
+	uint32_t __swap32md_x = (x);					\
 									\
 	__asm ("rorw $8, %w1; rorl $16, %1; rorw $8, %w1" :		\
 	    "+r" (__swap32md_x));					\
@@ -47,13 +47,13 @@
 #endif	/* _KERNEL && !I386_CPU */
 
 #define	__swap64md(x) ({						\
-	u_int64_t __swap64md_x = (x);					\
+	uint64_t __swap64md_x = (x);					\
 									\
-	(u_int64_t)__swap32md(__swap64md_x >> 32) |			\
-	    (u_int64_t)__swap32md(__swap64md_x & 0xffffffff) << 32;	\
+	(uint64_t)__swap32md(__swap64md_x >> 32) |			\
+	    (uint64_t)__swap32md(__swap64md_x & 0xffffffff) << 32;	\
 })
 #define	__swap16md(x) ({						\
-	u_int16_t __swap16md_x = (x);					\
+	uint16_t __swap16md_x = (x);					\
 									\
 	__asm ("rorw $8, %w1" : "+r" (__swap16md_x));			\
 	__swap16md_x;							\
diff --git a/ndk/platforms/android-3/arch-x86/include/fenv.h b/ndk/platforms/android-9/arch-x86/include/fenv.h
similarity index 97%
rename from ndk/platforms/android-3/arch-x86/include/fenv.h
rename to ndk/platforms/android-9/arch-x86/include/fenv.h
index b124366..5fe64e2 100644
--- a/ndk/platforms/android-3/arch-x86/include/fenv.h
+++ b/ndk/platforms/android-9/arch-x86/include/fenv.h
@@ -102,7 +102,7 @@
 #define	__fnclex()		__asm __volatile("fnclex")
 #define	__fnstenv(__env)	__asm __volatile("fnstenv %0" : "=m" (*(__env)))
 #define	__fnstcw(__cw)		__asm __volatile("fnstcw %0" : "=m" (*(__cw)))
-#define	__fnstsw(__sw)		__asm __volatile("fnstsw %0" : "=am" (*(__sw)))
+#define	__fnstsw(__sw)		__asm __volatile("fnstsw %0" : "=a" (*(__sw)))
 #define	__fwait()		__asm __volatile("fwait")
 #define	__ldmxcsr(__csr)	__asm __volatile("ldmxcsr %0" : : "m" (__csr))
 #define	__stmxcsr(__csr)	__asm __volatile("stmxcsr %0" : "=m" (*(__csr)))
@@ -131,7 +131,8 @@
 static __inline int
 fegetexceptflag(fexcept_t *__flagp, int __excepts)
 {
-	int __mxcsr, __status;
+	int __mxcsr;
+	short __status;
 
 	__fnstsw(&__status);
 	if (__HAS_SSE())
@@ -148,7 +149,8 @@
 static __inline int
 fetestexcept(int __excepts)
 {
-	int __mxcsr, __status;
+	int __mxcsr;
+	short __status;
 
 	__fnstsw(&__status);
 	if (__HAS_SSE())
diff --git a/ndk/platforms/android-3/arch-x86/include/machine/_types.h b/ndk/platforms/android-9/arch-x86/include/machine/_types.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/machine/_types.h
rename to ndk/platforms/android-9/arch-x86/include/machine/_types.h
diff --git a/ndk/platforms/android-3/arch-x86/include/machine/asm.h b/ndk/platforms/android-9/arch-x86/include/machine/asm.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/machine/asm.h
rename to ndk/platforms/android-9/arch-x86/include/machine/asm.h
diff --git a/ndk/platforms/android-3/arch-x86/include/machine/cdefs.h b/ndk/platforms/android-9/arch-x86/include/machine/cdefs.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/machine/cdefs.h
rename to ndk/platforms/android-9/arch-x86/include/machine/cdefs.h
diff --git a/ndk/platforms/android-3/arch-x86/include/machine/exec.h b/ndk/platforms/android-9/arch-x86/include/machine/exec.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/machine/exec.h
rename to ndk/platforms/android-9/arch-x86/include/machine/exec.h
diff --git a/ndk/platforms/android-3/arch-x86/include/machine/ieee.h b/ndk/platforms/android-9/arch-x86/include/machine/ieee.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/machine/ieee.h
rename to ndk/platforms/android-9/arch-x86/include/machine/ieee.h
diff --git a/ndk/platforms/android-3/arch-x86/include/machine/internal_types.h b/ndk/platforms/android-9/arch-x86/include/machine/internal_types.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/machine/internal_types.h
rename to ndk/platforms/android-9/arch-x86/include/machine/internal_types.h
diff --git a/ndk/platforms/android-3/arch-x86/include/machine/kernel.h b/ndk/platforms/android-9/arch-x86/include/machine/kernel.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/machine/kernel.h
rename to ndk/platforms/android-9/arch-x86/include/machine/kernel.h
diff --git a/ndk/platforms/android-3/arch-x86/include/machine/limits.h b/ndk/platforms/android-9/arch-x86/include/machine/limits.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/machine/limits.h
rename to ndk/platforms/android-9/arch-x86/include/machine/limits.h
diff --git a/ndk/platforms/android-3/arch-x86/include/machine/setjmp.h b/ndk/platforms/android-9/arch-x86/include/machine/setjmp.h
similarity index 100%
rename from ndk/platforms/android-3/arch-x86/include/machine/setjmp.h
rename to ndk/platforms/android-9/arch-x86/include/machine/setjmp.h
diff --git a/ndk/platforms/android-9/arch-x86/include/sys/atomics.h b/ndk/platforms/android-9/arch-x86/include/sys/atomics.h
new file mode 100644
index 0000000..7aed3ae
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/include/sys/atomics.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _SYS_ATOMICS_H
+#define _SYS_ATOMICS_H
+
+#include <sys/cdefs.h>
+#include <sys/time.h>
+
+__BEGIN_DECLS
+
+static inline __attribute__((always_inline)) int
+__atomic_cmpxchg(int old, int _new, volatile int *ptr)
+{
+  return !__sync_bool_compare_and_swap (ptr, old, _new);
+}
+
+static inline __attribute__((always_inline)) int
+__atomic_swap(int _new, volatile int *ptr)
+{
+  return __sync_lock_test_and_set(ptr, _new);
+}
+
+static inline __attribute__((always_inline)) int
+__atomic_dec(volatile int *ptr)
+{
+  return __sync_fetch_and_sub (ptr, 1);
+}
+
+static inline __attribute__((always_inline)) int
+__atomic_inc(volatile int *ptr)
+{
+  return __sync_fetch_and_add (ptr, 1);
+}
+
+int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout);
+int __futex_wake(volatile void *ftx, int count);
+
+__END_DECLS
+
+#endif /* _SYS_ATOMICS_H */
diff --git a/ndk/platforms/android-9/arch-x86/lib/crtbegin_dynamic.o b/ndk/platforms/android-9/arch-x86/lib/crtbegin_dynamic.o
new file mode 100644
index 0000000..102fc37
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/crtbegin_dynamic.o
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/crtbegin_so.o b/ndk/platforms/android-9/arch-x86/lib/crtbegin_so.o
new file mode 100644
index 0000000..662d85a
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/crtbegin_so.o
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/crtbegin_static.o b/ndk/platforms/android-9/arch-x86/lib/crtbegin_static.o
new file mode 100644
index 0000000..102fc37
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/crtbegin_static.o
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/crtend_android.o b/ndk/platforms/android-9/arch-x86/lib/crtend_android.o
new file mode 100644
index 0000000..87716a0
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/crtend_android.o
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/crtend_so.o b/ndk/platforms/android-9/arch-x86/lib/crtend_so.o
new file mode 100644
index 0000000..4c4460f
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/crtend_so.o
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libEGL.so b/ndk/platforms/android-9/arch-x86/lib/libEGL.so
new file mode 100755
index 0000000..6a8277e
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libEGL.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libGLESv1_CM.so b/ndk/platforms/android-9/arch-x86/lib/libGLESv1_CM.so
new file mode 100755
index 0000000..d03d357
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libGLESv1_CM.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libGLESv2.so b/ndk/platforms/android-9/arch-x86/lib/libGLESv2.so
new file mode 100755
index 0000000..51d6b59
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libGLESv2.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libOpenSLES.so b/ndk/platforms/android-9/arch-x86/lib/libOpenSLES.so
new file mode 100755
index 0000000..110da00
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libOpenSLES.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libandroid.so b/ndk/platforms/android-9/arch-x86/lib/libandroid.so
new file mode 100755
index 0000000..e106436
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libandroid.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libc.a b/ndk/platforms/android-9/arch-x86/lib/libc.a
new file mode 100644
index 0000000..e47736f
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libc.a
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libc.so b/ndk/platforms/android-9/arch-x86/lib/libc.so
index ce06b7c..bf23ca5 100755
--- a/ndk/platforms/android-9/arch-x86/lib/libc.so
+++ b/ndk/platforms/android-9/arch-x86/lib/libc.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libdl.so b/ndk/platforms/android-9/arch-x86/lib/libdl.so
new file mode 100755
index 0000000..2c13187
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libdl.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libjnigraphics.so b/ndk/platforms/android-9/arch-x86/lib/libjnigraphics.so
new file mode 100755
index 0000000..c669957
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libjnigraphics.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/liblog.so b/ndk/platforms/android-9/arch-x86/lib/liblog.so
new file mode 100755
index 0000000..f28bf77
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/liblog.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libm.a b/ndk/platforms/android-9/arch-x86/lib/libm.a
new file mode 100644
index 0000000..092b2cc
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libm.a
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libm.so b/ndk/platforms/android-9/arch-x86/lib/libm.so
new file mode 100755
index 0000000..ce9ffea
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libm.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libstdc++.a b/ndk/platforms/android-9/arch-x86/lib/libstdc++.a
new file mode 100644
index 0000000..04788e0
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libstdc++.a
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libstdc++.so b/ndk/platforms/android-9/arch-x86/lib/libstdc++.so
index 3742660..4ddac65 100755
--- a/ndk/platforms/android-9/arch-x86/lib/libstdc++.so
+++ b/ndk/platforms/android-9/arch-x86/lib/libstdc++.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libthread_db.a b/ndk/platforms/android-9/arch-x86/lib/libthread_db.a
new file mode 100644
index 0000000..de2e34d
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libthread_db.a
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libz.a b/ndk/platforms/android-9/arch-x86/lib/libz.a
new file mode 100644
index 0000000..1df2ec3
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libz.a
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libz.so b/ndk/platforms/android-9/arch-x86/lib/libz.so
new file mode 100755
index 0000000..9155cb9
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib/libz.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/symbols/libEGL.so.txt b/ndk/platforms/android-9/arch-x86/symbols/libEGL.so.txt
new file mode 100644
index 0000000..88d4105
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/symbols/libEGL.so.txt
@@ -0,0 +1,44 @@
+eglBindAPI
+eglBindTexImage
+eglChooseConfig
+eglClientWaitSyncKHR
+eglCopyBuffers
+eglCreateContext
+eglCreateImageKHR
+eglCreatePbufferFromClientBuffer
+eglCreatePbufferSurface
+eglCreatePixmapSurface
+eglCreateSyncKHR
+eglCreateWindowSurface
+eglDestroyContext
+eglDestroyImageKHR
+eglDestroySurface
+eglDestroySyncKHR
+eglGetConfigAttrib
+eglGetConfigs
+eglGetCurrentContext
+eglGetCurrentDisplay
+eglGetCurrentSurface
+eglGetDisplay
+eglGetError
+eglGetProcAddress
+eglInitialize
+eglLockSurfaceKHR
+eglMakeCurrent
+eglQueryAPI
+eglQueryContext
+eglQueryString
+eglQuerySurface
+eglReleaseTexImage
+eglReleaseThread
+eglSetSwapRectangleANDROID
+eglSurfaceAttrib
+eglSwapBuffers
+eglSwapInterval
+eglTerminate
+eglUnlockSurfaceKHR
+eglWaitClient
+eglWaitGL
+eglWaitNative
+__FINI_ARRAY__
+__INIT_ARRAY__
diff --git a/ndk/platforms/android-9/arch-x86/symbols/libGLESv1_CM.so.txt b/ndk/platforms/android-9/arch-x86/symbols/libGLESv1_CM.so.txt
new file mode 100644
index 0000000..7c53cfa
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/symbols/libGLESv1_CM.so.txt
@@ -0,0 +1,280 @@
+glActiveTexture
+glAlphaFunc
+glAlphaFuncx
+glAlphaFuncxOES
+glBindBuffer
+glBindFramebufferOES
+glBindRenderbufferOES
+glBindTexture
+glBindVertexArrayOES
+glBlendEquationOES
+glBlendEquationSeparateOES
+glBlendFunc
+glBlendFuncSeparateOES
+glBufferData
+glBufferSubData
+glCheckFramebufferStatusOES
+glClear
+glClearColor
+glClearColorx
+glClearColorxOES
+glClearDepthf
+glClearDepthfOES
+glClearDepthx
+glClearDepthxOES
+glClearStencil
+glClientActiveTexture
+glClipPlanef
+glClipPlanefIMG
+glClipPlanefOES
+glClipPlanex
+glClipPlanexIMG
+glClipPlanexOES
+glColor4f
+glColor4ub
+glColor4x
+glColor4xOES
+glColorMask
+glColorPointer
+glColorPointerBounds
+glCompressedTexImage2D
+glCompressedTexSubImage2D
+glCopyTexImage2D
+glCopyTexSubImage2D
+glCullFace
+glCurrentPaletteMatrixOES
+glDeleteBuffers
+glDeleteFencesNV
+glDeleteFramebuffersOES
+glDeleteRenderbuffersOES
+glDeleteTextures
+glDeleteVertexArraysOES
+glDepthFunc
+glDepthMask
+glDepthRangef
+glDepthRangefOES
+glDepthRangex
+glDepthRangexOES
+glDisable
+glDisableClientState
+glDisableDriverControlQCOM
+glDiscardFramebufferEXT
+glDrawArrays
+glDrawElements
+glDrawTexfOES
+glDrawTexfvOES
+glDrawTexiOES
+glDrawTexivOES
+glDrawTexsOES
+glDrawTexsvOES
+glDrawTexxOES
+glDrawTexxvOES
+glEGLImageTargetRenderbufferStorageOES
+glEGLImageTargetTexture2DOES
+glEnable
+glEnableClientState
+glEnableDriverControlQCOM
+glEndTilingQCOM
+glExtGetBufferPointervQCOM
+glExtGetBuffersQCOM
+glExtGetFramebuffersQCOM
+glExtGetProgramBinarySourceQCOM
+glExtGetProgramsQCOM
+glExtGetRenderbuffersQCOM
+glExtGetShadersQCOM
+glExtGetTexLevelParameterivQCOM
+glExtGetTexSubImageQCOM
+glExtGetTexturesQCOM
+glExtIsProgramBinaryQCOM
+glExtTexObjectStateOverrideiQCOM
+glFinish
+glFinishFenceNV
+glFlush
+glFogf
+glFogfv
+glFogx
+glFogxOES
+glFogxv
+glFogxvOES
+glFramebufferRenderbufferOES
+glFramebufferTexture2DMultisampleIMG
+glFramebufferTexture2DOES
+glFrontFace
+glFrustumf
+glFrustumfOES
+glFrustumx
+glFrustumxOES
+glGenBuffers
+glGenFencesNV
+glGenFramebuffersOES
+glGenRenderbuffersOES
+glGenTextures
+glGenVertexArraysOES
+glGenerateMipmapOES
+glGetBooleanv
+glGetBufferParameteriv
+glGetBufferPointervOES
+glGetClipPlanef
+glGetClipPlanefOES
+glGetClipPlanex
+glGetClipPlanexOES
+glGetDriverControlStringQCOM
+glGetDriverControlsQCOM
+glGetError
+glGetFenceivNV
+glGetFixedv
+glGetFixedvOES
+glGetFloatv
+glGetFramebufferAttachmentParameterivOES
+glGetIntegerv
+glGetLightfv
+glGetLightxv
+glGetLightxvOES
+glGetMaterialfv
+glGetMaterialxv
+glGetMaterialxvOES
+glGetPointerv
+glGetRenderbufferParameterivOES
+glGetString
+glGetTexEnvfv
+glGetTexEnviv
+glGetTexEnvxv
+glGetTexEnvxvOES
+glGetTexGenfvOES
+glGetTexGenivOES
+glGetTexGenxvOES
+glGetTexParameterfv
+glGetTexParameteriv
+glGetTexParameterxv
+glGetTexParameterxvOES
+glHint
+glIsBuffer
+glIsEnabled
+glIsFenceNV
+glIsFramebufferOES
+glIsRenderbufferOES
+glIsTexture
+glIsVertexArrayOES
+glLightModelf
+glLightModelfv
+glLightModelx
+glLightModelxOES
+glLightModelxv
+glLightModelxvOES
+glLightf
+glLightfv
+glLightx
+glLightxOES
+glLightxv
+glLightxvOES
+glLineWidth
+glLineWidthx
+glLineWidthxOES
+glLoadIdentity
+glLoadMatrixf
+glLoadMatrixx
+glLoadMatrixxOES
+glLoadPaletteFromModelViewMatrixOES
+glLogicOp
+glMapBufferOES
+glMaterialf
+glMaterialfv
+glMaterialx
+glMaterialxOES
+glMaterialxv
+glMaterialxvOES
+glMatrixIndexPointerOES
+glMatrixIndexPointerOESBounds
+glMatrixMode
+glMultMatrixf
+glMultMatrixx
+glMultMatrixxOES
+glMultiDrawArraysEXT
+glMultiDrawElementsEXT
+glMultiTexCoord4f
+glMultiTexCoord4x
+glMultiTexCoord4xOES
+glNormal3f
+glNormal3x
+glNormal3xOES
+glNormalPointer
+glNormalPointerBounds
+glOrthof
+glOrthofOES
+glOrthox
+glOrthoxOES
+glPixelStorei
+glPointParameterf
+glPointParameterfv
+glPointParameterx
+glPointParameterxOES
+glPointParameterxv
+glPointParameterxvOES
+glPointSize
+glPointSizePointerOES
+glPointSizePointerOESBounds
+glPointSizex
+glPointSizexOES
+glPolygonOffset
+glPolygonOffsetx
+glPolygonOffsetxOES
+glPopMatrix
+glPushMatrix
+glQueryMatrixxOES
+glReadPixels
+glRenderbufferStorageMultisampleIMG
+glRenderbufferStorageOES
+glRotatef
+glRotatex
+glRotatexOES
+glSampleCoverage
+glSampleCoveragex
+glSampleCoveragexOES
+glScalef
+glScalex
+glScalexOES
+glScissor
+glSetFenceNV
+glShadeModel
+glStartTilingQCOM
+glStencilFunc
+glStencilMask
+glStencilOp
+glTestFenceNV
+glTexCoordPointer
+glTexCoordPointerBounds
+glTexEnvf
+glTexEnvfv
+glTexEnvi
+glTexEnviv
+glTexEnvx
+glTexEnvxOES
+glTexEnvxv
+glTexEnvxvOES
+glTexGenfOES
+glTexGenfvOES
+glTexGeniOES
+glTexGenivOES
+glTexGenxOES
+glTexGenxvOES
+glTexImage2D
+glTexParameterf
+glTexParameterfv
+glTexParameteri
+glTexParameteriv
+glTexParameterx
+glTexParameterxOES
+glTexParameterxv
+glTexParameterxvOES
+glTexSubImage2D
+glTranslatef
+glTranslatex
+glTranslatexOES
+glUnmapBufferOES
+glVertexPointer
+glVertexPointerBounds
+glViewport
+glWeightPointerOES
+glWeightPointerOESBounds
+__FINI_ARRAY__
+__INIT_ARRAY__
diff --git a/ndk/platforms/android-9/arch-x86/symbols/libGLESv2.so.txt b/ndk/platforms/android-9/arch-x86/symbols/libGLESv2.so.txt
new file mode 100644
index 0000000..d86b82c
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/symbols/libGLESv2.so.txt
@@ -0,0 +1,204 @@
+glActiveTexture
+glAttachShader
+glBeginPerfMonitorAMD
+glBindAttribLocation
+glBindBuffer
+glBindFramebuffer
+glBindRenderbuffer
+glBindTexture
+glBindVertexArrayOES
+glBlendColor
+glBlendEquation
+glBlendEquationSeparate
+glBlendFunc
+glBlendFuncSeparate
+glBufferData
+glBufferSubData
+glCheckFramebufferStatus
+glClear
+glClearColor
+glClearDepthf
+glClearStencil
+glColorMask
+glCompileShader
+glCompressedTexImage2D
+glCompressedTexImage3DOES
+glCompressedTexSubImage2D
+glCompressedTexSubImage3DOES
+glCopyTexImage2D
+glCopyTexSubImage2D
+glCopyTexSubImage3DOES
+glCoverageMaskNV
+glCoverageOperationNV
+glCreateProgram
+glCreateShader
+glCullFace
+glDeleteBuffers
+glDeleteFencesNV
+glDeleteFramebuffers
+glDeletePerfMonitorsAMD
+glDeleteProgram
+glDeleteRenderbuffers
+glDeleteShader
+glDeleteTextures
+glDeleteVertexArraysOES
+glDepthFunc
+glDepthMask
+glDepthRangef
+glDetachShader
+glDisable
+glDisableDriverControlQCOM
+glDisableVertexAttribArray
+glDiscardFramebufferEXT
+glDrawArrays
+glDrawElements
+glEGLImageTargetRenderbufferStorageOES
+glEGLImageTargetTexture2DOES
+glEnable
+glEnableDriverControlQCOM
+glEnableVertexAttribArray
+glEndPerfMonitorAMD
+glEndTilingQCOM
+glExtGetBufferPointervQCOM
+glExtGetBuffersQCOM
+glExtGetFramebuffersQCOM
+glExtGetProgramBinarySourceQCOM
+glExtGetProgramsQCOM
+glExtGetRenderbuffersQCOM
+glExtGetShadersQCOM
+glExtGetTexLevelParameterivQCOM
+glExtGetTexSubImageQCOM
+glExtGetTexturesQCOM
+glExtIsProgramBinaryQCOM
+glExtTexObjectStateOverrideiQCOM
+glFinish
+glFinishFenceNV
+glFlush
+glFramebufferRenderbuffer
+glFramebufferTexture2D
+glFramebufferTexture2DMultisampleIMG
+glFramebufferTexture3DOES
+glFrontFace
+glGenBuffers
+glGenFencesNV
+glGenFramebuffers
+glGenPerfMonitorsAMD
+glGenRenderbuffers
+glGenTextures
+glGenVertexArraysOES
+glGenerateMipmap
+glGetActiveAttrib
+glGetActiveUniform
+glGetAttachedShaders
+glGetAttribLocation
+glGetBooleanv
+glGetBufferParameteriv
+glGetBufferPointervOES
+glGetDriverControlStringQCOM
+glGetDriverControlsQCOM
+glGetError
+glGetFenceivNV
+glGetFloatv
+glGetFramebufferAttachmentParameteriv
+glGetIntegerv
+glGetPerfMonitorCounterDataAMD
+glGetPerfMonitorCounterInfoAMD
+glGetPerfMonitorCounterStringAMD
+glGetPerfMonitorCountersAMD
+glGetPerfMonitorGroupStringAMD
+glGetPerfMonitorGroupsAMD
+glGetProgramBinaryOES
+glGetProgramInfoLog
+glGetProgramiv
+glGetRenderbufferParameteriv
+glGetShaderInfoLog
+glGetShaderPrecisionFormat
+glGetShaderSource
+glGetShaderiv
+glGetString
+glGetTexParameterfv
+glGetTexParameteriv
+glGetUniformLocation
+glGetUniformfv
+glGetUniformiv
+glGetVertexAttribPointerv
+glGetVertexAttribfv
+glGetVertexAttribiv
+glHint
+glIsBuffer
+glIsEnabled
+glIsFenceNV
+glIsFramebuffer
+glIsProgram
+glIsRenderbuffer
+glIsShader
+glIsTexture
+glIsVertexArrayOES
+glLineWidth
+glLinkProgram
+glMapBufferOES
+glMultiDrawArraysEXT
+glMultiDrawElementsEXT
+glPixelStorei
+glPolygonOffset
+glProgramBinaryOES
+glReadPixels
+glReleaseShaderCompiler
+glRenderbufferStorage
+glRenderbufferStorageMultisampleIMG
+glSampleCoverage
+glScissor
+glSelectPerfMonitorCountersAMD
+glSetFenceNV
+glShaderBinary
+glShaderSource
+glStartTilingQCOM
+glStencilFunc
+glStencilFuncSeparate
+glStencilMask
+glStencilMaskSeparate
+glStencilOp
+glStencilOpSeparate
+glTestFenceNV
+glTexImage2D
+glTexImage3DOES
+glTexParameterf
+glTexParameterfv
+glTexParameteri
+glTexParameteriv
+glTexSubImage2D
+glTexSubImage3DOES
+glUniform1f
+glUniform1fv
+glUniform1i
+glUniform1iv
+glUniform2f
+glUniform2fv
+glUniform2i
+glUniform2iv
+glUniform3f
+glUniform3fv
+glUniform3i
+glUniform3iv
+glUniform4f
+glUniform4fv
+glUniform4i
+glUniform4iv
+glUniformMatrix2fv
+glUniformMatrix3fv
+glUniformMatrix4fv
+glUnmapBufferOES
+glUseProgram
+glValidateProgram
+glVertexAttrib1f
+glVertexAttrib1fv
+glVertexAttrib2f
+glVertexAttrib2fv
+glVertexAttrib3f
+glVertexAttrib3fv
+glVertexAttrib4f
+glVertexAttrib4fv
+glVertexAttribPointer
+glViewport
+__FINI_ARRAY__
+__INIT_ARRAY__
diff --git a/ndk/platforms/android-9/arch-x86/symbols/libOpenSLES.so.txt b/ndk/platforms/android-9/arch-x86/symbols/libOpenSLES.so.txt
new file mode 100644
index 0000000..b42d1ee
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/symbols/libOpenSLES.so.txt
@@ -0,0 +1,52 @@
+slCreateEngine
+slQueryNumSupportedEngineInterfaces
+slQuerySupportedEngineInterfaces
+SL_IID_3DCOMMIT
+SL_IID_3DDOPPLER
+SL_IID_3DGROUPING
+SL_IID_3DLOCATION
+SL_IID_3DMACROSCOPIC
+SL_IID_3DSOURCE
+SL_IID_ANDROIDCONFIGURATION
+SL_IID_ANDROIDEFFECT
+SL_IID_ANDROIDEFFECTCAPABILITIES
+SL_IID_ANDROIDEFFECTSEND
+SL_IID_ANDROIDSIMPLEBUFFERQUEUE
+SL_IID_AUDIODECODERCAPABILITIES
+SL_IID_AUDIOENCODER
+SL_IID_AUDIOENCODERCAPABILITIES
+SL_IID_AUDIOIODEVICECAPABILITIES
+SL_IID_BASSBOOST
+SL_IID_BUFFERQUEUE
+SL_IID_DEVICEVOLUME
+SL_IID_DYNAMICINTERFACEMANAGEMENT
+SL_IID_DYNAMICSOURCE
+SL_IID_EFFECTSEND
+SL_IID_ENGINE
+SL_IID_ENGINECAPABILITIES
+SL_IID_ENVIRONMENTALREVERB
+SL_IID_EQUALIZER
+SL_IID_LED
+SL_IID_METADATAEXTRACTION
+SL_IID_METADATATRAVERSAL
+SL_IID_MIDIMESSAGE
+SL_IID_MIDIMUTESOLO
+SL_IID_MIDITEMPO
+SL_IID_MIDITIME
+SL_IID_MUTESOLO
+SL_IID_NULL
+SL_IID_OBJECT
+SL_IID_OUTPUTMIX
+SL_IID_PITCH
+SL_IID_PLAY
+SL_IID_PLAYBACKRATE
+SL_IID_PREFETCHSTATUS
+SL_IID_PRESETREVERB
+SL_IID_RATEPITCH
+SL_IID_RECORD
+SL_IID_SEEK
+SL_IID_THREADSYNC
+SL_IID_VIBRA
+SL_IID_VIRTUALIZER
+SL_IID_VISUALIZATION
+SL_IID_VOLUME
diff --git a/ndk/platforms/android-9/arch-x86/symbols/libandroid.so.txt b/ndk/platforms/android-9/arch-x86/symbols/libandroid.so.txt
new file mode 100644
index 0000000..80178a3
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/symbols/libandroid.so.txt
@@ -0,0 +1,150 @@
+AAssetDir_close
+AAssetDir_getNextFileName
+AAssetDir_rewind
+AAssetManager_fromJava
+AAssetManager_open
+AAssetManager_openDir
+AAsset_close
+AAsset_getBuffer
+AAsset_getLength
+AAsset_getRemainingLength
+AAsset_isAllocated
+AAsset_openFileDescriptor
+AAsset_read
+AAsset_seek
+AConfiguration_copy
+AConfiguration_delete
+AConfiguration_diff
+AConfiguration_fromAssetManager
+AConfiguration_getCountry
+AConfiguration_getDensity
+AConfiguration_getKeyboard
+AConfiguration_getKeysHidden
+AConfiguration_getLanguage
+AConfiguration_getMcc
+AConfiguration_getMnc
+AConfiguration_getNavHidden
+AConfiguration_getNavigation
+AConfiguration_getOrientation
+AConfiguration_getScreenLong
+AConfiguration_getScreenSize
+AConfiguration_getSdkVersion
+AConfiguration_getTouchscreen
+AConfiguration_getUiModeNight
+AConfiguration_getUiModeType
+AConfiguration_isBetterThan
+AConfiguration_match
+AConfiguration_new
+AConfiguration_setCountry
+AConfiguration_setDensity
+AConfiguration_setKeyboard
+AConfiguration_setKeysHidden
+AConfiguration_setLanguage
+AConfiguration_setMcc
+AConfiguration_setMnc
+AConfiguration_setNavHidden
+AConfiguration_setNavigation
+AConfiguration_setOrientation
+AConfiguration_setScreenLong
+AConfiguration_setScreenSize
+AConfiguration_setSdkVersion
+AConfiguration_setTouchscreen
+AConfiguration_setUiModeNight
+AConfiguration_setUiModeType
+AInputEvent_getDeviceId
+AInputEvent_getSource
+AInputEvent_getType
+AInputQueue_attachLooper
+AInputQueue_detachLooper
+AInputQueue_finishEvent
+AInputQueue_getEvent
+AInputQueue_hasEvents
+AInputQueue_preDispatchEvent
+AKeyEvent_getAction
+AKeyEvent_getDownTime
+AKeyEvent_getEventTime
+AKeyEvent_getFlags
+AKeyEvent_getKeyCode
+AKeyEvent_getMetaState
+AKeyEvent_getRepeatCount
+AKeyEvent_getScanCode
+ALooper_acquire
+ALooper_addFd
+ALooper_forThread
+ALooper_pollAll
+ALooper_pollOnce
+ALooper_prepare
+ALooper_release
+ALooper_removeFd
+ALooper_wake
+AMotionEvent_getAction
+AMotionEvent_getDownTime
+AMotionEvent_getEdgeFlags
+AMotionEvent_getEventTime
+AMotionEvent_getFlags
+AMotionEvent_getHistoricalEventTime
+AMotionEvent_getHistoricalPressure
+AMotionEvent_getHistoricalSize
+AMotionEvent_getHistoricalX
+AMotionEvent_getHistoricalY
+AMotionEvent_getHistorySize
+AMotionEvent_getMetaState
+AMotionEvent_getOrientation
+AMotionEvent_getPointerCount
+AMotionEvent_getPointerId
+AMotionEvent_getPressure
+AMotionEvent_getRawX
+AMotionEvent_getRawY
+AMotionEvent_getSize
+AMotionEvent_getToolMajor
+AMotionEvent_getToolMinor
+AMotionEvent_getTouchMajor
+AMotionEvent_getTouchMinor
+AMotionEvent_getX
+AMotionEvent_getXOffset
+AMotionEvent_getXPrecision
+AMotionEvent_getY
+AMotionEvent_getYOffset
+AMotionEvent_getYPrecision
+ANativeActivity_finish
+ANativeActivity_hideSoftInput
+ANativeActivity_setWindowFlags
+ANativeActivity_setWindowFormat
+ANativeActivity_showSoftInput
+ANativeWindow_acquire
+ANativeWindow_fromSurface
+ANativeWindow_getFormat
+ANativeWindow_getHeight
+ANativeWindow_getWidth
+ANativeWindow_lock
+ANativeWindow_release
+ANativeWindow_setBuffersGeometry
+ANativeWindow_unlockAndPost
+AObbInfo_delete
+AObbInfo_getFlags
+AObbInfo_getPackageName
+AObbInfo_getVersion
+AObbScanner_getObbInfo
+ASensorEventQueue_disableSensor
+ASensorEventQueue_enableSensor
+ASensorEventQueue_getEvents
+ASensorEventQueue_hasEvents
+ASensorEventQueue_setEventRate
+ASensorManager_createEventQueue
+ASensorManager_destroyEventQueue
+ASensorManager_getDefaultSensor
+ASensorManager_getInstance
+ASensorManager_getSensorList
+ASensor_getMinDelay
+ASensor_getName
+ASensor_getResolution
+ASensor_getType
+ASensor_getVendor
+AStorageManager_delete
+AStorageManager_getMountedObbPath
+AStorageManager_isObbMounted
+AStorageManager_mountObb
+AStorageManager_new
+AStorageManager_unmountObb
+__FINI_ARRAY__
+__INIT_ARRAY__
diff --git a/ndk/platforms/android-9/arch-x86/symbols/libc.so.txt b/ndk/platforms/android-9/arch-x86/symbols/libc.so.txt
new file mode 100644
index 0000000..39d905e
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/symbols/libc.so.txt
@@ -0,0 +1,992 @@
+MD5_Final
+MD5_Init
+MD5_Update
+SHA1Final
+SHA1Init
+SHA1Transform
+SHA1Update
+__arc4_getbyte
+__assert
+__assert2
+__atexit_register_cleanup
+__b64_ntop
+__b64_pton
+__bionic_atfork_run_child
+__bionic_atfork_run_parent
+__bionic_atfork_run_prepare
+__brk
+__cxa_atexit
+__cxa_finalize
+__divdi3
+__dn_comp
+__dn_count_labels
+__dn_skipname
+__dorand48
+__errno
+__evAddTime
+__evCmpTime
+__evConsIovec
+__evConsTime
+__evNowTime
+__evSubTime
+__evTimeSpec
+__evTimeVal
+__evUTCTime
+__fcntl
+__fcntl64
+__findenv
+__fork
+__fp_nquery
+__fp_query
+__fstatfs64
+__futex_syscall3
+__futex_syscall4
+__futex_wait
+__futex_wait_ex
+__futex_wake
+__futex_wake_ex
+__get_h_errno
+__get_res_cache
+__get_sp
+__get_stack_base
+__get_thread
+__get_tls
+__getcpu
+__getcwd
+__getpriority
+__hostalias
+__init_tls
+__ioctl
+__libc_android_log_assert
+__libc_android_log_print
+__libc_android_log_vprint
+__libc_fini
+__libc_init
+__libc_init_common
+__libc_preinit
+__llseek
+__loc_aton
+__loc_ntoa
+__mmap2
+__moddi3
+__ns_format_ttl
+__ns_get16
+__ns_get32
+__ns_initparse
+__ns_makecanon
+__ns_msg_getflag
+__ns_name_compress
+__ns_name_ntol
+__ns_name_ntop
+__ns_name_pack
+__ns_name_pton
+__ns_name_rollback
+__ns_name_skip
+__ns_name_uncompress
+__ns_name_unpack
+__ns_parserr
+__ns_put16
+__ns_put32
+__ns_samename
+__ns_skiprr
+__ns_sprintrr
+__ns_sprintrrf
+__open
+__openat
+__p_cdname
+__p_cdnname
+__p_class
+__p_fqname
+__p_fqnname
+__p_option
+__p_query
+__p_rcode
+__p_secstodate
+__p_section
+__p_sockun
+__p_time
+__p_type
+__popcountsi2
+__pthread_cleanup_pop
+__pthread_cleanup_push
+__pthread_clone
+__pthread_cond_timedwait
+__pthread_cond_timedwait_relative
+__ptrace
+__putlong
+__putshort
+__reboot
+__res_close
+__res_dnok
+__res_get_nibblesuffix
+__res_get_nibblesuffix2
+__res_get_state
+__res_get_static
+__res_getservers
+__res_hnok
+__res_hostalias
+__res_isourserver
+__res_mailok
+__res_nameinquery
+__res_nametoclass
+__res_nametotype
+__res_nclose
+__res_ndestroy
+__res_ninit
+__res_nmkquery
+__res_nopt
+__res_nquery
+__res_nquerydomain
+__res_nsearch
+__res_nsend
+__res_opt
+__res_ownok
+__res_pquery
+__res_put_state
+__res_queriesmatch
+__res_querydomain
+__res_randomid
+__res_send
+__res_send_setqhook
+__res_send_setrhook
+__res_setservers
+__res_vinit
+__rt_sigaction
+__rt_sigprocmask
+__rt_sigtimedwait
+__sched_cpualloc
+__sched_cpucount
+__sched_cpufree
+__sched_getaffinity
+__sclose
+__set_errno
+__set_thread_area
+__set_tls
+__setresuid
+__setreuid
+__setuid
+__sflags
+__sflush
+__sfp
+__sigsuspend
+__sinit
+__smakebuf
+__sread
+__srefill
+__srget
+__sseek
+__stack_chk_fail
+__statfs64
+__swbuf
+__swhatbuf
+__swrite
+__swsetup
+__sym_ntop
+__sym_ntos
+__sym_ston
+__sys_clone
+__syslog
+__system_properties_init
+__system_property_find
+__system_property_find_nth
+__system_property_get
+__system_property_read
+__system_property_wait
+__thread_entry
+__timer_create
+__timer_delete
+__timer_getoverrun
+__timer_gettime
+__timer_settime
+__udivdi3
+__umoddi3
+__wait4
+__waitid
+_cleanup
+_exit
+_exit_thread
+_exit_with_stack_teardown
+_fwalk
+_getlong
+_getshort
+_init_thread
+_longjmp
+_setjmp
+_thread_created_hook
+_waitpid
+abort
+accept
+access
+acct
+alarm
+alphasort
+arc4random
+arc4random_addrandom
+arc4random_buf
+arc4random_stir
+arc4random_uniform
+asctime
+asctime64
+asctime64_r
+asctime_r
+asprintf
+atexit
+atoi
+atol
+atoll
+basename
+basename_r
+bcopy
+bind
+bindresvport
+brk
+bsd_signal
+bsearch
+btowc
+bzero
+calloc
+capget
+capset
+chdir
+chmod
+chown
+chroot
+clearenv
+clearerr
+clock
+clock_getres
+clock_gettime
+clock_nanosleep
+clock_settime
+close
+closedir
+closelog
+closelog_r
+connect
+cpuacct_add
+creat
+ctime
+ctime64
+ctime64_r
+ctime_r
+daemon
+delete_module
+difftime
+dirfd
+dirname
+dirname_r
+div
+dlcalloc
+dlfree
+dlindependent_calloc
+dlindependent_comalloc
+dlmallinfo
+dlmalloc
+dlmalloc_footprint
+dlmalloc_max_footprint
+dlmalloc_stats
+dlmalloc_trim
+dlmalloc_usable_size
+dlmalloc_walk_free_pages
+dlmalloc_walk_heap
+dlmallopt
+dlmemalign
+dlpvalloc
+dlrealloc
+dlvalloc
+dn_expand
+drand48
+dup
+dup2
+endpwent
+endservent
+endusershell
+endutent
+epoll_create
+epoll_ctl
+epoll_wait
+erand48
+err
+errx
+ether_aton
+ether_aton_r
+ether_ntoa
+ether_ntoa_r
+eventfd
+eventfd_read
+eventfd_write
+execl
+execle
+execlp
+execv
+execve
+execvp
+exit
+fchdir
+fchmod
+fchmodat
+fchown
+fchownat
+fclose
+fcntl
+fdatasync
+fdopen
+fdopendir
+fdprintf
+feof
+ferror
+fflush
+fgetc
+fgetln
+fgetpos
+fgets
+fgetwc
+fgetws
+fileno
+flock
+flockfile
+fnmatch
+fopen
+fork
+fpathconf
+fprintf
+fpurge
+fputc
+fputs
+fputwc
+fputws
+fread
+free
+freeaddrinfo
+freedtoa
+freopen
+fscanf
+fseek
+fseeko
+fsetpos
+fstat
+fstatat
+fstatfs
+fsync
+ftell
+ftello
+ftime
+ftok
+ftruncate
+ftruncate64
+ftrylockfile
+fts_children
+fts_close
+fts_open
+fts_read
+fts_set
+funlockfile
+funopen
+futex
+fwide
+fwprintf
+fwrite
+fwscanf
+gai_strerror
+get_malloc_leak_info
+getaddrinfo
+getc
+getc_unlocked
+getchar
+getchar_unlocked
+getcwd
+getdents
+getdtablesize
+getegid
+getenv
+geteuid
+getgid
+getgrgid
+getgrnam
+getgrouplist
+getgroups
+gethostbyaddr
+gethostbyname
+gethostbyname2
+gethostbyname_r
+gethostent
+gethostname
+getitimer
+getlogin
+getmntent
+getnameinfo
+getnetbyaddr
+getnetbyname
+getopt
+getopt_long
+getopt_long_only
+getpeername
+getpgid
+getpgrp
+getpid
+getppid
+getpriority
+getprotobyname
+getprotobynumber
+getpt
+getpwnam
+getpwuid
+getresgid
+getresuid
+getrlimit
+getrusage
+gets
+getservbyname
+getservbyport
+getservent
+getservent_r
+getsockname
+getsockopt
+gettid
+gettimeofday
+getuid
+getusershell
+getutent
+getwc
+getwchar
+gmtime
+gmtime64
+gmtime64_r
+gmtime_r
+herror
+hstrerror
+if_indextoname
+if_nametoindex
+index
+inet_addr
+inet_aton
+inet_nsap_addr
+inet_nsap_ntoa
+inet_ntoa
+inet_ntop
+inet_pton
+init_module
+initgroups
+inotify_add_watch
+inotify_init
+inotify_rm_watch
+ioctl
+ioprio_get
+ioprio_set
+isalnum
+isalpha
+isascii
+isatty
+isblank
+iscntrl
+isdigit
+isgraph
+islower
+isprint
+ispunct
+issetugid
+isspace
+isupper
+iswalnum
+iswalpha
+iswcntrl
+iswctype
+iswdigit
+iswgraph
+iswlower
+iswprint
+iswpunct
+iswspace
+iswupper
+iswxdigit
+isxdigit
+jrand48
+kill
+killpg
+klogctl
+lchown
+ldexp
+ldiv
+link
+listen
+lldiv
+localtime
+localtime64
+localtime64_r
+localtime_r
+longjmp
+longjmperror
+lrand48
+lseek
+lseek64
+lstat
+madvise
+mallinfo
+malloc
+malloc_debug_init
+mbrlen
+mbrtowc
+mbsinit
+mbsrtowcs
+mbstowcs
+memalign
+memccpy
+memchr
+memcmp
+memcpy
+memmem
+memmove
+memrchr
+memset
+memswap
+mincore
+mkdir
+mkdirat
+mkdtemp
+mknod
+mkstemp
+mkstemps
+mktemp
+mktime
+mktime64
+mlock
+mmap
+mount
+mprotect
+mrand48
+mremap
+msync
+munlock
+munmap
+nanosleep
+nice
+nrand48
+nsdispatch
+open
+openat
+opendir
+openlog
+openlog_r
+pathconf
+pause
+pclose
+perror
+pipe
+pipe2
+poll
+popen
+posix2time
+prctl
+pread
+pread64
+printf
+pselect
+pthread_atfork
+pthread_attr_destroy
+pthread_attr_getdetachstate
+pthread_attr_getguardsize
+pthread_attr_getschedparam
+pthread_attr_getschedpolicy
+pthread_attr_getscope
+pthread_attr_getstack
+pthread_attr_getstackaddr
+pthread_attr_getstacksize
+pthread_attr_init
+pthread_attr_setdetachstate
+pthread_attr_setguardsize
+pthread_attr_setschedparam
+pthread_attr_setschedpolicy
+pthread_attr_setscope
+pthread_attr_setstack
+pthread_attr_setstackaddr
+pthread_attr_setstacksize
+pthread_cond_broadcast
+pthread_cond_destroy
+pthread_cond_init
+pthread_cond_signal
+pthread_cond_timedwait
+pthread_cond_timedwait_monotonic
+pthread_cond_timedwait_monotonic_np
+pthread_cond_timedwait_relative_np
+pthread_cond_timeout_np
+pthread_cond_wait
+pthread_condattr_destroy
+pthread_condattr_getpshared
+pthread_condattr_init
+pthread_condattr_setpshared
+pthread_create
+pthread_detach
+pthread_equal
+pthread_exit
+pthread_getattr_np
+pthread_getcpuclockid
+pthread_getschedparam
+pthread_getspecific
+pthread_join
+pthread_key_create
+pthread_key_delete
+pthread_kill
+pthread_mutex_destroy
+pthread_mutex_init
+pthread_mutex_lock
+pthread_mutex_lock_timeout_np
+pthread_mutex_trylock
+pthread_mutex_unlock
+pthread_mutexattr_destroy
+pthread_mutexattr_getpshared
+pthread_mutexattr_gettype
+pthread_mutexattr_init
+pthread_mutexattr_setpshared
+pthread_mutexattr_settype
+pthread_once
+pthread_rwlock_destroy
+pthread_rwlock_init
+pthread_rwlock_rdlock
+pthread_rwlock_timedrdlock
+pthread_rwlock_timedwrlock
+pthread_rwlock_tryrdlock
+pthread_rwlock_trywrlock
+pthread_rwlock_unlock
+pthread_rwlock_wrlock
+pthread_rwlockattr_destroy
+pthread_rwlockattr_getpshared
+pthread_rwlockattr_init
+pthread_rwlockattr_setpshared
+pthread_self
+pthread_setname_np
+pthread_setschedparam
+pthread_setspecific
+pthread_sigmask
+ptrace
+ptsname
+ptsname_r
+putc
+putc_unlocked
+putchar
+putchar_unlocked
+putenv
+puts
+pututline
+putw
+putwc
+putwchar
+pwrite
+pwrite64
+qsort
+raise
+read
+readdir
+readdir_r
+readlink
+readv
+realloc
+realpath
+reboot
+recv
+recvfrom
+recvmsg
+regcomp
+regerror
+regexec
+regfree
+remove
+rename
+renameat
+res_init
+res_mkquery
+res_query
+res_search
+rewind
+rewinddir
+rmdir
+sbrk
+scandir
+scanf
+sched_get_priority_max
+sched_get_priority_min
+sched_getaffinity
+sched_getcpu
+sched_getparam
+sched_getscheduler
+sched_rr_get_interval
+sched_setaffinity
+sched_setparam
+sched_setscheduler
+sched_yield
+seed48
+select
+sem_close
+sem_destroy
+sem_getvalue
+sem_init
+sem_open
+sem_post
+sem_timedwait
+sem_trywait
+sem_unlink
+sem_wait
+send
+sendfile
+sendmsg
+sendto
+setbuf
+setbuffer
+setegid
+setenv
+seteuid
+setgid
+setgroups
+setitimer
+setjmp
+setlinebuf
+setlocale
+setlogmask
+setlogmask_r
+setpgid
+setpgrp
+setpriority
+setregid
+setresgid
+setresuid
+setreuid
+setrlimit
+setservent
+setsid
+setsockopt
+settimeofday
+setuid
+setusershell
+setutent
+setvbuf
+shutdown
+sigaction
+sigaltstack
+sigblock
+siginterrupt
+siglongjmp
+sigpending
+sigprocmask
+sigsetjmp
+sigsetmask
+sigsuspend
+sigwait
+sleep
+snprintf
+socket
+socketpair
+sprintf
+srand48
+sscanf
+stat
+statfs
+strcasecmp
+strcasestr
+strcat
+strchr
+strcmp
+strcoll
+strcpy
+strcspn
+strdup
+strerror
+strerror_r
+strftime
+strftime_tz
+strlcat
+strlcpy
+strlen
+strncasecmp
+strncat
+strncmp
+strncpy
+strndup
+strnlen
+strntoimax
+strntoumax
+strpbrk
+strptime
+strrchr
+strsep
+strsignal
+strspn
+strstr
+strtod
+strtoimax
+strtok
+strtok_r
+strtol
+strtoll
+strtotimeval
+strtoul
+strtoull
+strtoumax
+strxfrm
+swprintf
+swscanf
+symlink
+sync
+syscall
+sysconf
+sysinfo
+syslog
+syslog_r
+system
+sysv_signal
+tcgetpgrp
+tcsetpgrp
+tempnam
+time
+time2posix
+timegm
+timegm64
+timelocal
+timelocal64
+timer_create
+timer_delete
+timer_getoverrun
+timer_gettime
+timer_settime
+times
+tkill
+tmpfile
+tmpnam
+toascii
+tolower
+toupper
+towlower
+towupper
+truncate
+ttyname
+ttyname_r
+tzset
+umask
+umount
+umount2
+uname
+ungetc
+ungetwc
+unlink
+unlinkat
+unlockpt
+unsetenv
+usleep
+utime
+utimes
+utmpname
+valloc
+vasprintf
+verr
+verrx
+vfdprintf
+vfork
+vfprintf
+vfscanf
+vfwprintf
+vprintf
+vscanf
+vsnprintf
+vsprintf
+vsscanf
+vswprintf
+vsyslog
+vsyslog_r
+vwarn
+vwarnx
+vwprintf
+wait
+wait3
+waitid
+waitpid
+warn
+warnx
+wcpcpy
+wcpncpy
+wcrtomb
+wcscasecmp
+wcscat
+wcschr
+wcscmp
+wcscoll
+wcscpy
+wcscspn
+wcsdup
+wcsftime
+wcslcat
+wcslcpy
+wcslen
+wcsncasecmp
+wcsncat
+wcsncmp
+wcsncpy
+wcsnlen
+wcspbrk
+wcsrchr
+wcsrtombs
+wcsspn
+wcsstr
+wcstod
+wcstok
+wcstol
+wcstombs
+wcstoul
+wcswcs
+wcswidth
+wcsxfrm
+wctob
+wctype
+wcwidth
+wmemchr
+wmemcmp
+wmemcpy
+wmemmove
+wmemset
+wprintf
+write
+writev
+wscanf
+_C_ctype_
+_C_tolower_
+_C_toupper_
+__FINI_ARRAY__
+__INIT_ARRAY__
+__atexit
+__atexit_invalid
+__bionic_brk
+__evOptMonoTime
+__isthreaded
+__libc_malloc_default_dispatch
+__libc_malloc_dispatch
+__p_cert_syms
+__p_class_syms
+__p_key_syms
+__p_rcode_syms
+__p_type_syms
+__page_shift
+__page_size
+__popcount_tab
+__progname
+__rand48_add
+__rand48_mult
+__rand48_seed
+__sF
+__sdidinit
+__sglue
+__stack_chk_guard
+__system_property_area__
+_ctype_
+_ns_flagdata
+_tolower_tab_
+_toupper_tab_
+daylight
+environ
+h_errlist
+h_nerr
+optarg
+opterr
+optind
+optopt
+optreset
+sys_siglist
+sys_signame
+timezone
+tzname
diff --git a/ndk/platforms/android-9/arch-x86/symbols/libdl.so.txt b/ndk/platforms/android-9/arch-x86/symbols/libdl.so.txt
new file mode 100644
index 0000000..24de29a
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/symbols/libdl.so.txt
@@ -0,0 +1,8 @@
+dl_iterate_phdr
+dladdr
+dlclose
+dlerror
+dlopen
+dlsym
+__FINI_ARRAY__
+__INIT_ARRAY__
diff --git a/ndk/platforms/android-9/arch-x86/symbols/libjnigraphics.so.txt b/ndk/platforms/android-9/arch-x86/symbols/libjnigraphics.so.txt
new file mode 100644
index 0000000..9cbc8c2
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/symbols/libjnigraphics.so.txt
@@ -0,0 +1,5 @@
+AndroidBitmap_getInfo
+AndroidBitmap_lockPixels
+AndroidBitmap_unlockPixels
+__FINI_ARRAY__
+__INIT_ARRAY__
diff --git a/ndk/platforms/android-9/arch-x86/symbols/liblog.so.txt b/ndk/platforms/android-9/arch-x86/symbols/liblog.so.txt
new file mode 100644
index 0000000..1405a81
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/symbols/liblog.so.txt
@@ -0,0 +1,10 @@
+__android_log_assert
+__android_log_btwrite
+__android_log_buf_print
+__android_log_buf_write
+__android_log_bwrite
+__android_log_dev_available
+__android_log_print
+__android_log_vprint
+__android_log_write
+
diff --git a/ndk/platforms/android-9/arch-x86/symbols/libm.so.txt b/ndk/platforms/android-9/arch-x86/symbols/libm.so.txt
new file mode 100644
index 0000000..1552b5d
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/symbols/libm.so.txt
@@ -0,0 +1,194 @@
+__exp__D
+__fedisableexcept
+__feenableexcept
+__fpclassifyd
+__fpclassifyf
+__fpclassifyl
+__ieee754_rem_pio2
+__ieee754_rem_pio2f
+__isfinite
+__isfinitef
+__isfinitel
+__isinf
+__isinff
+__isinfl
+__isnanl
+__isnormal
+__isnormalf
+__isnormall
+__kernel_cos
+__kernel_cosdf
+__kernel_rem_pio2
+__kernel_sin
+__kernel_sindf
+__kernel_tan
+__kernel_tandf
+__log__D
+__signbit
+__signbitf
+__signbitl
+__test_sse
+_scan_nan
+acos
+acosf
+acosh
+acoshf
+asin
+asinf
+asinh
+asinhf
+atan
+atan2
+atan2f
+atanf
+atanh
+atanhf
+cbrt
+cbrtf
+ceil
+ceilf
+ceill
+copysign
+copysignf
+copysignl
+cos
+cosf
+cosh
+coshf
+drem
+dremf
+erf
+erfc
+erfcf
+erff
+exp
+exp2
+exp2f
+expf
+expm1
+expm1f
+fabs
+fabsf
+fabsl
+fdim
+fdimf
+fdiml
+fegetenv
+feholdexcept
+feraiseexcept
+fesetexceptflag
+feupdateenv
+finite
+finitef
+floor
+floorf
+floorl
+fma
+fmaf
+fmax
+fmaxf
+fmaxl
+fmin
+fminf
+fminl
+fmod
+fmodf
+frexp
+frexpf
+gamma
+gamma_r
+gammaf
+gammaf_r
+hypot
+hypotf
+ilogb
+ilogbf
+ilogbl
+isnan
+isnanf
+j0
+j0f
+j1
+j1f
+jn
+jnf
+ldexpf
+ldexpl
+lgamma
+lgamma_r
+lgammaf
+lgammaf_r
+llrint
+llrintf
+llround
+llroundf
+llroundl
+log
+log10
+log10f
+log1p
+log1pf
+logb
+logbf
+logf
+lrint
+lrintf
+lround
+lroundf
+lroundl
+modf
+modff
+nan
+nanf
+nearbyint
+nearbyintf
+nextafter
+nextafterf
+nexttowardf
+pow
+powf
+remainder
+remainderf
+remquo
+remquof
+rint
+rintf
+round
+roundf
+roundl
+scalb
+scalbf
+scalbn
+scalbnf
+scalbnl
+significand
+significandf
+sin
+sincos
+sincosf
+sincosl
+sinf
+sinh
+sinhf
+sqrt
+sqrtf
+tan
+tanf
+tanh
+tanhf
+tgamma
+tgammaf
+trunc
+truncf
+truncl
+y0
+y0f
+y1
+y1f
+yn
+ynf
+__FINI_ARRAY__
+__INIT_ARRAY__
+__fe_dfl_env
+__has_sse
+signgam
diff --git a/ndk/platforms/android-9/arch-x86/symbols/libstdc++.so.txt b/ndk/platforms/android-9/arch-x86/symbols/libstdc++.so.txt
new file mode 100644
index 0000000..920262d
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/symbols/libstdc++.so.txt
@@ -0,0 +1,26 @@
+_ZN9type_infoC1ERKS_
+_ZN9type_infoC1Ev
+_ZN9type_infoC2ERKS_
+_ZN9type_infoC2Ev
+_ZN9type_infoD0Ev
+_ZN9type_infoD1Ev
+_ZN9type_infoD2Ev
+_ZNK9type_info4nameEv
+_ZNK9type_info6beforeERKS_
+_ZNK9type_infoeqERKS_
+_ZNK9type_infoneERKS_
+_ZdaPv
+_ZdaPvRKSt9nothrow_t
+_ZdlPv
+_ZdlPvRKSt9nothrow_t
+_Znaj
+_ZnajRKSt9nothrow_t
+_Znwj
+_ZnwjRKSt9nothrow_t
+__cxa_guard_abort
+__cxa_guard_acquire
+__cxa_guard_release
+__cxa_pure_virtual
+_ZSt7nothrow
+__FINI_ARRAY__
+__INIT_ARRAY__
diff --git a/ndk/platforms/android-9/arch-x86/symbols/libz.so.txt b/ndk/platforms/android-9/arch-x86/symbols/libz.so.txt
new file mode 100644
index 0000000..e35c7af
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/symbols/libz.so.txt
@@ -0,0 +1,76 @@
+adler32
+adler32_combine
+adler32_combine64
+compress
+compress2
+compressBound
+crc32
+crc32_combine
+crc32_combine64
+deflate
+deflateBound
+deflateCopy
+deflateEnd
+deflateInit2_
+deflateInit_
+deflateParams
+deflatePrime
+deflateReset
+deflateSetDictionary
+deflateSetHeader
+deflateTune
+get_crc_table
+gzbuffer
+gzclearerr
+gzclose
+gzclose_r
+gzclose_w
+gzdirect
+gzdopen
+gzeof
+gzerror
+gzflush
+gzgetc
+gzgets
+gzoffset
+gzoffset64
+gzopen
+gzopen64
+gzprintf
+gzputc
+gzputs
+gzread
+gzrewind
+gzseek
+gzseek64
+gzsetparams
+gztell
+gztell64
+gzungetc
+gzwrite
+inflate
+inflateBack
+inflateBackEnd
+inflateBackInit_
+inflateCopy
+inflateEnd
+inflateGetHeader
+inflateInit2_
+inflateInit_
+inflateMark
+inflatePrime
+inflateReset
+inflateReset2
+inflateSetDictionary
+inflateSync
+inflateSyncPoint
+inflateUndermine
+uncompress
+zError
+zlibCompileFlags
+zlibVersion
+__FINI_ARRAY__
+__INIT_ARRAY__
+deflate_copyright
+inflate_copyright
+z_errmsg
diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml
index 6ead389..1657878 100644
--- a/samples/ApiDemos/AndroidManifest.xml
+++ b/samples/ApiDemos/AndroidManifest.xml
@@ -38,7 +38,10 @@
 
     <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="11" />
 
-    <!-- This app has not been optimized for large screens. -->
+    <!-- The smallest screen this app works on is a phone.  The app will
+         scale its UI to larger screens but doesn't make good use of them
+         so allow the compatibility mode button to be shown (mostly because
+         this is just convenient for testing). -->
     <supports-screens android:requiresSmallestWidthDp="320"
             android:compatibleWidthLimitDp="480" />
 
@@ -361,6 +364,15 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".app.FragmentTabs"
+                android:label="@string/fragment_tabs"
+                android:enabled="@bool/atLeastHoneycomb">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+
         <!-- Loader Samples -->
 
         <activity android:name=".app.LoaderCursor"
diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index 1126233..5f9e990 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -153,6 +153,8 @@
     <string name="first">First</string>
     <string name="last">Last</string>
 
+    <string name="fragment_tabs">App/Fragment/Tabs</string>
+
     <string name="loader_cursor">App/Loader/Cursor</string>
 
     <string name="loader_custom">App/Loader/Custom</string>
@@ -617,6 +619,10 @@
     <string name="header_encryption">Encryption</string>
 
     <string name="enable_admin">Enable admin</string>
+    <string name="device_capabilities_category">Device capabilities</string>
+    <string name="disable_camera">Disable all device cameras</string>
+    <string name="camera_disabled">Device cameras disabled</string>
+    <string name="camera_enabled">Device cameras enabled</string>
     <string name="password_controls_category">Password controls</string>
     <string name="set_password_user">Set password (user)</string>
     <string name="set_password_api">Set password (via API)</string>
diff --git a/samples/ApiDemos/res/xml/appwidget_provider.xml b/samples/ApiDemos/res/xml/appwidget_provider.xml
index 5f5c735..9879f5d 100644
--- a/samples/ApiDemos/res/xml/appwidget_provider.xml
+++ b/samples/ApiDemos/res/xml/appwidget_provider.xml
@@ -20,6 +20,7 @@
     android:updatePeriodMillis="86400000"
     android:initialLayout="@layout/appwidget_provider"
     android:configure="com.example.android.apis.appwidget.ExampleAppWidgetConfigure"
+    android:resizeMode="horizontal"
     >
 </appwidget-provider>
 
diff --git a/samples/ApiDemos/res/xml/device_admin_general.xml b/samples/ApiDemos/res/xml/device_admin_general.xml
index ef46238..61ccd32 100644
--- a/samples/ApiDemos/res/xml/device_admin_general.xml
+++ b/samples/ApiDemos/res/xml/device_admin_general.xml
@@ -28,4 +28,13 @@
 
     </PreferenceCategory>
 
+    <PreferenceCategory
+        android:title="@string/device_capabilities_category" >
+
+        <CheckBoxPreference
+            android:key="key_disable_camera"
+            android:title="@string/disable_camera" />
+
+    </PreferenceCategory>
+
 </PreferenceScreen>
diff --git a/samples/ApiDemos/res/xml/device_admin_sample.xml b/samples/ApiDemos/res/xml/device_admin_sample.xml
index 10edb7e..2468919 100644
--- a/samples/ApiDemos/res/xml/device_admin_sample.xml
+++ b/samples/ApiDemos/res/xml/device_admin_sample.xml
@@ -24,6 +24,7 @@
         <wipe-data />
         <expire-password />
         <encrypted-storage />
+        <disable-camera />
     </uses-policies>
 </device-admin>
 <!-- END_INCLUDE(meta_data) -->
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.java b/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.java
index 8a7bf51..11c1bc2 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/ActionBarTabs.java
@@ -78,6 +78,11 @@
      * to it, it will be committed at the end of the full tab switch operation.
      * This lets tab switches be atomic without the app needing to track
      * the interactions between different tabs.
+     *
+     * NOTE: This is a very simple implementation that does not retain
+     * fragment state of the non-visible tabs across activity instances.
+     * Look at the FragmentTabs example for how to do a more complete
+     * implementation.
      */
     private class TabListener implements ActionBar.TabListener {
         private TabContentFragment mFragment;
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/DeviceAdminSample.java b/samples/ApiDemos/src/com/example/android/apis/app/DeviceAdminSample.java
index a9af983..324b8ce 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/DeviceAdminSample.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/DeviceAdminSample.java
@@ -67,6 +67,7 @@
 
     // The following keys are used to find each preference item
     private static final String KEY_ENABLE_ADMIN = "key_enable_admin";
+    private static final String KEY_DISABLE_CAMERA = "key_disable_camera";
 
     private static final String KEY_CATEGORY_QUALITY = "key_category_quality";
     private static final String KEY_SET_PASSWORD = "key_set_password";
@@ -243,6 +244,7 @@
             implements OnPreferenceChangeListener {
         // UI elements
         private CheckBoxPreference mEnableCheckbox;
+        private CheckBoxPreference mDisableCameraCheckbox;
 
         @Override
         public void onCreate(Bundle savedInstanceState) {
@@ -250,6 +252,8 @@
             addPreferencesFromResource(R.xml.device_admin_general);
             mEnableCheckbox = (CheckBoxPreference) findPreference(KEY_ENABLE_ADMIN);
             mEnableCheckbox.setOnPreferenceChangeListener(this);
+            mDisableCameraCheckbox = (CheckBoxPreference) findPreference(KEY_DISABLE_CAMERA);
+            mDisableCameraCheckbox.setOnPreferenceChangeListener(this);
         }
 
         // At onResume time, reload UI with current values as required
@@ -257,6 +261,12 @@
         public void onResume() {
             super.onResume();
             mEnableCheckbox.setChecked(mAdminActive);
+            enableDeviceCapabilitiesArea(mAdminActive);
+
+            if (mAdminActive) {
+                mDPM.setCameraDisabled(mDeviceAdminSample, mDisableCameraCheckbox.isChecked());
+                reloadSummaries();
+            }
         }
 
         @Override
@@ -264,10 +274,10 @@
             if (super.onPreferenceChange(preference, newValue)) {
                 return true;
             }
+            boolean value = (Boolean) newValue;
             if (preference == mEnableCheckbox) {
-                boolean newActive = (Boolean) newValue;
-                if (newActive != mAdminActive) {
-                    if (newActive) {
+                if (value != mAdminActive) {
+                    if (value) {
                         // Launch the activity to have the user enable our admin.
                         Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
                         intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mDeviceAdminSample);
@@ -278,12 +288,29 @@
                         return false;
                     } else {
                         mDPM.removeActiveAdmin(mDeviceAdminSample);
+                        enableDeviceCapabilitiesArea(false);
                         mAdminActive = false;
                     }
                 }
+            } else if (preference == mDisableCameraCheckbox) {
+                mDPM.setCameraDisabled(mDeviceAdminSample, value);
+                reloadSummaries();
             }
             return true;
         }
+
+        @Override
+        protected void reloadSummaries() {
+            super.reloadSummaries();
+            String cameraSummary = getString(mDPM.getCameraDisabled(mDeviceAdminSample)
+                    ? R.string.camera_disabled : R.string.camera_enabled);
+            mDisableCameraCheckbox.setSummary(cameraSummary);
+        }
+
+        /** Updates the device capabilities area (dis/enabling) as the admin is (de)activated */
+        private void enableDeviceCapabilitiesArea(boolean enabled) {
+            mDisableCameraCheckbox.setEnabled(enabled);
+        }
     }
 
     /**
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java b/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java
new file mode 100644
index 0000000..e245e9b
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/app/FragmentTabs.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.example.android.apis.app;
+
+import com.example.android.apis.R;
+
+//BEGIN_INCLUDE(complete)
+import android.app.ActionBar;
+import android.app.ActionBar.Tab;
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.FragmentTransaction;
+import android.os.Bundle;
+import android.widget.Toast;
+
+/**
+ * This demonstrates the use of action bar tabs and how they interact
+ * with other action bar features.
+ */
+public class FragmentTabs extends Activity {
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        final ActionBar bar = getActionBar();
+        bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+        bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
+
+        bar.addTab(bar.newTab()
+                .setText("Simple")
+                .setTabListener(new TabListener<FragmentStack.CountingFragment>(
+                        this, "simple", FragmentStack.CountingFragment.class)));
+        bar.addTab(bar.newTab()
+                .setText("Contacts")
+                .setTabListener(new TabListener<LoaderCursor.CursorLoaderListFragment>(
+                        this, "contacts", LoaderCursor.CursorLoaderListFragment.class)));
+        bar.addTab(bar.newTab()
+                .setText("Apps")
+                .setTabListener(new TabListener<LoaderCustom.AppListFragment>(
+                        this, "apps", LoaderCustom.AppListFragment.class)));
+        bar.addTab(bar.newTab()
+                .setText("Throttle")
+                .setTabListener(new TabListener<LoaderThrottle.ThrottledLoaderListFragment>(
+                        this, "throttle", LoaderThrottle.ThrottledLoaderListFragment.class)));
+
+        if (savedInstanceState != null) {
+            bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
+        }
+    }
+
+    @Override
+    protected void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putInt("tab", getActionBar().getSelectedNavigationIndex());
+    }
+
+    public static class TabListener<T extends Fragment> implements ActionBar.TabListener {
+        private final Activity mActivity;
+        private final String mTag;
+        private final Class<T> mClass;
+        private final Bundle mArgs;
+        private Fragment mFragment;
+
+        public TabListener(Activity activity, String tag, Class<T> clz) {
+            this(activity, tag, clz, null);
+        }
+
+        public TabListener(Activity activity, String tag, Class<T> clz, Bundle args) {
+            mActivity = activity;
+            mTag = tag;
+            mClass = clz;
+            mArgs = args;
+
+            // Check to see if we already have a fragment for this tab, probably
+            // from a previously saved state.  If so, deactivate it, because our
+            // initial state is that a tab isn't shown.
+            mFragment = mActivity.getFragmentManager().findFragmentByTag(mTag);
+            if (mFragment != null && !mFragment.isDetached()) {
+                FragmentTransaction ft = mActivity.getFragmentManager().beginTransaction();
+                ft.detach(mFragment);
+                ft.commit();
+            }
+        }
+
+        public void onTabSelected(Tab tab, FragmentTransaction ft) {
+            if (mFragment == null) {
+                mFragment = Fragment.instantiate(mActivity, mClass.getName(), mArgs);
+                ft.add(android.R.id.content, mFragment, mTag);
+            } else {
+                ft.attach(mFragment);
+            }
+        }
+
+        public void onTabUnselected(Tab tab, FragmentTransaction ft) {
+            if (mFragment != null) {
+                ft.detach(mFragment);
+            }
+        }
+
+        public void onTabReselected(Tab tab, FragmentTransaction ft) {
+            Toast.makeText(mActivity, "Reselected!", Toast.LENGTH_SHORT).show();
+        }
+    }
+}
+//END_INCLUDE(complete)
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/LoaderCursor.java b/samples/ApiDemos/src/com/example/android/apis/app/LoaderCursor.java
index a8ac0d4..fd2fa68 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/LoaderCursor.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/LoaderCursor.java
@@ -159,7 +159,11 @@
             mAdapter.swapCursor(data);
 
             // The list should now be shown.
-            setListShown(true);
+            if (isResumed()) {
+                setListShown(true);
+            } else {
+                setListShownNoAnimation(true);
+            }
         }
 
         public void onLoaderReset(Loader<Cursor> loader) {
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/LoaderCustom.java b/samples/ApiDemos/src/com/example/android/apis/app/LoaderCustom.java
index 883ab14..e1e77a9 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/LoaderCustom.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/LoaderCustom.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2011 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -466,7 +466,11 @@
             mAdapter.setData(data);
 
             // The list should now be shown.
-            setListShown(true);
+            if (isResumed()) {
+                setListShown(true);
+            } else {
+                setListShownNoAnimation(true);
+            }
         }
 
         @Override public void onLoaderReset(Loader<List<AppEntry>> loader) {
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/LoaderThrottle.java b/samples/ApiDemos/src/com/example/android/apis/app/LoaderThrottle.java
index 1c4c839..af674c0 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/LoaderThrottle.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/LoaderThrottle.java
@@ -409,6 +409,9 @@
                     new int[] { android.R.id.text1 }, 0);
             setListAdapter(mAdapter);
 
+            // Start out with a progress indicator.
+            setListShown(false);
+
             // Prepare the loader.  Either re-connect with an existing one,
             // or start a new one.
             getLoaderManager().initLoader(0, null, this);
@@ -492,6 +495,13 @@
 
         public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
             mAdapter.swapCursor(data);
+
+            // The list should now be shown.
+            if (isResumed()) {
+                setListShown(true);
+            } else {
+                setListShownNoAnimation(true);
+            }
         }
 
         public void onLoaderReset(Loader<Cursor> loader) {
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/_index.html b/samples/ApiDemos/src/com/example/android/apis/app/_index.html
index 71ccb54..e9d1cf5 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/_index.html
+++ b/samples/ApiDemos/src/com/example/android/apis/app/_index.html
@@ -134,6 +134,10 @@
   <dd>Demonstrates creating a stack of Fragment instances similar to the
   traditional stack of activities.</dd>
   
+  <dt><a href="FragmentTabs.html">Fragment Tabs</a></dt>
+  <dd>Demonstrates implementing ActionBar tabs by switching between
+  Fragments.</dd>
+
 </dl>
 
 
@@ -145,9 +149,10 @@
 Action Bar in a more idiomatic manner.</dd>
   <dt><a href="ActionBarTabs.html">Action Bar Tabs</a></dt>
   <dd>Demonstrates the use of Action Bar tabs and how they interact with other action bar
-features.</dd>
+features.  Also see the <a href="FragmentTabs.html">Fragment Tabs</a> for a more
+complete example of how to switch between fragments.</dd>
   <dt><a href="ActionBarUsage.html">Action Bar Usage</a></dt>
-  <dd>Demonstrates imple usage of the Action Bar, including a SearchView as an action item. The
+  <dd>Demonstrates simple usage of the Action Bar, including a SearchView as an action item. The
 default Honeycomb theme includes the Action Bar by default and a menu resource is used to populate
 the menu data itself. If you'd like to see how these things work under the hood, see
 Mechanics.</dd>
@@ -162,6 +167,10 @@
   <dd>Demonstrates use of LoaderManager to perform a query for a Cursor that
   populates a ListFragment.</dd>
 
+  <dt><a href="LoaderCustom.html">Loader Custom</a></dt>
+  <dd>Demonstrates implementation and use of a custom Loader class.  The
+  custom class here "loads" the currently installed applications.</dd>
+
   <dt><a href="LoaderThrottle.html">Loader Throttle</a></dt>
   <dd>Complete end-to-end demonstration of a simple content provider that
   populates data in a list through a cursor loader.  The UI allows the list
diff --git a/samples/RandomMusicPlayer/AndroidManifest.xml b/samples/RandomMusicPlayer/AndroidManifest.xml
new file mode 100644
index 0000000..5a0fc28
--- /dev/null
+++ b/samples/RandomMusicPlayer/AndroidManifest.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+      package="com.example.android.musicplayer"
+      android:versionCode="1"
+      android:versionName="1.0">
+
+    <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="8" />
+    <uses-permission android:name="android.permission.WAKE_LOCK"/>
+
+    <application android:icon="@drawable/ic_launcher" android:label="Random Music Player">
+        <activity android:name=".MainActivity"
+                  android:label="Random Music Player"
+                  android:theme="@android:style/Theme.Black.NoTitleBar">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
+        <service android:exported="false" android:name=".MusicService">
+            <intent-filter>
+                <action android:name="com.example.android.musicplayer.action.PLAY" />
+                <action android:name="com.example.android.musicplayer.action.PAUSE" />
+                <action android:name="com.example.android.musicplayer.action.SKIP" />
+                <action android:name="com.example.android.musicplayer.action.REWIND" />
+                <action android:name="com.example.android.musicplayer.action.STOP" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="com.example.android.musicplayer.action.URL" />
+                <data android:scheme="http" />
+            </intent-filter>
+        </service>
+
+        <receiver android:name=".MusicIntentReceiver">
+            <intent-filter>
+                <action android:name="android.media.AUDIO_BECOMING_NOISY" />
+            </intent-filter>
+        </receiver>
+    </application>
+</manifest>
diff --git a/samples/RandomMusicPlayer/_index.html b/samples/RandomMusicPlayer/_index.html
new file mode 100644
index 0000000..657e6c4
--- /dev/null
+++ b/samples/RandomMusicPlayer/_index.html
@@ -0,0 +1,8 @@
+<p>A simple music player that illustrates how to make a multimedia application
+that manages media playback from a service. It allows the user to play music
+available on the device or specify a URL from which the media should be
+streamed.  It also illustrates how to use the notification system to indicate
+an ongoing task and how to deal with audio focus changes.</p>
+
+<img alt="" src="../images/randommusicplayer.png" />
+
diff --git a/samples/RandomMusicPlayer/default.properties b/samples/RandomMusicPlayer/default.properties
new file mode 100644
index 0000000..e2e8061
--- /dev/null
+++ b/samples/RandomMusicPlayer/default.properties
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi-v9/ic_stat_playing.png b/samples/RandomMusicPlayer/res/drawable-hdpi-v9/ic_stat_playing.png
new file mode 100644
index 0000000..d111aab
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi-v9/ic_stat_playing.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/eject.png b/samples/RandomMusicPlayer/res/drawable-hdpi/eject.png
new file mode 100644
index 0000000..650b38a
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/eject.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/eject_pressed.png b/samples/RandomMusicPlayer/res/drawable-hdpi/eject_pressed.png
new file mode 100644
index 0000000..065b30d
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/eject_pressed.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/ff.png b/samples/RandomMusicPlayer/res/drawable-hdpi/ff.png
new file mode 100644
index 0000000..508f741
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/ff.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/ff_pressed.png b/samples/RandomMusicPlayer/res/drawable-hdpi/ff_pressed.png
new file mode 100644
index 0000000..468ae8e
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/ff_pressed.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/ic_launcher.png b/samples/RandomMusicPlayer/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..abd9055
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/ic_stat_playing.png b/samples/RandomMusicPlayer/res/drawable-hdpi/ic_stat_playing.png
new file mode 100644
index 0000000..c1dd9da
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/ic_stat_playing.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/pause.png b/samples/RandomMusicPlayer/res/drawable-hdpi/pause.png
new file mode 100644
index 0000000..13581de
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/pause.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/pause_pressed.png b/samples/RandomMusicPlayer/res/drawable-hdpi/pause_pressed.png
new file mode 100644
index 0000000..9ddd07d
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/pause_pressed.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/play.png b/samples/RandomMusicPlayer/res/drawable-hdpi/play.png
new file mode 100644
index 0000000..e34b48e
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/play.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/play_pressed.png b/samples/RandomMusicPlayer/res/drawable-hdpi/play_pressed.png
new file mode 100644
index 0000000..790cd29
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/play_pressed.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/rew.png b/samples/RandomMusicPlayer/res/drawable-hdpi/rew.png
new file mode 100644
index 0000000..26864b7
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/rew.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/rew_pressed.png b/samples/RandomMusicPlayer/res/drawable-hdpi/rew_pressed.png
new file mode 100644
index 0000000..54c38a7
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/rew_pressed.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/selector_eject.xml b/samples/RandomMusicPlayer/res/drawable-hdpi/selector_eject.xml
new file mode 100644
index 0000000..300e75a
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/selector_eject.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
+     <item android:state_pressed="true"
+           android:drawable="@drawable/eject_pressed" /> <!-- pressed -->
+     <item android:state_focused="true"
+           android:drawable="@drawable/eject_pressed" /> <!-- focused -->
+     <item android:drawable="@drawable/eject" /> <!-- default -->
+ </selector>
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/selector_ff.xml b/samples/RandomMusicPlayer/res/drawable-hdpi/selector_ff.xml
new file mode 100644
index 0000000..2d399b4
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/selector_ff.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
+     <item android:state_pressed="true"
+           android:drawable="@drawable/ff_pressed" /> <!-- pressed -->
+     <item android:state_focused="true"
+           android:drawable="@drawable/ff_pressed" /> <!-- focused -->
+     <item android:drawable="@drawable/ff" /> <!-- default -->
+ </selector>
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/selector_pause.xml b/samples/RandomMusicPlayer/res/drawable-hdpi/selector_pause.xml
new file mode 100644
index 0000000..2d6c4be
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/selector_pause.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
+     <item android:state_pressed="true"
+           android:drawable="@drawable/pause_pressed" /> <!-- pressed -->
+     <item android:state_focused="true"
+           android:drawable="@drawable/pause_pressed" /> <!-- focused -->
+     <item android:drawable="@drawable/pause" /> <!-- default -->
+ </selector>
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/selector_play.xml b/samples/RandomMusicPlayer/res/drawable-hdpi/selector_play.xml
new file mode 100644
index 0000000..d2eea02
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/selector_play.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
+     <item android:state_pressed="true"
+           android:drawable="@drawable/play_pressed" /> <!-- pressed -->
+     <item android:state_focused="true"
+           android:drawable="@drawable/play_pressed" /> <!-- focused -->
+     <item android:drawable="@drawable/play" /> <!-- default -->
+ </selector>
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/selector_rew.xml b/samples/RandomMusicPlayer/res/drawable-hdpi/selector_rew.xml
new file mode 100644
index 0000000..5f5f88a
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/selector_rew.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
+     <item android:state_pressed="true"
+           android:drawable="@drawable/rew_pressed" /> <!-- pressed -->
+     <item android:state_focused="true"
+           android:drawable="@drawable/rew_pressed" /> <!-- focused -->
+     <item android:drawable="@drawable/rew" /> <!-- default -->
+ </selector>
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/selector_stop.xml b/samples/RandomMusicPlayer/res/drawable-hdpi/selector_stop.xml
new file mode 100644
index 0000000..5778417
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/selector_stop.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
+     <item android:state_pressed="true"
+           android:drawable="@drawable/stop_pressed" /> <!-- pressed -->
+     <item android:state_focused="true"
+           android:drawable="@drawable/stop_pressed" /> <!-- focused -->
+     <item android:drawable="@drawable/stop" /> <!-- default -->
+ </selector>
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/stop.png b/samples/RandomMusicPlayer/res/drawable-hdpi/stop.png
new file mode 100644
index 0000000..45eff23
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/stop.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-hdpi/stop_pressed.png b/samples/RandomMusicPlayer/res/drawable-hdpi/stop_pressed.png
new file mode 100644
index 0000000..c7bda81
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-hdpi/stop_pressed.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-ldpi-v9/ic_stat_playing.png b/samples/RandomMusicPlayer/res/drawable-ldpi-v9/ic_stat_playing.png
new file mode 100644
index 0000000..6a40823
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-ldpi-v9/ic_stat_playing.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-ldpi/ic_launcher.png b/samples/RandomMusicPlayer/res/drawable-ldpi/ic_launcher.png
new file mode 100644
index 0000000..6f1277a
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-ldpi/ic_launcher.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-ldpi/ic_stat_playing.png b/samples/RandomMusicPlayer/res/drawable-ldpi/ic_stat_playing.png
new file mode 100644
index 0000000..fb21884
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-ldpi/ic_stat_playing.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi-v9/ic_stat_playing.png b/samples/RandomMusicPlayer/res/drawable-mdpi-v9/ic_stat_playing.png
new file mode 100644
index 0000000..b5a66df
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi-v9/ic_stat_playing.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/eject.png b/samples/RandomMusicPlayer/res/drawable-mdpi/eject.png
new file mode 100644
index 0000000..650b38a
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/eject.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/eject_pressed.png b/samples/RandomMusicPlayer/res/drawable-mdpi/eject_pressed.png
new file mode 100644
index 0000000..065b30d
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/eject_pressed.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/ff.png b/samples/RandomMusicPlayer/res/drawable-mdpi/ff.png
new file mode 100644
index 0000000..508f741
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/ff.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/ff_pressed.png b/samples/RandomMusicPlayer/res/drawable-mdpi/ff_pressed.png
new file mode 100644
index 0000000..468ae8e
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/ff_pressed.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/ic_launcher.png b/samples/RandomMusicPlayer/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..abd9055
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/ic_stat_playing.png b/samples/RandomMusicPlayer/res/drawable-mdpi/ic_stat_playing.png
new file mode 100644
index 0000000..c1dd9da
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/ic_stat_playing.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/pause.png b/samples/RandomMusicPlayer/res/drawable-mdpi/pause.png
new file mode 100644
index 0000000..13581de
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/pause.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/pause_pressed.png b/samples/RandomMusicPlayer/res/drawable-mdpi/pause_pressed.png
new file mode 100644
index 0000000..9ddd07d
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/pause_pressed.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/play.png b/samples/RandomMusicPlayer/res/drawable-mdpi/play.png
new file mode 100644
index 0000000..e34b48e
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/play.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/play_pressed.png b/samples/RandomMusicPlayer/res/drawable-mdpi/play_pressed.png
new file mode 100644
index 0000000..790cd29
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/play_pressed.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/rew.png b/samples/RandomMusicPlayer/res/drawable-mdpi/rew.png
new file mode 100644
index 0000000..26864b7
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/rew.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/rew_pressed.png b/samples/RandomMusicPlayer/res/drawable-mdpi/rew_pressed.png
new file mode 100644
index 0000000..54c38a7
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/rew_pressed.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/selector_eject.xml b/samples/RandomMusicPlayer/res/drawable-mdpi/selector_eject.xml
new file mode 100644
index 0000000..300e75a
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/selector_eject.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
+     <item android:state_pressed="true"
+           android:drawable="@drawable/eject_pressed" /> <!-- pressed -->
+     <item android:state_focused="true"
+           android:drawable="@drawable/eject_pressed" /> <!-- focused -->
+     <item android:drawable="@drawable/eject" /> <!-- default -->
+ </selector>
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/selector_ff.xml b/samples/RandomMusicPlayer/res/drawable-mdpi/selector_ff.xml
new file mode 100644
index 0000000..2d399b4
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/selector_ff.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
+     <item android:state_pressed="true"
+           android:drawable="@drawable/ff_pressed" /> <!-- pressed -->
+     <item android:state_focused="true"
+           android:drawable="@drawable/ff_pressed" /> <!-- focused -->
+     <item android:drawable="@drawable/ff" /> <!-- default -->
+ </selector>
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/selector_pause.xml b/samples/RandomMusicPlayer/res/drawable-mdpi/selector_pause.xml
new file mode 100644
index 0000000..2d6c4be
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/selector_pause.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
+     <item android:state_pressed="true"
+           android:drawable="@drawable/pause_pressed" /> <!-- pressed -->
+     <item android:state_focused="true"
+           android:drawable="@drawable/pause_pressed" /> <!-- focused -->
+     <item android:drawable="@drawable/pause" /> <!-- default -->
+ </selector>
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/selector_play.xml b/samples/RandomMusicPlayer/res/drawable-mdpi/selector_play.xml
new file mode 100644
index 0000000..d2eea02
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/selector_play.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
+     <item android:state_pressed="true"
+           android:drawable="@drawable/play_pressed" /> <!-- pressed -->
+     <item android:state_focused="true"
+           android:drawable="@drawable/play_pressed" /> <!-- focused -->
+     <item android:drawable="@drawable/play" /> <!-- default -->
+ </selector>
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/selector_rew.xml b/samples/RandomMusicPlayer/res/drawable-mdpi/selector_rew.xml
new file mode 100644
index 0000000..5f5f88a
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/selector_rew.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
+     <item android:state_pressed="true"
+           android:drawable="@drawable/rew_pressed" /> <!-- pressed -->
+     <item android:state_focused="true"
+           android:drawable="@drawable/rew_pressed" /> <!-- focused -->
+     <item android:drawable="@drawable/rew" /> <!-- default -->
+ </selector>
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/selector_stop.xml b/samples/RandomMusicPlayer/res/drawable-mdpi/selector_stop.xml
new file mode 100644
index 0000000..5778417
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/selector_stop.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
+     <item android:state_pressed="true"
+           android:drawable="@drawable/stop_pressed" /> <!-- pressed -->
+     <item android:state_focused="true"
+           android:drawable="@drawable/stop_pressed" /> <!-- focused -->
+     <item android:drawable="@drawable/stop" /> <!-- default -->
+ </selector>
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/stop.png b/samples/RandomMusicPlayer/res/drawable-mdpi/stop.png
new file mode 100644
index 0000000..45eff23
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/stop.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/drawable-mdpi/stop_pressed.png b/samples/RandomMusicPlayer/res/drawable-mdpi/stop_pressed.png
new file mode 100644
index 0000000..c7bda81
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/drawable-mdpi/stop_pressed.png
Binary files differ
diff --git a/samples/RandomMusicPlayer/res/layout-land/main.xml b/samples/RandomMusicPlayer/res/layout-land/main.xml
new file mode 100644
index 0000000..c9072bf
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/layout-land/main.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:gravity="center"
+    android:background="#000040"
+    >
+
+<TextView android:text="Random Music Player"
+          android:layout_width="wrap_content"
+          android:layout_height="wrap_content"
+          android:padding="20dp"
+          android:textColor="#ffffff"
+          android:textSize="20sp"
+          android:textStyle="bold"
+          />
+
+<LinearLayout
+    android:orientation="horizontal"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:gravity="center"
+    >
+<Button
+    android:id="@+id/rewindbutton"
+    android:background="@drawable/selector_rew"
+    android:layout_width="64dp"
+    android:layout_height="64dp"
+    android:layout_margin="5dp"
+    />
+<Button
+    android:id="@+id/playbutton"
+    android:background="@drawable/selector_play"
+    android:layout_width="64dp"
+    android:layout_height="64dp"
+    android:layout_margin="5dp"
+    />
+<Button
+    android:id="@+id/pausebutton"
+    android:background="@drawable/selector_pause"
+    android:layout_width="64dp"
+    android:layout_height="64dp"
+    android:layout_margin="5dp"
+    />
+<Button
+    android:id="@+id/skipbutton"
+    android:background="@drawable/selector_ff"
+    android:layout_width="64dp"
+    android:layout_height="64dp"
+    android:layout_margin="5dp"
+    />
+<Button
+    android:id="@+id/stopbutton"
+    android:background="@drawable/selector_stop"
+    android:layout_width="64dp"
+    android:layout_height="64dp"
+    android:layout_margin="5dp"
+    />
+<Button
+    android:id="@+id/ejectbutton"
+    android:background="@drawable/selector_eject"
+    android:layout_width="64dp"
+    android:layout_height="64dp"
+    android:layout_margin="5dp"
+    />
+
+</LinearLayout>
+</LinearLayout>
diff --git a/samples/RandomMusicPlayer/res/layout-port/main.xml b/samples/RandomMusicPlayer/res/layout-port/main.xml
new file mode 100644
index 0000000..ab86ae5
--- /dev/null
+++ b/samples/RandomMusicPlayer/res/layout-port/main.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:gravity="center"
+    android:background="#000040"
+    >
+
+<TextView android:text="Random Music Player"
+          android:layout_width="wrap_content"
+          android:layout_height="wrap_content"
+          android:padding="20dp"
+          android:textColor="#ffffff"
+          android:textSize="20sp"
+          android:textStyle="bold"
+          />
+
+<LinearLayout
+    android:orientation="horizontal"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:gravity="center"
+    android:layout_margin="10dp"
+    >
+<Button
+    android:id="@+id/rewindbutton"
+    android:background="@drawable/selector_rew"
+    android:layout_width="64dp"
+    android:layout_height="64dp"
+    android:layout_margin="5dp"
+    />
+<Button
+    android:id="@+id/playbutton"
+    android:background="@drawable/selector_play"
+    android:layout_width="64dp"
+    android:layout_height="64dp"
+    android:layout_margin="5dp"
+    />
+<Button
+    android:id="@+id/pausebutton"
+    android:background="@drawable/selector_pause"
+    android:layout_width="64dp"
+    android:layout_height="64dp"
+    android:layout_margin="5dp"
+    />
+<Button
+    android:id="@+id/skipbutton"
+    android:background="@drawable/selector_ff"
+    android:layout_width="64dp"
+    android:layout_height="64dp"
+    android:layout_margin="5dp"
+    />
+</LinearLayout>
+
+<LinearLayout
+    android:orientation="horizontal"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:gravity="center"
+    android:layout_margin="10dp"
+    >
+<Button
+    android:id="@+id/stopbutton"
+    android:background="@drawable/selector_stop"
+    android:layout_width="64dp"
+    android:layout_height="64dp"
+    android:layout_margin="5dp"
+    />
+<Button
+    android:id="@+id/ejectbutton"
+    android:background="@drawable/selector_eject"
+    android:layout_width="64dp"
+    android:layout_height="64dp"
+    android:layout_margin="5dp"
+    />
+
+</LinearLayout>
+</LinearLayout>
diff --git a/samples/RandomMusicPlayer/src/com/example/android/musicplayer/AudioFocusHelper.java b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/AudioFocusHelper.java
new file mode 100644
index 0000000..4b8b54a
--- /dev/null
+++ b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/AudioFocusHelper.java
@@ -0,0 +1,71 @@
+/*   
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.musicplayer;
+
+import android.content.Context;
+import android.media.AudioManager;
+
+/** 
+ * Convenience class to deal with audio focus. This class deals with everything related to audio
+ * focus: it can request and abandon focus, and will intercept focus change events and deliver
+ * them to a MusicFocusable interface (which, in our case, is implemented by {@link MusicService}).
+ *
+ * This class can only be used on SDK level 8 and above, since it uses API features that are not
+ * available on previous SDK's.
+ */
+public class AudioFocusHelper implements AudioManager.OnAudioFocusChangeListener {
+    AudioManager mAM;
+    MusicFocusable mFocusable;
+
+    public AudioFocusHelper(Context ctx, MusicFocusable focusable) {
+        mAM = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
+        mFocusable = focusable;
+    }
+
+    /** Requests audio focus. Returns whether request was successful or not. */
+    public boolean requestFocus() {
+        return AudioManager.AUDIOFOCUS_REQUEST_GRANTED ==
+            mAM.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
+    }
+
+    /** Abandons audio focus. Returns whether request was successful or not. */
+    public boolean abandonFocus() {
+        return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAM.abandonAudioFocus(this);
+    }
+
+    /** 
+     * Called by AudioManager on audio focus changes. We implement this by calling our
+     * MusicFocusable appropriately to relay the message.
+     */
+    @Override
+    public void onAudioFocusChange(int focusChange) {
+        if (mFocusable == null) return;
+        switch (focusChange) {
+            case AudioManager.AUDIOFOCUS_GAIN:
+                mFocusable.onGainedAudioFocus();
+                break;
+            case AudioManager.AUDIOFOCUS_LOSS:
+            case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
+                mFocusable.onLostAudioFocus(false);
+                break;
+            case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
+                mFocusable.onLostAudioFocus(true);
+                break;
+             default:
+        }
+    }
+}
diff --git a/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MainActivity.java b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MainActivity.java
new file mode 100644
index 0000000..4974a21
--- /dev/null
+++ b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MainActivity.java
@@ -0,0 +1,122 @@
+/*   
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.musicplayer;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.EditText;
+
+/** 
+ * Main activity: shows media player buttons. This activity shows the media player buttons and
+ * lets the user click them. No media handling is done here -- everything is done by passing
+ * Intents to our {@link MusicService}.
+ * */
+public class MainActivity extends Activity implements OnClickListener {
+    /**
+     * The URL we suggest as default when adding by URL. This is just so that the user doesn't
+     * have to find an URL to test this sample.
+     */
+    final String SUGGESTED_URL = "http://www.vorbis.com/music/Epoq-Lepidoptera.ogg";
+
+    Button mPlayButton;
+    Button mPauseButton;
+    Button mSkipButton;
+    Button mRewindButton;
+    Button mStopButton;
+    Button mEjectButton;
+
+    /**
+     * Called when the activity is first created. Here, we simply set the event listeners and
+     * start the background service ({@link MusicService}) that will handle the actual media
+     * playback.
+     */
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.main);
+
+        mPlayButton = (Button) findViewById(R.id.playbutton);
+        mPauseButton = (Button) findViewById(R.id.pausebutton);
+        mSkipButton = (Button) findViewById(R.id.skipbutton);
+        mRewindButton = (Button) findViewById(R.id.rewindbutton);
+        mStopButton = (Button) findViewById(R.id.stopbutton);
+        mEjectButton = (Button) findViewById(R.id.ejectbutton);
+
+        mPlayButton.setOnClickListener(this);
+        mPauseButton.setOnClickListener(this);
+        mSkipButton.setOnClickListener(this);
+        mRewindButton.setOnClickListener(this);
+        mStopButton.setOnClickListener(this);
+        mEjectButton.setOnClickListener(this);
+    }
+
+    @Override
+    public void onClick(View target) {
+        // Send the correct intent to the MusicService, according to the button that was clicked
+        if (target == mPlayButton)
+            startService(new Intent(MusicService.ACTION_PLAY));
+        else if (target == mPauseButton)
+            startService(new Intent(MusicService.ACTION_PAUSE));
+        else if (target == mSkipButton)
+            startService(new Intent(MusicService.ACTION_SKIP));
+        else if (target == mRewindButton)
+            startService(new Intent(MusicService.ACTION_REWIND));
+        else if (target == mStopButton)
+            startService(new Intent(MusicService.ACTION_STOP));
+        else if (target == mEjectButton) {
+            showUrlDialog();
+        }
+    }
+
+    /** 
+     * Shows an alert dialog where the user can input a URL. After showing the dialog, if the user
+     * confirms, sends the appropriate intent to the {@link MusicService} to cause that URL to be
+     * played.
+     */
+    void showUrlDialog() {
+        AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
+        alertBuilder.setTitle("Manual Input");
+        alertBuilder.setMessage("Enter a URL (must be http://)");
+        final EditText input = new EditText(this);
+        alertBuilder.setView(input);
+
+        input.setText(SUGGESTED_URL);
+
+        alertBuilder.setPositiveButton("Play!", new DialogInterface.OnClickListener() {
+            public void onClick(DialogInterface dlg, int whichButton) {
+                // Send an intent with the URL of the song to play. This is expected by
+                // MusicService.
+                Intent i = new Intent(MusicService.ACTION_URL);
+                Uri uri = Uri.parse(input.getText().toString());
+                i.setData(uri);
+                startService(i);
+            }
+        });
+        alertBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+            public void onClick(DialogInterface dlg, int whichButton) {}
+        });
+
+        alertBuilder.show();
+    }
+}
diff --git a/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MusicFocusable.java b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MusicFocusable.java
new file mode 100644
index 0000000..aea8b49
--- /dev/null
+++ b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MusicFocusable.java
@@ -0,0 +1,35 @@
+/*   
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.musicplayer;
+
+/**
+ * Represents something that can react to audio focus events. We implement this instead of just
+ * using AudioManager.OnAudioFocusChangeListener because that interface is only available in SDK
+ * level 8 and above, and we want our application to work on previous SDKs.
+ */
+public interface MusicFocusable {
+    /** Signals that audio focus was gained. */
+    public void onGainedAudioFocus();
+
+    /**
+     * Signals that audio focus was lost.
+     *
+     * @param canDuck If true, audio can continue in "ducked" mode (low volume). Otherwise, all
+     * audio must stop.
+     */
+    public void onLostAudioFocus(boolean canDuck);
+}
diff --git a/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MusicIntentReceiver.java b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MusicIntentReceiver.java
new file mode 100644
index 0000000..cc03d5e
--- /dev/null
+++ b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MusicIntentReceiver.java
@@ -0,0 +1,40 @@
+/*   
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.musicplayer;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.widget.Toast;
+
+/**
+ * Receives broadcasted intents. In particular, we are interested in the
+ * android.media.AUDIO_BECOMING_NOISY intent, which is broadcast, for example, when the user
+ * disconnects the headphones. This class works because we are declaring it in a &lt;receiver&gt;
+ * tag in AndroidManifest.xml.
+ */
+public class MusicIntentReceiver extends BroadcastReceiver {
+    @Override
+    public void onReceive(Context ctx, Intent intent) {
+        if (intent.getAction().equals(android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY)) {
+            Toast.makeText(ctx, "Headphones disconnected.", Toast.LENGTH_SHORT).show();
+
+            // send an intent to our MusicService to telling it to pause the audio
+            ctx.startService(new Intent(MusicService.ACTION_PAUSE));
+        }
+    }
+}
diff --git a/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MusicRetriever.java b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MusicRetriever.java
new file mode 100644
index 0000000..44d6447
--- /dev/null
+++ b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MusicRetriever.java
@@ -0,0 +1,118 @@
+/*   
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.musicplayer;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import android.content.ContentResolver;
+import android.content.ContentUris;
+import android.database.Cursor;
+import android.net.Uri;
+import android.util.Log;
+
+/**
+ * Retrieves and organizes media to play. Before being used, you must call {@link #prepare()},
+ * which will retrieve all of the music on the user's device (by performing a query on a content
+ * resolver). After that, it's ready to retrieve a random song, with its title and URI, upon
+ * request.
+ */
+public class MusicRetriever {
+    final String TAG = "MusicRetriever";
+
+    ContentResolver mContentResolver;
+
+    // the items (songs) we have queried
+    List<Item> mItems = new ArrayList<Item>();
+
+    Random mRandom = new Random();
+
+    public MusicRetriever(ContentResolver cr) {
+        mContentResolver = cr;
+    }
+
+    /**
+     * Loads music data. This method may take long, so be sure to call it asynchronously without
+     * blocking the main thread.
+     */
+    public void prepare() {
+        Uri uri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
+        Log.i(TAG, "Querying media...");
+        Log.i(TAG, "URI: " + uri.toString());
+
+        // Perform a query on the content resolver. The URI we're passing specifies that we
+        // want to query for all audio media on external storage (e.g. SD card)
+        Cursor cur = mContentResolver.query(uri, null, null, null, null);
+        Log.i(TAG, "Query finished. " + (cur == null ? "Returned NULL." : "Returned a cursor."));
+
+        if (cur == null) {
+            // Query failed...
+            Log.e(TAG, "Failed to retrieve music: cursor is null :-(");
+            return;
+        }
+        if (!cur.moveToFirst()) {
+            // Nothing to query. There is no music on the device. How boring.
+            Log.e(TAG, "Failed to move cursor to first row (no query results).");
+            return;
+        }
+
+        Log.i(TAG, "Listing...");
+
+        // retrieve the indices of the columns where the ID and title of the song are
+        int titleColumn = cur.getColumnIndex(android.provider.MediaStore.Audio.Media.TITLE);
+        int idColumn = cur.getColumnIndex(android.provider.MediaStore.Audio.Media._ID);
+
+        Log.i(TAG, "Title column index: " + String.valueOf(titleColumn));
+        Log.i(TAG, "ID column index: " + String.valueOf(titleColumn));
+
+        // add each song to mItems
+        do {
+            Log.i(TAG, "ID: " + cur.getString(idColumn) + " Title: " + cur.getString(titleColumn));
+            mItems.add(new Item(cur.getLong(idColumn), cur.getString(titleColumn)));
+        } while (cur.moveToNext());
+
+        Log.i(TAG, "Done querying media. MusicRetriever is ready.");
+    }
+
+    public ContentResolver getContentResolver() {
+        return mContentResolver;
+    }
+
+    /** Returns a random Item. If there are no items available, returns null. */
+    public Item getRandomItem() {
+        if (mItems.size() <= 0) return null;
+        return mItems.get(mRandom.nextInt(mItems.size()));
+    }
+
+    public class Item {
+        long id;
+        String title;
+
+        public Item(long id, String title) {
+            this.id = id;
+            this.title = title;
+        }
+
+        public long getId() { return id; }
+        public String getTitle() { return title; }
+        public Uri getURI() {
+            return ContentUris.withAppendedId(
+                    android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, id);
+        }
+    }
+}
diff --git a/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MusicService.java b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MusicService.java
new file mode 100644
index 0000000..9bd1251
--- /dev/null
+++ b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/MusicService.java
@@ -0,0 +1,511 @@
+/*   
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.musicplayer;
+
+import java.io.IOException;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.media.AudioManager;
+import android.media.MediaPlayer;
+import android.media.MediaPlayer.OnCompletionListener;
+import android.media.MediaPlayer.OnErrorListener;
+import android.media.MediaPlayer.OnPreparedListener;
+import android.net.Uri;
+import android.net.wifi.WifiManager;
+import android.net.wifi.WifiManager.WifiLock;
+import android.os.IBinder;
+import android.os.PowerManager;
+import android.util.Log;
+import android.widget.Toast;
+
+/**
+ * Service that handles media playback. This is the Service through which we perform all the media
+ * handling in our application. Upon initialization, it starts a {@link MediaRetriever} to scan
+ * the user's media. Then, it waits for Intents (which come from our main activity,
+ * {@link MainActivity}, which signal the service to perform specific operations: Play, Pause,
+ * Rewind, Skip, etc.
+ */
+public class MusicService extends Service implements OnCompletionListener, OnPreparedListener,
+                OnErrorListener, MusicFocusable,
+                PrepareMusicRetrieverTask.MusicRetrieverPreparedListener {
+
+    NotificationManager mNotificationManager;
+
+    // our media player
+    MediaPlayer mPlayer = null;
+
+    // our AudioFocusHelper object, if it's available (it's available on SDK level >= 8)
+    // If not available, this will be null. Always check for null before using!
+    AudioFocusHelper mAudioFocusHelper = null;
+
+    // indicates the state our service:
+    enum State {
+        Retrieving, // the MediaRetriever is retrieving music
+        Stopped,    // media player is stopped and not prepared to play
+        Preparing,  // media player is preparing...
+        Playing,    // playback active (media player ready!). (but the media player may actually be
+                    // paused in this state if we don't have audio focus. But we stay in this state
+                    // so that we know we have to resume playback once we get focus back)
+        Paused      // playback paused (media player ready!)
+    };
+
+    State mState = State.Retrieving;
+
+    // if in Retrieving mode, this flag indicates whether we should start playing immediately
+    // when we are ready or not.
+    boolean mStartPlayingAfterRetrieve = false;
+
+    // if mStartPlayingAfterRetrieve is true, this variable indicates the URL that we should
+    // start playing when we are ready. If null, we should play a random song from the device
+    Uri mWhatToPlayAfterRetrieve = null;
+
+    enum PauseReason {
+        UserRequest,  // paused by user request
+        FocusLoss,    // paused because of audio focus loss
+    };
+
+    // why did we pause? (only relevant if mState == State.Paused)
+    PauseReason mPauseReason = PauseReason.UserRequest;
+
+    // do we have audio focus?
+    enum AudioFocus {
+        NoFocusNoDuck,    // we don't have audio focus, and can't duck
+        NoFocusCanDuck,   // we don't have focus, but can play at a low volume ("ducking")
+        Focused           // we have full audio focus
+    }
+    AudioFocus mAudioFocus = AudioFocus.NoFocusNoDuck;
+
+    // title of the song we are currently playing
+    String mSongTitle = "";
+
+    // whether the song we are playing is streaming from the network
+    boolean mIsStreaming = false;
+
+    // Wifi lock that we hold when streaming files from the internet, in order to prevent the
+    // device from shutting off the Wifi radio
+    WifiLock mWifiLock;
+
+    // The tag we put on debug messages
+    final static String TAG = "RandomMusicPlayer";
+
+    // These are the Intent actions that we are prepared to handle. Notice that the fact these
+    // constants exist in our class is a mere convenience: what really defines the actions our
+    // service can handle are the <action> tags in the <intent-filters> tag for our service in
+    // AndroidManifest.xml.
+    public static final String ACTION_PLAY = "com.example.android.musicplayer.action.PLAY";
+    public static final String ACTION_PAUSE = "com.example.android.musicplayer.action.PAUSE";
+    public static final String ACTION_STOP = "com.example.android.musicplayer.action.STOP";
+    public static final String ACTION_SKIP = "com.example.android.musicplayer.action.SKIP";
+    public static final String ACTION_REWIND = "com.example.android.musicplayer.action.REWIND";
+    public static final String ACTION_URL = "com.example.android.musicplayer.action.URL";
+
+    // The volume we set the media player to when we lose audio focus, but are allowed to reduce
+    // the volume instead of stopping playback.
+    public final float DUCK_VOLUME = 0.1f;
+
+    // The ID we use for the notification (the onscreen alert that appears at the notification
+    // area at the top of the screen as an icon -- and as text as well if the user expands the
+    // notification area).
+    final int NOTIFICATION_ID = 1;
+
+    // Our instance of our MusicRetriever, which handles scanning for media and
+    // providing titles and URIs as we need.
+    MusicRetriever mRetriever;
+
+    Notification mNotification = null;
+
+    /**
+     * Makes sure the media player exists and has been reset. This will create the media player
+     * if needed, or reset the existing media player if one already exists.
+     */
+    void createMediaPlayerIfNeeded() {
+        if (mPlayer == null) {
+            mPlayer = new MediaPlayer();
+
+            // Make sure the media player will acquire a wake-lock while playing. If we don't do
+            // that, the CPU might go to sleep while the song is playing, causing playback to stop.
+            //
+            // Remember that to use this, we have to declare the android.permission.WAKE_LOCK
+            // permission in AndroidManifest.xml.
+            mPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);
+
+            // we want the media player to notify us when it's ready preparing, and when it's done
+            // playing:
+            mPlayer.setOnPreparedListener(this);
+            mPlayer.setOnCompletionListener(this);
+            mPlayer.setOnErrorListener(this);
+        }
+        else
+            mPlayer.reset();
+    }
+
+    @Override
+    public void onCreate() {
+        Log.i(TAG, "debug: Creating service");
+
+        // Create the Wifi lock (this does not acquire the lock, this just creates it)
+        mWifiLock = ((WifiManager) getSystemService(Context.WIFI_SERVICE))
+                        .createWifiLock(WifiManager.WIFI_MODE_FULL, "mylock");
+
+        mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+
+        // Create the retriever and start an asynchronous task that will prepare it.
+        mRetriever = new MusicRetriever(getContentResolver());
+        (new PrepareMusicRetrieverTask(mRetriever,this)).execute();
+
+        // create the Audio Focus Helper, if the Audio Focus feature is available (SDK 8 or above)
+        if (android.os.Build.VERSION.SDK_INT >= 8)
+            mAudioFocusHelper = new AudioFocusHelper(getApplicationContext(), this);
+        else
+            mAudioFocus = AudioFocus.Focused; // no focus feature, so we always "have" audio focus
+    }
+
+    /**
+     * Called when we receive an Intent. When we receive an intent sent to us via startService(),
+     * this is the method that gets called. So here we react appropriately depending on the
+     * Intent's action, which specifies what is being requested of us.
+     */
+    @Override
+    public int onStartCommand(Intent intent, int flags, int startId) {
+        String action = intent.getAction();
+        if (action.equals(ACTION_PLAY)) processPlayRequest();
+        else if (action.equals(ACTION_PAUSE)) processPauseRequest();
+        else if (action.equals(ACTION_SKIP)) processSkipRequest();
+        else if (action.equals(ACTION_STOP)) processStopRequest();
+        else if (action.equals(ACTION_REWIND)) processRewindRequest();
+        else if (action.equals(ACTION_URL)) processAddRequest(intent);
+
+        return START_NOT_STICKY; // Means we started the service, but don't want it to
+                                 // restart in case it's killed.
+    }
+
+    void processPlayRequest() {
+        if (mState == State.Retrieving) {
+            // If we are still retrieving media, just set the flag to start playing when we're
+            // ready
+            mWhatToPlayAfterRetrieve = null; // play a random song
+            mStartPlayingAfterRetrieve = true;
+            return;
+        }
+
+        tryToGetAudioFocus();
+
+        if (mState == State.Stopped) {
+            // If we're stopped, just go ahead to the next song and start playing
+            playNextSong(null);
+        }
+        else if (mState == State.Paused) {
+            // If we're paused, just continue playback and restore the 'foreground service' state.
+            mState = State.Playing;
+            setUpAsForeground(mSongTitle + " (playing)");
+            configAndStartMediaPlayer();
+        }
+    }
+
+    void processPauseRequest() {
+        if (mState == State.Retrieving) {
+            // If we are still retrieving media, clear the flag that indicates we should start
+            // playing when we're ready
+            mStartPlayingAfterRetrieve = false;
+            return;
+        }
+
+        if (mState == State.Playing) {
+            // Pause media player and cancel the 'foreground service' state.
+            mState = State.Paused;
+            mPlayer.pause();
+            relaxResources(false); // while paused, we always retain the MediaPlayer
+            giveUpAudioFocus();
+        }
+    }
+
+    void processRewindRequest() {
+        if (mState == State.Playing || mState == State.Paused)
+            mPlayer.seekTo(0);
+    }
+
+    void processSkipRequest() {
+        if (mState == State.Playing || mState == State.Paused) {
+            tryToGetAudioFocus();
+            playNextSong(null);
+        }
+    }
+
+    void processStopRequest() {
+        if (mState == State.Playing || mState == State.Paused) {
+            mState = State.Stopped;
+
+            // let go of all resources...
+            relaxResources(true);
+            giveUpAudioFocus();
+
+            // service is no longer necessary. Will be started again if needed.
+            stopSelf();
+        }
+    }
+
+    /**
+     * Releases resources used by the service for playback. This includes the "foreground service"
+     * status and notification, the wake locks and possibly the MediaPlayer.
+     *
+     * @param releaseMediaPlayer Indicates whether the Media Player should also be released or not
+     */
+    void relaxResources(boolean releaseMediaPlayer) {
+        // stop being a foreground service
+        stopForeground(true);
+
+        // stop and release the Media Player, if it's available
+        if (releaseMediaPlayer && mPlayer != null) {
+            mPlayer.reset();
+            mPlayer.release();
+            mPlayer = null;
+        }
+
+        // we can also release the Wifi lock, if we're holding it
+        if (mWifiLock.isHeld()) mWifiLock.release();
+    }
+
+    void giveUpAudioFocus() {
+        if (mAudioFocus == AudioFocus.Focused && mAudioFocusHelper != null
+                                && mAudioFocusHelper.abandonFocus())
+            mAudioFocus = AudioFocus.NoFocusNoDuck;
+    }
+
+    /**
+     * Reconfigures MediaPlayer according to audio focus settings and starts/restarts it. This
+     * method starts/restarts the MediaPlayer respecting the current audio focus state. So if
+     * we have focus, it will play normally; if we don't have focus, it will either leave the
+     * MediaPlayer paused or set it to a low volume, depending on what is allowed by the
+     * current focus settings. This method assumes mPlayer != null, so if you are calling it,
+     * you have to do so from a context where you are sure this is the case.
+     */
+    void configAndStartMediaPlayer() {
+        if (mAudioFocus == AudioFocus.NoFocusNoDuck) {
+            // If we don't have audio focus and can't duck, we have to pause, even if mState
+            // is State.Playing. But we stay in the Playing state so that we know we have to resume
+            // playback once we get the focus back.
+            if (mPlayer.isPlaying()) mPlayer.pause();
+            return;
+        }
+        else if (mAudioFocus == AudioFocus.NoFocusCanDuck)
+            mPlayer.setVolume(DUCK_VOLUME, DUCK_VOLUME);  // we'll be relatively quiet
+        else
+            mPlayer.setVolume(1.0f, 1.0f); // we can be loud
+
+        if (!mPlayer.isPlaying()) mPlayer.start();
+    }
+
+    void processAddRequest(Intent intent) {
+        // user wants to play a song directly by URL or path. The URL or path comes in the "data"
+        // part of the Intent. This Intent is sent by {@link MainActivity} after the user
+        // specifies the URL/path via an alert box.
+        if (mState == State.Retrieving) {
+            // we'll play the requested URL right after we finish retrieving
+            mWhatToPlayAfterRetrieve = intent.getData();
+            mStartPlayingAfterRetrieve = true;
+        }
+        else if (mState == State.Playing || mState == State.Paused || mState == State.Stopped) {
+            Log.i(TAG, "Playing from URL/path: " + intent.getData().toString());
+            tryToGetAudioFocus();
+            playNextSong(intent.getData().toString());
+        }
+    }
+
+    /**
+     * Shortcut to making and displaying a toast. Seemed cleaner than repeating
+     * this code everywhere, at least for this sample.
+     */
+    void say(String message) {
+        Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
+    }
+
+    void tryToGetAudioFocus() {
+        if (mAudioFocus != AudioFocus.Focused && mAudioFocusHelper != null
+                        && mAudioFocusHelper.requestFocus())
+            mAudioFocus = AudioFocus.Focused;
+    }
+
+    /**
+     * Starts playing the next song. If manualUrl is null, the next song will be randomly selected
+     * from our Media Retriever (that is, it will be a random song in the user's device). If
+     * manualUrl is non-null, then it specifies the URL or path to the song that will be played
+     * next.
+     */
+    void playNextSong(String manualUrl) {
+        mState = State.Stopped;
+        relaxResources(false); // release everything except MediaPlayer
+
+        try {
+            if (manualUrl != null) {
+                // set the source of the media player to a manual URL or path
+                createMediaPlayerIfNeeded();
+                mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
+                mPlayer.setDataSource(manualUrl);
+                mSongTitle = manualUrl;
+                mIsStreaming = manualUrl.startsWith("http:") || manualUrl.startsWith("https:");
+            }
+            else {
+                mIsStreaming = false; // playing a locally available song
+
+                MusicRetriever.Item item = mRetriever.getRandomItem();
+                if (item == null) {
+                    say("No song to play :-(");
+                    return;
+                }
+
+                // set the source of the media player a a content URI
+                createMediaPlayerIfNeeded();
+                mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
+                mPlayer.setDataSource(getApplicationContext(), item.getURI());
+                mSongTitle = item.getTitle();
+            }
+
+
+            mState = State.Preparing;
+            setUpAsForeground(mSongTitle + " (loading)");
+
+            // starts preparing the media player in the background. When it's done, it will call
+            // our OnPreparedListener (that is, the onPrepared() method on this class, since we set
+            // the listener to 'this').
+            //
+            // Until the media player is prepared, we *cannot* call start() on it!
+            mPlayer.prepareAsync();
+
+            // If we are streaming from the internet, we want to hold a Wifi lock, which prevents
+            // the Wifi radio from going to sleep while the song is playing. If, on the other hand,
+            // we are *not* streaming, we want to release the lock if we were holding it before.
+            if (mIsStreaming) mWifiLock.acquire();
+            else if (mWifiLock.isHeld()) mWifiLock.release();
+        }
+        catch (IOException ex) {
+            Log.e("MusicService", "IOException playing next song: " + ex.getMessage());
+            ex.printStackTrace();
+        }
+    }
+
+    /** Called when media player is done playing current song. */
+    @Override
+    public void onCompletion(MediaPlayer player) {
+        // The media player finished playing the current song, so we go ahead and start the next.
+        playNextSong(null);
+    }
+
+    /** Called when media player is done preparing. */
+    @Override
+    public void onPrepared(MediaPlayer player) {
+        // The media player is done preparing. That means we can start playing!
+        mState = State.Playing;
+        updateNotification(mSongTitle + " (playing)");
+        configAndStartMediaPlayer();
+    }
+
+    /** Updates the notification. */
+    void updateNotification(String text) {
+        PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0,
+                new Intent(getApplicationContext(), MainActivity.class),
+                PendingIntent.FLAG_UPDATE_CURRENT);
+        mNotification.setLatestEventInfo(getApplicationContext(), "RandomMusicPlayer", text, pi);
+        mNotificationManager.notify(NOTIFICATION_ID, mNotification);
+    }
+
+    /**
+     * Configures service as a foreground service. A foreground service is a service that's doing
+     * something the user is actively aware of (such as playing music), and must appear to the
+     * user as a notification. That's why we create the notification here.
+     */
+    void setUpAsForeground(String text) {
+        PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0,
+                new Intent(getApplicationContext(), MainActivity.class),
+                PendingIntent.FLAG_UPDATE_CURRENT);
+        mNotification = new Notification();
+        mNotification.tickerText = text;
+        mNotification.icon = R.drawable.ic_stat_playing;
+        mNotification.flags |= Notification.FLAG_ONGOING_EVENT;
+        mNotification.setLatestEventInfo(getApplicationContext(), "RandomMusicPlayer",
+                text, pi);
+        startForeground(NOTIFICATION_ID, mNotification);
+    }
+
+    /**
+     * Called when there's an error playing media. When this happens, the media player goes to
+     * the Error state. We warn the user about the error and reset the media player.
+     */
+    @Override
+    public boolean onError(MediaPlayer mp, int what, int extra) {
+        Toast.makeText(getApplicationContext(), "Media player error! Resetting.",
+            Toast.LENGTH_SHORT).show();
+        Log.e(TAG, "Error: what=" + String.valueOf(what) + ", extra=" + String.valueOf(extra));
+
+        mState = State.Stopped;
+        relaxResources(true);
+        giveUpAudioFocus();
+        return true; // true indicates we handled the error
+    }
+
+    @Override
+    public void onGainedAudioFocus() {
+        Toast.makeText(getApplicationContext(), "gained audio focus.", Toast.LENGTH_SHORT).show();
+        mAudioFocus = AudioFocus.Focused;
+
+        // restart media player with new focus settings
+        if (mState == State.Playing)
+            configAndStartMediaPlayer();
+    }
+
+    @Override
+    public void onLostAudioFocus(boolean canDuck) {
+        Toast.makeText(getApplicationContext(), "lost audio focus." + (canDuck ? "can duck" :
+            "no duck"), Toast.LENGTH_SHORT).show();
+        mAudioFocus = canDuck ? AudioFocus.NoFocusCanDuck : AudioFocus.NoFocusNoDuck;
+
+        // start/restart/pause media player with new focus settings
+        if (mPlayer != null && mPlayer.isPlaying())
+            configAndStartMediaPlayer();
+    }
+
+    @Override
+    public void onMusicRetrieverPrepared() {
+        // Done retrieving!
+        mState = State.Stopped;
+
+        // If the flag indicates we should start playing after retrieving, let's do that now.
+        if (mStartPlayingAfterRetrieve) {
+            tryToGetAudioFocus();
+            playNextSong(mWhatToPlayAfterRetrieve == null ?
+                    null : mWhatToPlayAfterRetrieve.toString());
+        }
+    }
+
+
+    @Override
+    public void onDestroy() {
+        // Service is being killed, so make sure we release our resources
+        mState = State.Stopped;
+        relaxResources(true);
+        giveUpAudioFocus();
+    }
+
+    @Override
+    public IBinder onBind(Intent arg0) {
+        return null;
+    }
+}
diff --git a/samples/RandomMusicPlayer/src/com/example/android/musicplayer/PrepareMusicRetrieverTask.java b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/PrepareMusicRetrieverTask.java
new file mode 100644
index 0000000..fd114c8
--- /dev/null
+++ b/samples/RandomMusicPlayer/src/com/example/android/musicplayer/PrepareMusicRetrieverTask.java
@@ -0,0 +1,50 @@
+/*   
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.musicplayer;
+
+import android.os.AsyncTask;
+
+/**
+ * Asynchronous task that prepares a MusicRetriever. This asynchronous task essentially calls
+ * {@link MusicRetriever#prepare()} on a {@link MusicRetriever}, which may take some time to
+ * run. Upon finishing, it notifies the indicated {@MusicRetrieverPreparedListener}.
+ */
+public class PrepareMusicRetrieverTask extends AsyncTask<Void, Void, Void> {
+    MusicRetriever mRetriever;
+    MusicRetrieverPreparedListener mListener;
+
+    public PrepareMusicRetrieverTask(MusicRetriever retriever,
+            MusicRetrieverPreparedListener listener) {
+        mRetriever = retriever;
+        mListener = listener;
+    }
+
+    @Override
+    protected Void doInBackground(Void... arg0) {
+        mRetriever.prepare();
+        return null;
+    }
+
+    @Override
+    protected void onPostExecute(Void result) {
+        mListener.onMusicRetrieverPrepared();
+    }
+
+    public interface MusicRetrieverPreparedListener {
+        public void onMusicRetrieverPrepared();
+    }
+}
diff --git a/samples/StackWidget/res/xml/stackwidgetinfo.xml b/samples/StackWidget/res/xml/stackwidgetinfo.xml
index 8c2630f..6f59605 100644
--- a/samples/StackWidget/res/xml/stackwidgetinfo.xml
+++ b/samples/StackWidget/res/xml/stackwidgetinfo.xml
@@ -20,5 +20,6 @@
   android:updatePeriodMillis="3600000"
   android:previewImage="@drawable/preview"
   android:initialLayout="@layout/widget_layout"
-  android:autoAdvanceViewId="@id/stack_view">
-</appwidget-provider>
\ No newline at end of file
+  android:autoAdvanceViewId="@id/stack_view"
+  android:resizeMode="horizontal|vertical">
+</appwidget-provider>
diff --git a/samples/Support13Demos/AndroidManifest.xml b/samples/Support13Demos/AndroidManifest.xml
index e54bf7f..bc32d09 100644
--- a/samples/Support13Demos/AndroidManifest.xml
+++ b/samples/Support13Demos/AndroidManifest.xml
@@ -26,7 +26,10 @@
 
     <uses-sdk android:minSdkVersion="13" />
 
-    <!-- This app has not been optimized for large screens. -->
+    <!-- The smallest screen this app works on is a phone.  The app will
+         scale its UI to larger screens but doesn't make good use of them
+         so allow the compatibility mode button to be shown (mostly because
+         this is just convenient for testing). -->
     <supports-screens android:requiresSmallestWidthDp="320"
             android:compatibleWidthLimitDp="480" />
 
@@ -60,5 +63,13 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".app.ActionBarTabsPager"
+                android:label="@string/action_bar_tabs_pager">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.example.android.supportv13.SUPPORT13_SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+
     </application>
 </manifest>
diff --git a/samples/Support13Demos/_index.html b/samples/Support13Demos/_index.html
index d6168ab..f913a99 100644
--- a/samples/Support13Demos/_index.html
+++ b/samples/Support13Demos/_index.html
@@ -1,8 +1,8 @@
-<p>The Support v4 Demos application contains a variety of small sample
-code showing how to use key features of the support library.
+<p>The Support v13 Demos application contains a variety of small sample
+code showing how to use key features of the Android API 13+ Support Library.
 This library contains code that you can
 build in to your application to access new features and common
-utilities while being able to run down to version 1.6 (API 4)
+utilities while being able to run down to version 3.2 (API 13)
 of the platform.
 </p>
 
@@ -19,7 +19,7 @@
 "together. Current samples are only for the fragment and loader in the "+
 "application part of the support library:</p>"+
 
-"<ul><li><a href='src/com/example/android/supportv4/app/index.html'>App</a></li></ul>");
+"<ul><li><a href='src/com/example/android/supportv13/app/index.html'>App</a></li></ul>");
 
 }
 
diff --git a/samples/Support13Demos/res/layout/fragment_pager.xml b/samples/Support13Demos/res/layout/fragment_pager.xml
index cc07d84..46c8cbe 100644
--- a/samples/Support13Demos/res/layout/fragment_pager.xml
+++ b/samples/Support13Demos/res/layout/fragment_pager.xml
@@ -21,12 +21,12 @@
         android:gravity="center_horizontal"
         android:layout_width="match_parent" android:layout_height="match_parent">
 
-    <android.support.v13.view.ViewPager
+    <android.support.v4.view.ViewPager
             android:id="@+id/pager"
             android:layout_width="match_parent"
             android:layout_height="0px"
             android:layout_weight="1">
-    </android.support.v13.view.ViewPager>
+    </android.support.v4.view.ViewPager>
 
     <LinearLayout android:orientation="horizontal"
             android:gravity="center" android:measureWithLargestChild="true"
diff --git a/samples/Support13Demos/res/values/strings.xml b/samples/Support13Demos/res/values/strings.xml
index 818597c..2fd12d4 100644
--- a/samples/Support13Demos/res/values/strings.xml
+++ b/samples/Support13Demos/res/values/strings.xml
@@ -29,4 +29,5 @@
 
     <string name="fragment_state_pager_support">Fragment/State Pager</string>
 
+    <string name="action_bar_tabs_pager">Fragment/Action Bar Tabs Pager</string>
 </resources>
diff --git a/samples/Support13Demos/src/com/example/android/supportv13/app/ActionBarTabsPager.java b/samples/Support13Demos/src/com/example/android/supportv13/app/ActionBarTabsPager.java
new file mode 100644
index 0000000..433f7e9
--- /dev/null
+++ b/samples/Support13Demos/src/com/example/android/supportv13/app/ActionBarTabsPager.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.example.android.supportv13.app;
+
+import java.util.ArrayList;
+
+import com.example.android.supportv13.R;
+
+import android.app.ActionBar;
+import android.app.ActionBar.Tab;
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.FragmentTransaction;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v13.app.FragmentPagerAdapter;
+import android.support.v4.view.ViewPager;
+
+/**
+ * This demonstrates the use of action bar tabs and how they interact
+ * with other action bar features.
+ */
+public class ActionBarTabsPager extends Activity {
+    ViewPager mViewPager;
+    TabsAdapter mTabsAdapter;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mViewPager = new ViewPager(this);
+        mViewPager.setId(R.id.pager);
+        setContentView(mViewPager);
+
+        final ActionBar bar = getActionBar();
+        bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+        bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
+
+        mTabsAdapter = new TabsAdapter(this, mViewPager);
+        mTabsAdapter.addTab(bar.newTab().setText("Simple"),
+                CountingFragment.class, null);
+        mTabsAdapter.addTab(bar.newTab().setText("List"),
+                FragmentPagerSupport.ArrayListFragment.class, null);
+        mTabsAdapter.addTab(bar.newTab().setText("Cursor"),
+                CursorFragment.class, null);
+
+        if (savedInstanceState != null) {
+            bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
+        }
+    }
+
+    @Override
+    protected void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putInt("tab", getActionBar().getSelectedNavigationIndex());
+    }
+
+    /**
+     * This is a helper class that implements the management of tabs and all
+     * details of connecting a ViewPager with associated TabHost.  It relies on a
+     * trick.  Normally a tab host has a simple API for supplying a View or
+     * Intent that each tab will show.  This is not sufficient for switching
+     * between pages.  So instead we make the content part of the tab host
+     * 0dp high (it is not shown) and the TabsAdapter supplies its own dummy
+     * view to show as the tab content.  It listens to changes in tabs, and takes
+     * care of switch to the correct paged in the ViewPager whenever the selected
+     * tab changes.
+     */
+    public static class TabsAdapter extends FragmentPagerAdapter
+            implements ActionBar.TabListener, ViewPager.OnPageChangeListener {
+        private final Context mContext;
+        private final ActionBar mActionBar;
+        private final ViewPager mViewPager;
+        private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
+
+        static final class TabInfo {
+            private final Class<?> clss;
+            private final Bundle args;
+
+            TabInfo(Class<?> _class, Bundle _args) {
+                clss = _class;
+                args = _args;
+            }
+        }
+
+        public TabsAdapter(Activity activity, ViewPager pager) {
+            super(activity.getFragmentManager());
+            mContext = activity;
+            mActionBar = activity.getActionBar();
+            mViewPager = pager;
+            mViewPager.setAdapter(this);
+            mViewPager.setOnPageChangeListener(this);
+        }
+
+        public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
+            TabInfo info = new TabInfo(clss, args);
+            tab.setTag(info);
+            tab.setTabListener(this);
+            mTabs.add(info);
+            mActionBar.addTab(tab);
+            notifyDataSetChanged();
+        }
+
+        @Override
+        public int getCount() {
+            return mTabs.size();
+        }
+
+        @Override
+        public Fragment getItem(int position) {
+            TabInfo info = mTabs.get(position);
+            return Fragment.instantiate(mContext, info.clss.getName(), info.args);
+        }
+
+        @Override
+        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+        }
+
+        @Override
+        public void onPageSelected(int position) {
+            mActionBar.setSelectedNavigationItem(position);
+        }
+
+        @Override
+        public void onPageScrollStateChanged(int state) {
+        }
+
+        @Override
+        public void onTabSelected(Tab tab, FragmentTransaction ft) {
+            Object tag = tab.getTag();
+            for (int i=0; i<mTabs.size(); i++) {
+                if (mTabs.get(i) == tag) {
+                    mViewPager.setCurrentItem(i);
+                }
+            }
+        }
+
+        @Override
+        public void onTabUnselected(Tab tab, FragmentTransaction ft) {
+        }
+
+        @Override
+        public void onTabReselected(Tab tab, FragmentTransaction ft) {
+        }
+    }
+}
diff --git a/samples/Support13Demos/src/com/example/android/supportv13/app/CountingFragment.java b/samples/Support13Demos/src/com/example/android/supportv13/app/CountingFragment.java
new file mode 100644
index 0000000..8672ed2
--- /dev/null
+++ b/samples/Support13Demos/src/com/example/android/supportv13/app/CountingFragment.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.example.android.supportv13.app;
+
+import com.example.android.supportv13.R;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+public class CountingFragment extends Fragment {
+    int mNum;
+
+    /**
+     * Create a new instance of CountingFragment, providing "num"
+     * as an argument.
+     */
+    static CountingFragment newInstance(int num) {
+        CountingFragment f = new CountingFragment();
+
+        // Supply num input as an argument.
+        Bundle args = new Bundle();
+        args.putInt("num", num);
+        f.setArguments(args);
+
+        return f;
+    }
+
+    /**
+     * When creating, retrieve this instance's number from its arguments.
+     */
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mNum = getArguments() != null ? getArguments().getInt("num") : 1;
+    }
+
+    /**
+     * The Fragment's UI is just a simple text view showing its
+     * instance number.
+     */
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        View v = inflater.inflate(R.layout.hello_world, container, false);
+        View tv = v.findViewById(R.id.text);
+        ((TextView)tv).setText("Fragment #" + mNum);
+        tv.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.gallery_thumb));
+        return v;
+    }
+}
diff --git a/samples/Support13Demos/src/com/example/android/supportv13/app/CursorFragment.java b/samples/Support13Demos/src/com/example/android/supportv13/app/CursorFragment.java
new file mode 100644
index 0000000..38be247
--- /dev/null
+++ b/samples/Support13Demos/src/com/example/android/supportv13/app/CursorFragment.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.supportv13.app;
+
+import android.app.ListFragment;
+import android.app.LoaderManager;
+import android.content.CursorLoader;
+import android.content.Loader;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+import android.provider.ContactsContract.Contacts;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.ListView;
+import android.widget.SearchView;
+import android.widget.SimpleCursorAdapter;
+import android.widget.SearchView.OnQueryTextListener;
+
+
+public class CursorFragment extends ListFragment
+        implements OnQueryTextListener, LoaderManager.LoaderCallbacks<Cursor> {
+
+    // This is the Adapter being used to display the list's data.
+    SimpleCursorAdapter mAdapter;
+
+    // If non-null, this is the current filter the user has provided.
+    String mCurFilter;
+
+    @Override public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+
+        // Give some text to display if there is no data.  In a real
+        // application this would come from a resource.
+        setEmptyText("No phone numbers");
+
+        // We have a menu item to show in action bar.
+        setHasOptionsMenu(true);
+
+        // Create an empty adapter we will use to display the loaded data.
+        mAdapter = new SimpleCursorAdapter(getActivity(),
+                android.R.layout.simple_list_item_2, null,
+                new String[] { Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS },
+                new int[] { android.R.id.text1, android.R.id.text2 }, 0);
+        setListAdapter(mAdapter);
+
+        // Start out with a progress indicator.
+        setListShown(false);
+
+        // Prepare the loader.  Either re-connect with an existing one,
+        // or start a new one.
+        getLoaderManager().initLoader(0, null, this);
+    }
+
+    @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+        // Place an action bar item for searching.
+        MenuItem item = menu.add("Search");
+        item.setIcon(android.R.drawable.ic_menu_search);
+        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+        SearchView sv = new SearchView(getActivity());
+        sv.setOnQueryTextListener(this);
+        item.setActionView(sv);
+    }
+
+    public boolean onQueryTextChange(String newText) {
+        // Called when the action bar search text has changed.  Update
+        // the search filter, and restart the loader to do a new query
+        // with this filter.
+        mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
+        getLoaderManager().restartLoader(0, null, this);
+        return true;
+    }
+
+    @Override public boolean onQueryTextSubmit(String query) {
+        // Don't care about this.
+        return true;
+    }
+
+    @Override public void onListItemClick(ListView l, View v, int position, long id) {
+        // Insert desired behavior here.
+        Log.i("FragmentComplexList", "Item clicked: " + id);
+    }
+
+    // These are the Contacts rows that we will retrieve.
+    static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] {
+        Contacts._ID,
+        Contacts.DISPLAY_NAME,
+        Contacts.CONTACT_STATUS,
+        Contacts.CONTACT_PRESENCE,
+        Contacts.PHOTO_ID,
+        Contacts.LOOKUP_KEY,
+    };
+
+    public Loader<Cursor> onCreateLoader(int id, Bundle args) {
+        // This is called when a new Loader needs to be created.  This
+        // sample only has one Loader, so we don't care about the ID.
+        // First, pick the base URI to use depending on whether we are
+        // currently filtering.
+        Uri baseUri;
+        if (mCurFilter != null) {
+            baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,
+                    Uri.encode(mCurFilter));
+        } else {
+            baseUri = Contacts.CONTENT_URI;
+        }
+
+        // Now create and return a CursorLoader that will take care of
+        // creating a Cursor for the data being displayed.
+        String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
+                + Contacts.HAS_PHONE_NUMBER + "=1) AND ("
+                + Contacts.DISPLAY_NAME + " != '' ))";
+        return new CursorLoader(getActivity(), baseUri,
+                CONTACTS_SUMMARY_PROJECTION, select, null,
+                Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
+    }
+
+    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+        // Swap the new cursor in.  (The framework will take care of closing the
+        // old cursor once we return.)
+        mAdapter.swapCursor(data);
+
+        // The list should now be shown.
+        if (isResumed()) {
+            setListShown(true);
+        } else {
+            setListShownNoAnimation(true);
+        }
+    }
+
+    public void onLoaderReset(Loader<Cursor> loader) {
+        // This is called when the last Cursor provided to onLoadFinished()
+        // above is about to be closed.  We need to make sure we are no
+        // longer using it.
+        mAdapter.swapCursor(null);
+    }
+}
diff --git a/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentPagerSupport.java b/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentPagerSupport.java
index fcb41cd..ae2f481 100644
--- a/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentPagerSupport.java
+++ b/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentPagerSupport.java
@@ -20,7 +20,7 @@
 import com.example.android.supportv13.R;
 
 import android.support.v13.app.FragmentPagerAdapter;
-import android.support.v13.view.ViewPager;
+import android.support.v4.view.ViewPager;
 
 import android.os.Bundle;
 import android.app.Activity;
diff --git a/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentStatePagerSupport.java b/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentStatePagerSupport.java
index e19bdf6..4e6ebda 100644
--- a/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentStatePagerSupport.java
+++ b/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentStatePagerSupport.java
@@ -20,7 +20,7 @@
 import com.example.android.supportv13.R;
 
 import android.support.v13.app.FragmentStatePagerAdapter;
-import android.support.v13.view.ViewPager;
+import android.support.v4.view.ViewPager;
 
 import android.os.Bundle;
 import android.app.Activity;
diff --git a/samples/Support13Demos/src/com/example/android/supportv13/app/_index.html b/samples/Support13Demos/src/com/example/android/supportv13/app/_index.html
index b00985e..832d60e 100644
--- a/samples/Support13Demos/src/com/example/android/supportv13/app/_index.html
+++ b/samples/Support13Demos/src/com/example/android/supportv13/app/_index.html
@@ -8,8 +8,19 @@
 
 <h3 id="Fragment">Fragment</h3>
 <dl>
+  <dt><a href="ActionBarTabsPager.html">Action Bar Tabs Pager</a></dt>
+  <dd>Demonstrates the use of fragments to implement switching between
+  ActionBar tabs, using a ViewPager to manager the fragments so that
+  the user can also fling left and right to switch tabs.</dd>
+
   <dt><a href="FragmentPagerSupport.html">Fragment Pager Support</a></dt>
-  <dd>A support class for using the framework Fragment APIs to build
-   a user interface where the user can fling left or right to switch
-   between fragments.</dd>
+  <dd>Demonstrates the use of the v4 support class ViewPager with a
+  FragmentPagerAdapter to build a user interface where the user can fling
+  left or right to switch between fragments.</dd>
+
+  <dt><a href="FragmentStatePagerSupport.html">Fragment State Pager Support</a></dt>
+  <dd>Demonstrates the use of the v4 support class ViewPager with a
+  FragmentStatePagerAdapter to build a user interface where the user can fling
+  left or right to switch between fragments.  This versions of the adapter
+  doesn't keep around the fragment instances that ViewPager has destroyed.</dd>
 </dl>
diff --git a/samples/Support4Demos/AndroidManifest.xml b/samples/Support4Demos/AndroidManifest.xml
index 772eb54..5c74954 100644
--- a/samples/Support4Demos/AndroidManifest.xml
+++ b/samples/Support4Demos/AndroidManifest.xml
@@ -24,9 +24,12 @@
 
     <uses-permission android:name="android.permission.READ_CONTACTS" />
 
-    <uses-sdk android:minSdkVersion="4" />
+    <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="13" />
 
-    <!-- This app has not been optimized for large screens. -->
+    <!-- The smallest screen this app works on is a phone.  The app will
+         scale its UI to larger screens but doesn't make good use of them
+         so allow the compatibility mode button to be shown (mostly because
+         this is just convenient for testing). -->
     <supports-screens android:requiresSmallestWidthDp="320"
             android:compatibleWidthLimitDp="480" />
 
@@ -147,6 +150,22 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".app.FragmentTabs"
+                android:label="@string/fragment_tabs">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.example.android.supportv4.SUPPORT4_SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name=".app.FragmentTabsPager"
+                android:label="@string/fragment_tabs_pager">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.example.android.supportv4.SUPPORT4_SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+
         <activity android:name=".app.FragmentPagerSupport"
                 android:label="@string/fragment_pager_support">
             <intent-filter>
@@ -155,6 +174,14 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".app.FragmentStatePagerSupport"
+                android:label="@string/fragment_state_pager_support">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.example.android.supportv4.SUPPORT4_SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+
         <activity android:name=".app.LoaderCursorSupport"
                 android:label="@string/loader_cursor_support">
             <intent-filter>
@@ -163,6 +190,14 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".app.LoaderCustomSupport"
+                android:label="@string/loader_custom_support">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.example.android.supportv4.SUPPORT4_SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+
         <activity android:name=".app.LoaderThrottleSupport"
                 android:label="@string/loader_throttle_support">
             <intent-filter>
diff --git a/samples/Support4Demos/_index.html b/samples/Support4Demos/_index.html
index d6168ab..2b03ca4 100644
--- a/samples/Support4Demos/_index.html
+++ b/samples/Support4Demos/_index.html
@@ -1,5 +1,5 @@
 <p>The Support v4 Demos application contains a variety of small sample
-code showing how to use key features of the support library.
+code showing how to use key features of the Android API 4+ Support Library.
 This library contains code that you can
 build in to your application to access new features and common
 utilities while being able to run down to version 1.6 (API 4)
diff --git a/samples/Support4Demos/res/layout/fragment_pager.xml b/samples/Support4Demos/res/layout/fragment_pager.xml
index a082e2e..46c8cbe 100644
--- a/samples/Support4Demos/res/layout/fragment_pager.xml
+++ b/samples/Support4Demos/res/layout/fragment_pager.xml
@@ -21,12 +21,12 @@
         android:gravity="center_horizontal"
         android:layout_width="match_parent" android:layout_height="match_parent">
 
-    <android.support.v4.app.FragmentPager
+    <android.support.v4.view.ViewPager
             android:id="@+id/pager"
             android:layout_width="match_parent"
             android:layout_height="0px"
             android:layout_weight="1">
-    </android.support.v4.app.FragmentPager>
+    </android.support.v4.view.ViewPager>
 
     <LinearLayout android:orientation="horizontal"
             android:gravity="center" android:measureWithLargestChild="true"
diff --git a/samples/Support4Demos/res/layout/fragment_tabs.xml b/samples/Support4Demos/res/layout/fragment_tabs.xml
new file mode 100644
index 0000000..18297b5
--- /dev/null
+++ b/samples/Support4Demos/res/layout/fragment_tabs.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/assets/res/layout/tab_content.xml
+**
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<!-- BEGIN_INCLUDE(complete) -->
+<TabHost
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@android:id/tabhost"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <LinearLayout
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <TabWidget
+            android:id="@android:id/tabs"
+            android:orientation="horizontal"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_weight="0"/>
+
+        <FrameLayout
+            android:id="@android:id/tabcontent"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:layout_weight="0"/>
+
+        <FrameLayout
+            android:id="@+android:id/realtabcontent"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1"/>
+
+    </LinearLayout>
+</TabHost>
+<!-- END_INCLUDE(complete) -->
diff --git a/samples/Support4Demos/res/layout/fragment_tabs_pager.xml b/samples/Support4Demos/res/layout/fragment_tabs_pager.xml
new file mode 100644
index 0000000..c36cf3c
--- /dev/null
+++ b/samples/Support4Demos/res/layout/fragment_tabs_pager.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/assets/res/layout/tab_content.xml
+**
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<TabHost
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@android:id/tabhost"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <LinearLayout
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <TabWidget
+            android:id="@android:id/tabs"
+            android:orientation="horizontal"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_weight="0"/>
+
+        <FrameLayout
+            android:id="@android:id/tabcontent"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            android:layout_weight="0"/>
+
+        <android.support.v4.view.ViewPager
+            android:id="@+id/pager"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1"/>
+
+    </LinearLayout>
+</TabHost>
diff --git a/samples/Support4Demos/res/layout/list_item_icon_text.xml b/samples/Support4Demos/res/layout/list_item_icon_text.xml
new file mode 100644
index 0000000..c3825b7
--- /dev/null
+++ b/samples/Support4Demos/res/layout/list_item_icon_text.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="horizontal"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <ImageView android:id="@+id/icon"
+        android:layout_width="48dip"
+        android:layout_height="48dip" />
+
+    <TextView android:id="@+id/text"
+        android:layout_gravity="center_vertical"
+        android:layout_width="0dip"
+        android:layout_weight="1.0"
+        android:layout_height="wrap_content" />
+
+</LinearLayout>
diff --git a/samples/Support4Demos/res/values/strings.xml b/samples/Support4Demos/res/values/strings.xml
index ba7a341..fa437db 100644
--- a/samples/Support4Demos/res/values/strings.xml
+++ b/samples/Support4Demos/res/values/strings.xml
@@ -77,12 +77,20 @@
     <string name="fragment_stack_support">Fragment/Stack</string>
     <string name="new_fragment">New fragment</string>
 
+    <string name="fragment_tabs">Fragment/Tabs</string>
+
+    <string name="fragment_tabs_pager">Fragment/Tabs and Pager</string>
+
     <string name="fragment_pager_support">Fragment/Pager</string>
     <string name="first">First</string>
     <string name="last">Last</string>
 
+    <string name="fragment_state_pager_support">Fragment/State Pager</string>
+
     <string name="loader_cursor_support">Loader/Cursor</string>
     
+    <string name="loader_custom_support">Loader/Custom</string>
+
     <string name="loader_throttle_support">Loader/Throttle</string>
 
 </resources>
diff --git a/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentPagerSupport.java b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentPagerSupport.java
index 3329597..c10890b 100644
--- a/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentPagerSupport.java
+++ b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentPagerSupport.java
@@ -22,8 +22,10 @@
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentActivity;
-import android.support.v4.app.FragmentPager;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
 import android.support.v4.app.ListFragment;
+import android.support.v4.view.ViewPager;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -34,19 +36,22 @@
 import android.widget.ListView;
 import android.widget.TextView;
 
-public class FragmentPagerSupport extends FragmentActivity
-        implements FragmentPager.Adapter {
+public class FragmentPagerSupport extends FragmentActivity {
     static final int NUM_ITEMS = 10;
 
-    FragmentPager mPager;
+    MyAdapter mAdapter;
+
+    ViewPager mPager;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.fragment_pager);
 
-        mPager = (FragmentPager)findViewById(R.id.pager);
-        mPager.setAdapter(this);
+        mAdapter = new MyAdapter(getSupportFragmentManager());
+
+        mPager = (ViewPager)findViewById(R.id.pager);
+        mPager.setAdapter(mAdapter);
 
         // Watch for button clicks.
         Button button = (Button)findViewById(R.id.goto_first);
@@ -63,14 +68,20 @@
         });
     }
 
-    @Override
-    public int getCount() {
-        return NUM_ITEMS;
-    }
+    public static class MyAdapter extends FragmentPagerAdapter {
+        public MyAdapter(FragmentManager fm) {
+            super(fm);
+        }
 
-    @Override
-    public Fragment getItem(int position) {
-        return ArrayListFragment.newInstance(position);
+        @Override
+        public int getCount() {
+            return NUM_ITEMS;
+        }
+
+        @Override
+        public Fragment getItem(int position) {
+            return ArrayListFragment.newInstance(position);
+        }
     }
 
     public static class ArrayListFragment extends ListFragment {
diff --git a/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentStatePagerSupport.java b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentStatePagerSupport.java
new file mode 100644
index 0000000..8a52896
--- /dev/null
+++ b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentStatePagerSupport.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.supportv4.app;
+
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentStatePagerAdapter;
+import android.support.v4.app.ListFragment;
+import android.support.v4.view.ViewPager;
+
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.View.OnClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import com.example.android.supportv4.Cheeses;
+import com.example.android.supportv4.R;
+
+public class FragmentStatePagerSupport extends FragmentActivity {
+    static final int NUM_ITEMS = 10;
+
+    MyAdapter mAdapter;
+
+    ViewPager mPager;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.fragment_pager);
+
+        mAdapter = new MyAdapter(getSupportFragmentManager());
+
+        mPager = (ViewPager)findViewById(R.id.pager);
+        mPager.setAdapter(mAdapter);
+
+        // Watch for button clicks.
+        Button button = (Button)findViewById(R.id.goto_first);
+        button.setOnClickListener(new OnClickListener() {
+            public void onClick(View v) {
+                mPager.setCurrentItem(0);
+            }
+        });
+        button = (Button)findViewById(R.id.goto_last);
+        button.setOnClickListener(new OnClickListener() {
+            public void onClick(View v) {
+                mPager.setCurrentItem(NUM_ITEMS-1);
+            }
+        });
+    }
+
+    public static class MyAdapter extends FragmentStatePagerAdapter {
+        public MyAdapter(FragmentManager fm) {
+            super(fm);
+        }
+
+        @Override
+        public int getCount() {
+            return NUM_ITEMS;
+        }
+
+        @Override
+        public Fragment getItem(int position) {
+            return ArrayListFragment.newInstance(position);
+        }
+    }
+
+    public static class ArrayListFragment extends ListFragment {
+        int mNum;
+
+        /**
+         * Create a new instance of CountingFragment, providing "num"
+         * as an argument.
+         */
+        static ArrayListFragment newInstance(int num) {
+            ArrayListFragment f = new ArrayListFragment();
+
+            // Supply num input as an argument.
+            Bundle args = new Bundle();
+            args.putInt("num", num);
+            f.setArguments(args);
+
+            return f;
+        }
+
+        /**
+         * When creating, retrieve this instance's number from its arguments.
+         */
+        @Override
+        public void onCreate(Bundle savedInstanceState) {
+            super.onCreate(savedInstanceState);
+            mNum = getArguments() != null ? getArguments().getInt("num") : 1;
+        }
+
+        /**
+         * The Fragment's UI is just a simple text view showing its
+         * instance number.
+         */
+        @Override
+        public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                Bundle savedInstanceState) {
+            View v = inflater.inflate(R.layout.fragment_pager_list, container, false);
+            View tv = v.findViewById(R.id.text);
+            ((TextView)tv).setText("Fragment #" + mNum);
+            return v;
+        }
+
+        @Override
+        public void onActivityCreated(Bundle savedInstanceState) {
+            super.onActivityCreated(savedInstanceState);
+            setListAdapter(new ArrayAdapter<String>(getActivity(),
+                    android.R.layout.simple_list_item_1, Cheeses.sCheeseStrings));
+        }
+
+        @Override
+        public void onListItemClick(ListView l, View v, int position, long id) {
+            Log.i("FragmentList", "Item clicked: " + id);
+        }
+    }
+}
diff --git a/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabs.java b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabs.java
new file mode 100644
index 0000000..64b21c5
--- /dev/null
+++ b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabs.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.example.android.supportv4.app;
+
+//BEGIN_INCLUDE(complete)
+import java.util.HashMap;
+
+import com.example.android.supportv4.R;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentTransaction;
+import android.view.View;
+import android.widget.TabHost;
+
+/**
+ * This demonstrates how you can implement switching between the tabs of a
+ * TabHost through fragments.  It uses a trick (see the code below) to allow
+ * the tabs to switch between fragments instead of simple views.
+ */
+public class FragmentTabs extends FragmentActivity {
+    TabHost mTabHost;
+    TabManager mTabManager;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.fragment_tabs);
+        mTabHost = (TabHost)findViewById(android.R.id.tabhost);
+        mTabHost.setup();
+
+        mTabManager = new TabManager(this, mTabHost, R.id.realtabcontent);
+
+        mTabManager.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
+                FragmentStackSupport.CountingFragment.class, null);
+        mTabManager.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
+                LoaderCursorSupport.CursorLoaderListFragment.class, null);
+        mTabManager.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
+                LoaderCustomSupport.AppListFragment.class, null);
+        mTabManager.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
+                LoaderThrottleSupport.ThrottledLoaderListFragment.class, null);
+
+        if (savedInstanceState != null) {
+            mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
+        }
+    }
+
+    @Override
+    protected void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putString("tab", mTabHost.getCurrentTabTag());
+    }
+
+    /**
+     * This is a helper class that implements a generic mechanism for
+     * associating fragments with the tabs in a tab host.  It relies on a
+     * trick.  Normally a tab host has a simple API for supplying a View or
+     * Intent that each tab will show.  This is not sufficient for switching
+     * between fragments.  So instead we make the content part of the tab host
+     * 0dp high (it is not shown) and the TabManager supplies its own dummy
+     * view to show as the tab content.  It listens to changes in tabs, and takes
+     * care of switch to the correct fragment shown in a separate content area
+     * whenever the selected tab changes.
+     */
+    public static class TabManager implements TabHost.OnTabChangeListener {
+        private final FragmentActivity mActivity;
+        private final TabHost mTabHost;
+        private final int mContainerId;
+        private final HashMap<String, TabInfo> mTabs = new HashMap<String, TabInfo>();
+        TabInfo mLastTab;
+
+        static final class TabInfo {
+            private final String tag;
+            private final Class<?> clss;
+            private final Bundle args;
+            private Fragment fragment;
+
+            TabInfo(String _tag, Class<?> _class, Bundle _args) {
+                tag = _tag;
+                clss = _class;
+                args = _args;
+            }
+        }
+
+        static class DummyTabFactory implements TabHost.TabContentFactory {
+            private final Context mContext;
+
+            public DummyTabFactory(Context context) {
+                mContext = context;
+            }
+
+            @Override
+            public View createTabContent(String tag) {
+                View v = new View(mContext);
+                v.setMinimumWidth(0);
+                v.setMinimumHeight(0);
+                return v;
+            }
+        }
+
+        public TabManager(FragmentActivity activity, TabHost tabHost, int containerId) {
+            mActivity = activity;
+            mTabHost = tabHost;
+            mContainerId = containerId;
+            mTabHost.setOnTabChangedListener(this);
+        }
+
+        public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
+            tabSpec.setContent(new DummyTabFactory(mActivity));
+            String tag = tabSpec.getTag();
+
+            TabInfo info = new TabInfo(tag, clss, args);
+
+            // Check to see if we already have a fragment for this tab, probably
+            // from a previously saved state.  If so, deactivate it, because our
+            // initial state is that a tab isn't shown.
+            info.fragment = mActivity.getSupportFragmentManager().findFragmentByTag(tag);
+            if (info.fragment != null && !info.fragment.isDetached()) {
+                FragmentTransaction ft = mActivity.getSupportFragmentManager().beginTransaction();
+                ft.detach(info.fragment);
+                ft.commit();
+            }
+
+            mTabs.put(tag, info);
+            mTabHost.addTab(tabSpec);
+        }
+
+        @Override
+        public void onTabChanged(String tabId) {
+            TabInfo newTab = mTabs.get(tabId);
+            if (mLastTab != newTab) {
+                FragmentTransaction ft = mActivity.getSupportFragmentManager().beginTransaction();
+                if (mLastTab != null) {
+                    if (mLastTab.fragment != null) {
+                        ft.detach(mLastTab.fragment);
+                    }
+                }
+                if (newTab != null) {
+                    if (newTab.fragment == null) {
+                        newTab.fragment = Fragment.instantiate(mActivity,
+                                newTab.clss.getName(), newTab.args);
+                        ft.add(mContainerId, newTab.fragment, newTab.tag);
+                    } else {
+                        ft.attach(newTab.fragment);
+                    }
+                }
+
+                mLastTab = newTab;
+                ft.commit();
+                mActivity.getSupportFragmentManager().executePendingTransactions();
+            }
+        }
+    }
+}
+//END_INCLUDE(complete)
diff --git a/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabsPager.java b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabsPager.java
new file mode 100644
index 0000000..75498fd
--- /dev/null
+++ b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabsPager.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.example.android.supportv4.app;
+
+import com.example.android.supportv4.R;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.view.View;
+import android.widget.TabHost;
+
+import java.util.ArrayList;
+
+/**
+ * Demonstrates combining a TabHost with a ViewPager to implement a tab UI
+ * that switches between tabs and also allows the user to perform horizontal
+ * flicks to move between the tabs.
+ */
+public class FragmentTabsPager extends FragmentActivity {
+    TabHost mTabHost;
+    ViewPager  mViewPager;
+    TabsAdapter mTabsAdapter;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.fragment_tabs_pager);
+        mTabHost = (TabHost)findViewById(android.R.id.tabhost);
+        mTabHost.setup();
+
+        mViewPager = (ViewPager)findViewById(R.id.pager);
+
+        mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);
+
+        mTabsAdapter.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
+                FragmentStackSupport.CountingFragment.class, null);
+        mTabsAdapter.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
+                LoaderCursorSupport.CursorLoaderListFragment.class, null);
+        mTabsAdapter.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
+                LoaderCustomSupport.AppListFragment.class, null);
+        mTabsAdapter.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
+                LoaderThrottleSupport.ThrottledLoaderListFragment.class, null);
+
+        if (savedInstanceState != null) {
+            mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
+        }
+    }
+
+    @Override
+    protected void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putString("tab", mTabHost.getCurrentTabTag());
+    }
+
+    /**
+     * This is a helper class that implements the management of tabs and all
+     * details of connecting a ViewPager with associated TabHost.  It relies on a
+     * trick.  Normally a tab host has a simple API for supplying a View or
+     * Intent that each tab will show.  This is not sufficient for switching
+     * between pages.  So instead we make the content part of the tab host
+     * 0dp high (it is not shown) and the TabsAdapter supplies its own dummy
+     * view to show as the tab content.  It listens to changes in tabs, and takes
+     * care of switch to the correct paged in the ViewPager whenever the selected
+     * tab changes.
+     */
+    public static class TabsAdapter extends FragmentPagerAdapter
+            implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener {
+        private final Context mContext;
+        private final TabHost mTabHost;
+        private final ViewPager mViewPager;
+        private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
+
+        static final class TabInfo {
+            private final String tag;
+            private final Class<?> clss;
+            private final Bundle args;
+
+            TabInfo(String _tag, Class<?> _class, Bundle _args) {
+                tag = _tag;
+                clss = _class;
+                args = _args;
+            }
+        }
+
+        static class DummyTabFactory implements TabHost.TabContentFactory {
+            private final Context mContext;
+
+            public DummyTabFactory(Context context) {
+                mContext = context;
+            }
+
+            @Override
+            public View createTabContent(String tag) {
+                View v = new View(mContext);
+                v.setMinimumWidth(0);
+                v.setMinimumHeight(0);
+                return v;
+            }
+        }
+
+        public TabsAdapter(FragmentActivity activity, TabHost tabHost, ViewPager pager) {
+            super(activity.getSupportFragmentManager());
+            mContext = activity;
+            mTabHost = tabHost;
+            mViewPager = pager;
+            mTabHost.setOnTabChangedListener(this);
+            mViewPager.setAdapter(this);
+            mViewPager.setOnPageChangeListener(this);
+        }
+
+        public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
+            tabSpec.setContent(new DummyTabFactory(mContext));
+            String tag = tabSpec.getTag();
+
+            TabInfo info = new TabInfo(tag, clss, args);
+            mTabs.add(info);
+            mTabHost.addTab(tabSpec);
+            notifyDataSetChanged();
+        }
+
+        @Override
+        public int getCount() {
+            return mTabs.size();
+        }
+
+        @Override
+        public Fragment getItem(int position) {
+            TabInfo info = mTabs.get(position);
+            return Fragment.instantiate(mContext, info.clss.getName(), info.args);
+        }
+
+        @Override
+        public void onTabChanged(String tabId) {
+            int position = mTabHost.getCurrentTab();
+            mViewPager.setCurrentItem(position);
+        }
+
+        @Override
+        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+        }
+
+        @Override
+        public void onPageSelected(int position) {
+            mTabHost.setCurrentTab(position);
+        }
+
+        @Override
+        public void onPageScrollStateChanged(int state) {
+        }
+    }
+}
diff --git a/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderCursorSupport.java b/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderCursorSupport.java
index 07b9309..096316c 100644
--- a/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderCursorSupport.java
+++ b/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderCursorSupport.java
@@ -81,6 +81,9 @@
                     new int[] { android.R.id.text1, android.R.id.text2 }, 0);
             setListAdapter(mAdapter);
 
+            // Start out with a progress indicator.
+            setListShown(false);
+
             // Prepare the loader.  Either re-connect with an existing one,
             // or start a new one.
             getLoaderManager().initLoader(0, null, this);
@@ -147,6 +150,13 @@
             // Swap the new cursor in.  (The framework will take care of closing the
             // old cursor once we return.)
             mAdapter.swapCursor(data);
+
+            // The list should now be shown.
+            if (isResumed()) {
+                setListShown(true);
+            } else {
+                setListShownNoAnimation(true);
+            }
         }
 
         public void onLoaderReset(Loader<Cursor> loader) {
diff --git a/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderCustomSupport.java b/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderCustomSupport.java
new file mode 100644
index 0000000..b222a20
--- /dev/null
+++ b/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderCustomSupport.java
@@ -0,0 +1,482 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.supportv4.app;
+
+import com.example.android.supportv4.R;
+
+import java.io.File;
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.ListFragment;
+import android.support.v4.app.LoaderManager;
+import android.support.v4.content.AsyncTaskLoader;
+import android.support.v4.content.Loader;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.SearchView;
+import android.widget.TextView;
+import android.widget.SearchView.OnQueryTextListener;
+
+/**
+ * Demonstration of the implementation of a custom Loader.
+ */
+public class LoaderCustomSupport extends FragmentActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        FragmentManager fm = getSupportFragmentManager();
+
+        // Create the list fragment and add it as our sole content.
+        if (fm.findFragmentById(android.R.id.content) == null) {
+            AppListFragment list = new AppListFragment();
+            fm.beginTransaction().add(android.R.id.content, list).commit();
+        }
+    }
+
+//BEGIN_INCLUDE(loader)
+    /**
+     * This class holds the per-item data in our Loader.
+     */
+    public static class AppEntry {
+        public AppEntry(AppListLoader loader, ApplicationInfo info) {
+            mLoader = loader;
+            mInfo = info;
+            mApkFile = new File(info.sourceDir);
+        }
+
+        public ApplicationInfo getApplicationInfo() {
+            return mInfo;
+        }
+
+        public String getLabel() {
+            return mLabel;
+        }
+
+        public Drawable getIcon() {
+            if (mIcon == null) {
+                if (mApkFile.exists()) {
+                    mIcon = mInfo.loadIcon(mLoader.mPm);
+                    return mIcon;
+                } else {
+                    mMounted = false;
+                }
+            } else if (!mMounted) {
+                // If the app wasn't mounted but is now mounted, reload
+                // its icon.
+                if (mApkFile.exists()) {
+                    mMounted = true;
+                    mIcon = mInfo.loadIcon(mLoader.mPm);
+                    return mIcon;
+                }
+            } else {
+                return mIcon;
+            }
+
+            return mLoader.getContext().getResources().getDrawable(
+                    android.R.drawable.sym_def_app_icon);
+        }
+
+        @Override public String toString() {
+            return mLabel;
+        }
+
+        void loadLabel(Context context) {
+            if (mLabel == null || !mMounted) {
+                if (!mApkFile.exists()) {
+                    mMounted = false;
+                    mLabel = mInfo.packageName;
+                } else {
+                    mMounted = true;
+                    CharSequence label = mInfo.loadLabel(context.getPackageManager());
+                    mLabel = label != null ? label.toString() : mInfo.packageName;
+                }
+            }
+        }
+
+        private final AppListLoader mLoader;
+        private final ApplicationInfo mInfo;
+        private final File mApkFile;
+        private String mLabel;
+        private Drawable mIcon;
+        private boolean mMounted;
+    }
+
+    /**
+     * Perform alphabetical comparison of application entry objects.
+     */
+    public static final Comparator<AppEntry> ALPHA_COMPARATOR = new Comparator<AppEntry>() {
+        private final Collator sCollator = Collator.getInstance();
+        @Override
+        public int compare(AppEntry object1, AppEntry object2) {
+            return sCollator.compare(object1.getLabel(), object2.getLabel());
+        }
+    };
+
+    /**
+     * Helper for determining if the configuration has changed in an interesting
+     * way so we need to rebuild the app list.
+     */
+    public static class InterestingConfigChanges {
+        final Configuration mLastConfiguration = new Configuration();
+        int mLastDensity;
+
+        boolean applyNewConfig(Resources res) {
+            int configChanges = mLastConfiguration.updateFrom(res.getConfiguration());
+            boolean densityChanged = mLastDensity != res.getDisplayMetrics().densityDpi;
+            if (densityChanged || (configChanges&(ActivityInfo.CONFIG_LOCALE
+                    |ActivityInfo.CONFIG_UI_MODE|ActivityInfo.CONFIG_SCREEN_LAYOUT)) != 0) {
+                mLastDensity = res.getDisplayMetrics().densityDpi;
+                return true;
+            }
+            return false;
+        }
+    }
+
+    /**
+     * Helper class to look for interesting changes to the installed apps
+     * so that the loader can be updated.
+     */
+    public static class PackageIntentReceiver extends BroadcastReceiver {
+        final AppListLoader mLoader;
+
+        public PackageIntentReceiver(AppListLoader loader) {
+            mLoader = loader;
+            IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
+            filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
+            filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
+            filter.addDataScheme("package");
+            mLoader.getContext().registerReceiver(this, filter);
+            // Register for events related to sdcard installation.
+            IntentFilter sdFilter = new IntentFilter();
+            sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
+            sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
+            mLoader.getContext().registerReceiver(this, sdFilter);
+        }
+
+        @Override public void onReceive(Context context, Intent intent) {
+            // Tell the loader about the change.
+            mLoader.onContentChanged();
+        }
+    }
+
+    /**
+     * A custom Loader that loads all of the installed applications.
+     */
+    public static class AppListLoader extends AsyncTaskLoader<List<AppEntry>> {
+        final InterestingConfigChanges mLastConfig = new InterestingConfigChanges();
+        final PackageManager mPm;
+
+        List<AppEntry> mApps;
+        PackageIntentReceiver mPackageObserver;
+
+        public AppListLoader(Context context) {
+            super(context);
+
+            // Retrieve the package manager for later use; note we don't
+            // use 'context' directly but instead the save global application
+            // context returned by getContext().
+            mPm = getContext().getPackageManager();
+        }
+
+        /**
+         * This is where the bulk of our work is done.  This function is
+         * called in a background thread and should generate a new set of
+         * data to be published by the loader.
+         */
+        @Override public List<AppEntry> loadInBackground() {
+            // Retrieve all known applications.
+            List<ApplicationInfo> apps = mPm.getInstalledApplications(
+                    PackageManager.GET_UNINSTALLED_PACKAGES |
+                    PackageManager.GET_DISABLED_COMPONENTS);
+            if (apps == null) {
+                apps = new ArrayList<ApplicationInfo>();
+            }
+
+            final Context context = getContext();
+
+            // Create corresponding array of entries and load their labels.
+            List<AppEntry> entries = new ArrayList<AppEntry>(apps.size());
+            for (int i=0; i<apps.size(); i++) {
+                AppEntry entry = new AppEntry(this, apps.get(i));
+                entry.loadLabel(context);
+                entries.add(entry);
+            }
+
+            // Sort the list.
+            Collections.sort(entries, ALPHA_COMPARATOR);
+
+            // Done!
+            return entries;
+        }
+
+        /**
+         * Called when there is new data to deliver to the client.  The
+         * super class will take care of delivering it; the implementation
+         * here just adds a little more logic.
+         */
+        @Override public void deliverResult(List<AppEntry> apps) {
+            if (isReset()) {
+                // An async query came in while the loader is stopped.  We
+                // don't need the result.
+                if (apps != null) {
+                    onReleaseResources(apps);
+                }
+            }
+            List<AppEntry> oldApps = apps;
+            mApps = apps;
+
+            if (isStarted()) {
+                // If the Loader is currently started, we can immediately
+                // deliver its results.
+                super.deliverResult(apps);
+            }
+
+            // At this point we can release the resources associated with
+            // 'oldApps' if needed; now that the new result is delivered we
+            // know that it is no longer in use.
+            if (oldApps != null) {
+                onReleaseResources(oldApps);
+            }
+        }
+
+        /**
+         * Handles a request to start the Loader.
+         */
+        @Override protected void onStartLoading() {
+            if (mApps != null) {
+                // If we currently have a result available, deliver it
+                // immediately.
+                deliverResult(mApps);
+            }
+
+            // Start watching for changes in the app data.
+            if (mPackageObserver == null) {
+                mPackageObserver = new PackageIntentReceiver(this);
+            }
+
+            // Has something interesting in the configuration changed since we
+            // last built the app list?
+            boolean configChange = mLastConfig.applyNewConfig(getContext().getResources());
+
+            if (takeContentChanged() || mApps == null || configChange) {
+                // If the data has changed since the last time it was loaded
+                // or is not currently available, start a load.
+                forceLoad();
+            }
+        }
+
+        /**
+         * Handles a request to stop the Loader.
+         */
+        @Override protected void onStopLoading() {
+            // Attempt to cancel the current load task if possible.
+            cancelLoad();
+        }
+
+        /**
+         * Handles a request to cancel a load.
+         */
+        @Override public void onCanceled(List<AppEntry> apps) {
+            super.onCanceled(apps);
+
+            // At this point we can release the resources associated with 'apps'
+            // if needed.
+            onReleaseResources(apps);
+        }
+
+        /**
+         * Handles a request to completely reset the Loader.
+         */
+        @Override protected void onReset() {
+            super.onReset();
+
+            // Ensure the loader is stopped
+            onStopLoading();
+
+            // At this point we can release the resources associated with 'apps'
+            // if needed.
+            if (mApps != null) {
+                onReleaseResources(mApps);
+                mApps = null;
+            }
+
+            // Stop monitoring for changes.
+            if (mPackageObserver != null) {
+                getContext().unregisterReceiver(mPackageObserver);
+                mPackageObserver = null;
+            }
+        }
+
+        /**
+         * Helper function to take care of releasing resources associated
+         * with an actively loaded data set.
+         */
+        protected void onReleaseResources(List<AppEntry> apps) {
+            // For a simple List<> there is nothing to do.  For something
+            // like a Cursor, we would close it here.
+        }
+    }
+//END_INCLUDE(loader)
+
+//BEGIN_INCLUDE(fragment)
+    public static class AppListAdapter extends ArrayAdapter<AppEntry> {
+        private final LayoutInflater mInflater;
+
+        public AppListAdapter(Context context) {
+            super(context, android.R.layout.simple_list_item_2);
+            mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+        }
+
+        public void setData(List<AppEntry> data) {
+            clear();
+            if (data != null) {
+                addAll(data);
+            }
+        }
+
+        /**
+         * Populate new items in the list.
+         */
+        @Override public View getView(int position, View convertView, ViewGroup parent) {
+            View view;
+
+            if (convertView == null) {
+                view = mInflater.inflate(R.layout.list_item_icon_text, parent, false);
+            } else {
+                view = convertView;
+            }
+
+            AppEntry item = getItem(position);
+            ((ImageView)view.findViewById(R.id.icon)).setImageDrawable(item.getIcon());
+            ((TextView)view.findViewById(R.id.text)).setText(item.getLabel());
+
+            return view;
+        }
+    }
+
+    public static class AppListFragment extends ListFragment
+            implements OnQueryTextListener, LoaderManager.LoaderCallbacks<List<AppEntry>> {
+
+        // This is the Adapter being used to display the list's data.
+        AppListAdapter mAdapter;
+
+        // If non-null, this is the current filter the user has provided.
+        String mCurFilter;
+
+        @Override public void onActivityCreated(Bundle savedInstanceState) {
+            super.onActivityCreated(savedInstanceState);
+
+            // Give some text to display if there is no data.  In a real
+            // application this would come from a resource.
+            setEmptyText("No applications");
+
+            // We have a menu item to show in action bar.
+            setHasOptionsMenu(true);
+
+            // Create an empty adapter we will use to display the loaded data.
+            mAdapter = new AppListAdapter(getActivity());
+            setListAdapter(mAdapter);
+
+            // Start out with a progress indicator.
+            setListShown(false);
+
+            // Prepare the loader.  Either re-connect with an existing one,
+            // or start a new one.
+            getLoaderManager().initLoader(0, null, this);
+        }
+
+        @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+            // Place an action bar item for searching.
+            MenuItem item = menu.add("Search");
+            item.setIcon(android.R.drawable.ic_menu_search);
+            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+            SearchView sv = new SearchView(getActivity());
+            sv.setOnQueryTextListener(this);
+            item.setActionView(sv);
+        }
+
+        @Override public boolean onQueryTextChange(String newText) {
+            // Called when the action bar search text has changed.  Since this
+            // is a simple array adapter, we can just have it do the filtering.
+            mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
+            mAdapter.getFilter().filter(mCurFilter);
+            return true;
+        }
+
+        @Override public boolean onQueryTextSubmit(String query) {
+            // Don't care about this.
+            return true;
+        }
+
+        @Override public void onListItemClick(ListView l, View v, int position, long id) {
+            // Insert desired behavior here.
+            Log.i("LoaderCustom", "Item clicked: " + id);
+        }
+
+        @Override public Loader<List<AppEntry>> onCreateLoader(int id, Bundle args) {
+            // This is called when a new Loader needs to be created.  This
+            // sample only has one Loader with no arguments, so it is simple.
+            return new AppListLoader(getActivity());
+        }
+
+        @Override public void onLoadFinished(Loader<List<AppEntry>> loader, List<AppEntry> data) {
+            // Set the new data in the adapter.
+            mAdapter.setData(data);
+
+            // The list should now be shown.
+            if (isResumed()) {
+                setListShown(true);
+            } else {
+                setListShownNoAnimation(true);
+            }
+        }
+
+        @Override public void onLoaderReset(Loader<List<AppEntry>> loader) {
+            // Clear the data in the adapter.
+            mAdapter.setData(null);
+        }
+    }
+//END_INCLUDE(fragment)
+}
diff --git a/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderThrottleSupport.java b/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderThrottleSupport.java
index 6693008..de3f937 100644
--- a/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderThrottleSupport.java
+++ b/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderThrottleSupport.java
@@ -63,7 +63,7 @@
     /**
      * The authority we use to get to our sample provider.
      */
-    public static final String AUTHORITY = "com.example.android.apis.support.app.LoaderThrottle";
+    public static final String AUTHORITY = "com.example.android.apis.supportv4.app.LoaderThrottle";
 
     /**
      * Definition of the contract for the main table of our provider.
@@ -410,6 +410,9 @@
                     new int[] { android.R.id.text1 }, 0);
             setListAdapter(mAdapter);
 
+            // Start out with a progress indicator.
+            setListShown(false);
+
             // Prepare the loader.  Either re-connect with an existing one,
             // or start a new one.
             getLoaderManager().initLoader(0, null, this);
@@ -493,6 +496,13 @@
 
         public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
             mAdapter.swapCursor(data);
+
+            // The list should now be shown.
+            if (isResumed()) {
+                setListShown(true);
+            } else {
+                setListShownNoAnimation(true);
+            }
         }
 
         public void onLoaderReset(Loader<Cursor> loader) {
diff --git a/samples/Support4Demos/src/com/example/android/supportv4/app/_index.html b/samples/Support4Demos/src/com/example/android/supportv4/app/_index.html
index 592ccc1..fa9af5a 100644
--- a/samples/Support4Demos/src/com/example/android/supportv4/app/_index.html
+++ b/samples/Support4Demos/src/com/example/android/supportv4/app/_index.html
@@ -45,9 +45,15 @@
   <dd>Demonstrates populating custom menu items from a Fragment.</dd>
   
   <dt><a href="FragmentPagerSupport.html">Fragment Pager Support</a></dt>
-  <dd>A support class for using the Fragment APIs to build
-   a user interface where the user can fling left or right to switch
-   between fragments.</dd>
+  <dd>Demonstrates the use of the support class ViewPager with a
+  FragmentPagerAdapter to build a user interface where the user can fling
+  left or right to switch between fragments.</dd>
+
+  <dt><a href="FragmentStatePagerSupport.html">Fragment State Pager Support</a></dt>
+  <dd>Demonstrates the use of the support class ViewPager with a
+  FragmentStatePagerAdapter to build a user interface where the user can fling
+  left or right to switch between fragments.  This versions of the adapter
+  doesn't keep around the fragment instances that ViewPager has destroyed.</dd>
 
   <dt><a href="FragmentReceiveResultSupport.html">Fragment Receive Result</a></dt>
   <dd>Demonstrates starting a new Activity from a Fragment, and receiving
@@ -61,6 +67,15 @@
   <dd>Demonstrates creating a stack of Fragment instances similar to the
   traditional stack of activities.</dd>
   
+  <dt><a href="FragmentTabs.html">Fragment Tabs</a></dt>
+  <dd>Demonstrates the use of fragments to implement switching between
+  tabs in a TabHost.</dd>
+
+  <dt><a href="FragmentTabsPager.html">Fragment Tabs Pager</a></dt>
+  <dd>Demonstrates the use of fragments to implement switching between
+  tabs in a TabHost, using a ViewPager to manager the fragments so that
+  the user can also fling left and right to switch tabs.</dd>
+
 </dl>
 
 <h3 id="LoaderManager">LoaderManager</h3>
@@ -68,6 +83,10 @@
   <dt><a href="LoaderCursorSupport.html">Loader Cursor</a></dt>
   <dd>Demonstrates use of LoaderManager to perform a query for a Cursor that
   populates a ListFragment.</dd>
+
+  <dt><a href="LoaderCustomSupport.html">Loader Custom</a></dt>
+  <dd>Demonstrates implementation and use of a custom Loader class.  The
+  custom class here "loads" the currently installed applications.</dd>
   
   <dt><a href="LoaderThrottleSupport.html">Loader Throttle</a></dt>
   <dd>Complete end-to-end demonstration of a simple content provider that
diff --git a/samples/VoicemailProviderDemo/AndroidManifest.xml b/samples/VoicemailProviderDemo/AndroidManifest.xml
index 7dd0a0c..e1a3404 100644
--- a/samples/VoicemailProviderDemo/AndroidManifest.xml
+++ b/samples/VoicemailProviderDemo/AndroidManifest.xml
@@ -23,10 +23,10 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     android:versionCode="1" android:versionName="1.0" package="com.example.android.voicemail">
 
-    <uses-sdk android:minSdkVersion="9" />
-    <uses-sdk android:targetSdkVersion="9" />
+    <uses-sdk android:minSdkVersion="13"
+              android:targetSdkVersion="13" />
 
-    <uses-permission android:name="com.android.providers.voicemail.permission.READ_WRITE_OWN_VOICEMAIL" />
+    <uses-permission android:name="com.android.voicemail.permission.READ_WRITE_OWN_VOICEMAIL" />
     <uses-permission android:name="android.permission.RECORD_AUDIO" />
 
     <application android:icon="@drawable/icon" android:label="@string/app_name">
diff --git a/samples/VoicemailProviderDemo/src/com/android/providers/voicemail/api/VoicemailProvider.java b/samples/VoicemailProviderDemo/src/com/android/providers/voicemail/api/VoicemailProvider.java
deleted file mode 100644
index 4d8876f..0000000
--- a/samples/VoicemailProviderDemo/src/com/android/providers/voicemail/api/VoicemailProvider.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-package com.android.providers.voicemail.api;
-
-import android.content.Intent;
-import android.net.Uri;
-
-/**
- * Defines the constants needed to access and interact with the voicemail content provider.
- */
-public class VoicemailProvider {
-    /** The authority used by the voicemail provider. */
-    public static final String AUTHORITY =
-            "com.android.providers.voicemail";
-
-    /** The main URI exposed by the service. */
-    public static final Uri CONTENT_URI =
-            Uri.parse("content://" + AUTHORITY + "/voicemail");
-    /** The URI to fetch an individual voicemail. */
-    public static final Uri CONTENT_URI_ID_QUERY =
-            Uri.parse("content://" + AUTHORITY + "/voicemail/");
-    /** The URI to fetch all voicemails from a given provider. */
-    public static final Uri CONTENT_URI_PROVIDER_QUERY =
-            Uri.parse("content://" + AUTHORITY + "/voicemail/provider/");
-    /** The URI to fetch an individual voicemail from a given provider. */
-    public static final Uri CONTENT_URI_PROVIDER_ID_QUERY =
-            Uri.parse("content://" + AUTHORITY + "/voicemail/provider/");
-
-    /** Broadcast intent when a new voicemail record is inserted. */
-    public static final String ACTION_NEW_VOICEMAIL = "android.intent.action.NEW_VOICEMAIL";
-    /**
-     * Extra included in {@value Intent#ACTION_PROVIDER_CHANGED} and {@value #ACTION_NEW_VOICEMAIL}
-     * broadcast intents to indicate the package that caused the change in content provider.
-     * <p>
-     * Receivers of the broadcast can use this field to determine if this is a self change.
-     */
-    public static final String EXTRA_CHANGED_BY =
-          "com.android.providers.voicemail.changed_by";
-
-    /** The different tables defined by the content provider. */
-    public static final class Tables {
-        /** The table containing voicemail information. */
-        public static final class Voicemails {
-            public static final String NAME = "voicemails";
-
-            /** The mime type for a collection of voicemails. */
-            public static final String DIR_TYPE =
-                    "vnd.android.cursor.dir/voicemails";
-
-            /** The different columns contained within the voicemail table. */
-            public static final class Columns {
-                public static final String _ID = "_id";
-                public static final String _DATA = "_data";
-                public static final String _DATA_FILE_EXISTS = "_data_file_exists";
-                public static final String NUMBER = "number";
-                public static final String DATE = "date";
-                public static final String DURATION = "duration";
-                public static final String PROVIDER = "provider";
-                public static final String PROVIDER_DATA = "provider_data";
-                public static final String DATA_MIME_TYPE = "data_mime_type";
-                public static final String READ_STATUS = "read_status";
-                /**
-                 * Current mailbox state of the message.
-                 * <p>
-                 * Legal values: 0(Inbox)/1(Deleted)/2(Undeleted).
-                 */
-                public static final String STATE = "state";
-            }
-        }
-    }
-}
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/provider/VoicemailContract.java b/samples/VoicemailProviderDemo/src/com/example/android/provider/VoicemailContract.java
new file mode 100644
index 0000000..b1d7361
--- /dev/null
+++ b/samples/VoicemailProviderDemo/src/com/example/android/provider/VoicemailContract.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+package com.example.android.provider;
+
+// This is a COPY of the voicemail provider contract file checked in at
+// framework/base/core/java/android/provider. The API is currently hidden so
+// it is not available through the SDK and hence is not available to the sample
+// code.
+// TODO: get rid of this copy once the voicemail provider API is opened ups.
+
+import android.content.Intent;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.provider.BaseColumns;
+import android.provider.CallLog.Calls;
+
+/**
+ * The contract between the voicemail provider and applications. Contains
+ * definitions for the supported URIs and columns.
+ *
+ * <P>Voicemails are inserted by what is called as a "voicemail source"
+ * application, which is responsible for syncing voicemail data between a remote
+ * server and the local voicemail content provider. "voicemail source"
+ * application should use the source specific {@link #CONTENT_URI_SOURCE} URI
+ * to insert and retrieve voicemails.
+ *
+ * <P>In addition to the {@link ContentObserver} notifications the voicemail
+ * provider also generates broadcast intents to notify change for applications
+ * that are not active and therefore cannot listen to ContentObserver
+ * notifications. Broadcast intents with following actions are generated:
+ * <ul>
+ *   <li> {@link #ACTION_NEW_VOICEMAIL} is generated for each new voicemail
+ *   inserted.
+ *   </li>
+ *   <li> {@link Intent#ACTION_PROVIDER_CHANGED} is generated for any change
+ *    made into the database, including new voicemail.
+ *   </li>
+ * </ul>
+ * @hide
+ */
+// TODO: unhide when the API is approved by android-api-council
+public class VoicemailContract {
+    /** Not instantiable. */
+    private VoicemailContract() {
+    }
+
+    /** The authority used by the voicemail provider. */
+    public static final String AUTHORITY = "com.android.voicemail";
+
+    /** URI to insert/retrieve all voicemails. */
+    public static final Uri CONTENT_URI =
+            Uri.parse("content://" + AUTHORITY + "/voicemail");
+    /** URI to insert/retrieve voicemails by a given voicemail source. */
+    public static final Uri CONTENT_URI_SOURCE =
+            Uri.parse("content://" + AUTHORITY + "/voicemail/source/");
+
+    // TODO: Move ACTION_NEW_VOICEMAIL to the Intent class.
+    /** Broadcast intent when a new voicemail record is inserted. */
+    public static final String ACTION_NEW_VOICEMAIL = "android.intent.action.NEW_VOICEMAIL";
+    /**
+     * Extra included in {@value Intent#ACTION_PROVIDER_CHANGED} and
+     * {@value #ACTION_NEW_VOICEMAIL} broadcast intents to indicate the package
+     * that caused the change in content provider.
+     * <p>Receivers of the broadcast can use this field to determine if this is
+     * a self change.
+     */
+    public static final String EXTRA_CHANGED_BY = "com.android.voicemail.extra.CHANGED_BY";
+
+    /** The mime type for a collection of voicemails. */
+    public static final String DIR_TYPE =
+            "vnd.android.cursor.dir/voicemails";
+
+    public static final class Voicemails implements BaseColumns {
+        /** Not instantiable. */
+        private Voicemails() {
+        }
+
+        /**
+         * Phone number of the voicemail sender.
+         * <P>Type: TEXT</P>
+         */
+        public static final String NUMBER = Calls.NUMBER;
+        /**
+         * The date the voicemail was sent, in milliseconds since the epoch
+         * <P>Type: INTEGER (long)</P>
+         */
+        public static final String DATE = Calls.DATE;
+        /**
+         * The duration of the voicemail in seconds.
+         * <P>Type: INTEGER (long)</P>
+         */
+        public static final String DURATION = Calls.DURATION;
+        /**
+         * Whether this is a new voicemail (i.e. has not been heard).
+         * <P>Type: INTEGER (boolean)</P>
+         */
+        public static final String NEW = Calls.NEW;
+        /**
+         * The mail box state of the voicemail.
+         * <P> Possible values: {@link #STATE_INBOX}, {@link #STATE_DELETED},
+         * {@link #STATE_UNDELETED}.
+         * <P>Type: INTEGER</P>
+         */
+        public static final String STATE = "state";
+        /** Value of {@link #STATE} when the voicemail is in inbox. */
+        public static int STATE_INBOX = 0;
+        /** Value of {@link #STATE} when the voicemail has been marked as deleted. */
+        public static int STATE_DELETED = 1;
+        /** Value of {@link #STATE} when the voicemail has marked as undeleted. */
+        public static int STATE_UNDELETED = 2;
+        /**
+         * Package name of the source application that inserted the voicemail.
+         * <P>Type: TEXT</P>
+         */
+        public static final String SOURCE_PACKAGE = "source_package";
+        /**
+         * Application-specific data available to the source application that
+         * inserted the voicemail. This is typically used to store the source
+         * specific message id to identify this voicemail on the remote
+         * voicemail server.
+         * <P>Type: TEXT</P>
+         * <P> Note that this is NOT the voicemail media content data.
+         */
+        public static final String SOURCE_DATA = "source_data";
+        /**
+         * Whether the media content for this voicemail is available for
+         * consumption.
+         * <P>Type: INTEGER (boolean)</P>
+         */
+        public static final String HAS_CONTENT = "has_content";
+        /**
+         * MIME type of the media content for the voicemail.
+         * <P>Type: TEXT</P>
+         */
+        public static final String MIME_TYPE = "mime_type";
+        /**
+         * Path to the media content file. Internal only field.
+         * @hide
+         */
+        public static final String _DATA = "_data";
+    }
+}
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java
index 2a6f8fe..c2a34ae 100644
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java
+++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java
@@ -130,7 +130,8 @@
         long duration = durationStr.length() != 0 ? Long.parseLong(durationStr) : 0;
         return VoicemailImpl.createForInsertion(time, sender)
                 .setDuration(duration)
-                .setSource(sourcePackageName)
+                .setSourcePackage(sourcePackageName)
+                .setMailbox(Voicemail.Mailbox.INBOX)
                 .build();
     }
 
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java
index f48122b..17f03c7 100644
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java
+++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java
@@ -16,6 +16,8 @@
 
 package com.example.android.voicemail.common.core;
 
+import com.example.android.provider.VoicemailContract;
+
 import android.net.Uri;
 
 /**
@@ -41,11 +43,11 @@
      */
     public enum Mailbox {
         /** After being fetched from the server, a message usually starts in the inbox. */
-        INBOX(0),
+        INBOX(VoicemailContract.Voicemails.STATE_INBOX),
         /** Indicates that a message has been deleted. */
-        DELETED(1),
+        DELETED(VoicemailContract.Voicemails.STATE_DELETED),
         /** Restored from having been deleted, distinct from being in the inbox. */
-        UNDELETED(2);
+        UNDELETED(VoicemailContract.Voicemails.STATE_UNDELETED);
 
         private final int mValue;
 
@@ -89,24 +91,21 @@
      * Returns the package name of the source that added this voicemail, or null if this field is
      * not set.
      */
-    public String getSource();
+    public String getSourcePackage();
 
-    public boolean hasSource();
+    public boolean hasSourcePackage();
 
     /**
-     * Returns the provider-specific data type stored with the voicemail, or null if this field is
-     * not set.
+     * Returns the application-specific data type stored with the voicemail, or null if this field
+     * is not set.
      * <p>
-     * Provider data is typically used as an identifier to uniquely identify the voicemail against
+     * Source data is typically used as an identifier to uniquely identify the voicemail against
      * the voicemail server. This is likely to be something like the IMAP UID, or some other
      * server-generated identifying string.
      */
-    // TODO:4: we should rename the provider data field to be called provider message id, which is
-    // more explicit. I think we should also rename the get id method to get content id or something
-    // like that.
-    public String getProviderData();
+    public String getSourceData();
 
-    public boolean hasProviderData();
+    public boolean hasSourceData();
 
     /**
      * Gets the Uri that can be used to refer to this voicemail, and to make it play.
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java
index dbb7338..b3eab91 100644
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java
+++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java
@@ -16,38 +16,31 @@
 
 package com.example.android.voicemail.common.core;
 
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.DATE;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.DURATION;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.NUMBER;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.PROVIDER;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.PROVIDER_DATA;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.READ_STATUS;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.STATE;
 import static com.example.android.voicemail.common.utils.DbQueryUtils.concatenateClausesWithAnd;
 import static com.example.android.voicemail.common.utils.DbQueryUtils.concatenateClausesWithOr;
+import static com.example.android.voicemail.common.utils.DbQueryUtils.getEqualityClause;
 
 import com.example.android.voicemail.common.core.Voicemail.Mailbox;
-import com.example.android.voicemail.common.utils.DbQueryUtils;
+import com.example.android.provider.VoicemailContract.Voicemails;
 
 import android.text.TextUtils;
 
-import com.android.providers.voicemail.api.VoicemailProvider;
-
 import java.util.ArrayList;
 import java.util.List;
 
 /**
  * Factory class to create {@link VoicemailFilter} objects for various filtering needs.
  * <p>
- * Factory methods like {@link #createWithMailbox(Mailbox)}, {@link #createWithReadStatus(boolean)} and
- * {@link #createWithMatchingFields(Voicemail)} can be used to create a voicemail filter that matches the
- * value of the specific field.
+ * Factory methods like {@link #createWithMailbox(Mailbox)}, {@link #createWithReadStatus(boolean)}
+ * and {@link #createWithMatchingFields(Voicemail)} can be used to create a voicemail filter that
+ * matches the value of the specific field.
  * <p>
- * It it possible to combine multiple filters with OR or AND operation using the methods
- * {@link #createWithOrOf(VoicemailFilter...)} and {@link #createWithAndOf(VoicemailFilter...)} respectively.
+ * It is possible to combine multiple filters with OR or AND operation using the methods
+ * {@link #createWithOrOf(VoicemailFilter...)} and {@link #createWithAndOf(VoicemailFilter...)}
+ * respectively.
  * <p>
- * {@link #createWithWhereClause(String)} can be used to create an arbitrary filter for a specific where
- * clause. Using this method requires the knowledge of the name of columns used in voicemail
+ * {@link #createWithWhereClause(String)} can be used to create an arbitrary filter for a specific
+ * where clause. Using this method requires the knowledge of the name of columns used in voicemail
  * content provider database and is therefore less recommended.
  */
 public class VoicemailFilterFactory {
@@ -60,8 +53,8 @@
 
     /**
      * Creates a voicemail filter with the specified where clause. Use this method only if you know
-     * and want to directly use the column names of the content provider. For most of the usages one
-     * the other factory methods should be good enough.
+     * and want to directly use the column names of the content provider. For most of the usages
+     * one of the other factory methods should be good enough.
      */
     public static VoicemailFilter createWithWhereClause(final String whereClause) {
         return new VoicemailFilter() {
@@ -81,17 +74,20 @@
         if (fieldMatch == null) {
             throw new IllegalArgumentException("Cannot create filter null fieldMatch");
         }
-        return VoicemailFilterFactory.createWithWhereClause(getWhereClauseForMatchingFields(fieldMatch));
+        return VoicemailFilterFactory.createWithWhereClause(
+                getWhereClauseForMatchingFields(fieldMatch));
     }
 
     /** Creates a voicemail filter with the specified mailbox state. */
     public static VoicemailFilter createWithMailbox(Mailbox mailbox) {
-        return createWithMatchingFields(VoicemailImpl.createEmptyBuilder().setMailbox(mailbox).build());
+        return createWithMatchingFields(
+                VoicemailImpl.createEmptyBuilder().setMailbox(mailbox).build());
     }
 
     /** Creates a voicemail filter with the specified read status. */
     public static VoicemailFilter createWithReadStatus(boolean isRead) {
-        return createWithMatchingFields(VoicemailImpl.createEmptyBuilder().setIsRead(isRead).build());
+        return createWithMatchingFields(
+                VoicemailImpl.createEmptyBuilder().setIsRead(isRead).build());
     }
 
     /** Combine multiple filters with OR clause. */
@@ -115,26 +111,29 @@
     private static String getWhereClauseForMatchingFields(Voicemail fieldMatch) {
         List<String> clauses = new ArrayList<String>();
         if (fieldMatch.hasRead()) {
-            clauses.add(getEqualityClause(READ_STATUS, fieldMatch.isRead() ? "1" : "0"));
+            clauses.add(getEqualityClause(Voicemails.NEW, fieldMatch.isRead() ? "1" : "0"));
         }
         if (fieldMatch.hasMailbox()) {
-            clauses.add(getEqualityClause(STATE,
+            clauses.add(getEqualityClause(Voicemails.STATE,
                     Integer.toString(fieldMatch.getMailbox().getValue())));
         }
         if (fieldMatch.hasNumber()) {
-            clauses.add(getEqualityClause(NUMBER, fieldMatch.getNumber()));
+            clauses.add(getEqualityClause(Voicemails.NUMBER, fieldMatch.getNumber()));
         }
-        if (fieldMatch.hasSource()) {
-            clauses.add(getEqualityClause(PROVIDER, fieldMatch.getSource()));
+        if (fieldMatch.hasSourcePackage()) {
+            clauses.add(getEqualityClause(Voicemails.SOURCE_PACKAGE,
+                    fieldMatch.getSourcePackage()));
         }
-        if (fieldMatch.hasProviderData()) {
-            clauses.add(getEqualityClause(PROVIDER_DATA, fieldMatch.getProviderData()));
+        if (fieldMatch.hasSourceData()) {
+            clauses.add(getEqualityClause(Voicemails.SOURCE_DATA, fieldMatch.getSourceData()));
         }
         if (fieldMatch.hasDuration()) {
-            clauses.add(getEqualityClause(DURATION, Long.toString(fieldMatch.getDuration())));
+            clauses.add(getEqualityClause(Voicemails.DURATION,
+                    Long.toString(fieldMatch.getDuration())));
         }
         if (fieldMatch.hasTimestampMillis()) {
-            clauses.add(getEqualityClause(DATE, Long.toString(fieldMatch.getTimestampMillis())));
+            clauses.add(getEqualityClause(Voicemails.DATE,
+                    Long.toString(fieldMatch.getTimestampMillis())));
         }
         // Empty filter.
         if (clauses.size() == 0) {
@@ -142,9 +141,4 @@
         }
         return concatenateClausesWithAnd(clauses.toArray(new String[0]));
     }
-
-    private static String getEqualityClause(String field, String value) {
-        return DbQueryUtils.getEqualityClause(VoicemailProvider.Tables.Voicemails.NAME, field,
-                value);
-    }
 }
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailImpl.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailImpl.java
index 60f9069..9e08b68 100644
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailImpl.java
+++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailImpl.java
@@ -89,14 +89,16 @@
      * Builder pattern for creating a {@link VoicemailImpl}.
      * <p>
      * All fields are optional, and can be set with the various {@code setXXX} methods.
+     * <p>
+     * This class is <b>not thread safe</b>
      */
     public static class Builder {
         private Long mBuilderTimestamp;
         private String mBuilderNumber;
         private Long mBuilderId;
         private Long mBuilderDuration;
-        private String mBuilderSource;
-        private String mBuilderProviderData;
+        private String mBuilderSourcePackage;
+        private String mBuilderSourceData;
         private Uri mBuilderUri;
         private Voicemail.Mailbox mBuilderMailbox;
         private Boolean mBuilderIsRead;
@@ -126,13 +128,13 @@
             return this;
         }
 
-        public Builder setSource(String source) {
-            mBuilderSource = source;
+        public Builder setSourcePackage(String sourcePackage) {
+            mBuilderSourcePackage = sourcePackage;
             return this;
         }
 
-        public Builder setProviderData(String providerData) {
-            mBuilderProviderData = providerData;
+        public Builder setSourceData(String sourceData) {
+            mBuilderSourceData = sourceData;
             return this;
         }
 
@@ -159,7 +161,7 @@
         public VoicemailImpl build() {
             return new VoicemailImpl(mBuilderTimestamp, mBuilderNumber, mBuilderId,
                     mBuilderDuration,
-                    mBuilderSource, mBuilderProviderData, mBuilderUri, mBuilderMailbox,
+                    mBuilderSourcePackage, mBuilderSourceData, mBuilderUri, mBuilderMailbox,
                     mBuilderIsRead,
                     mBuilderHasContent);
         }
@@ -206,22 +208,22 @@
     }
 
     @Override
-    public String getSource() {
+    public String getSourcePackage() {
         return mSource;
     }
 
     @Override
-    public boolean hasSource() {
+    public boolean hasSourcePackage() {
         return mSource != null;
     }
 
     @Override
-    public String getProviderData() {
+    public String getSourceData() {
         return mProviderData;
     }
 
     @Override
-    public boolean hasProviderData() {
+    public boolean hasSourceData() {
         return mProviderData != null;
     }
 
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailIntentUtils.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailIntentUtils.java
deleted file mode 100644
index 82d971a..0000000
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailIntentUtils.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.voicemail.common.core;
-
-import android.content.Intent;
-import android.os.Bundle;
-
-/**
- * Stores and retrieves relevant bits of voicemails in an Intent.
- */
-public class VoicemailIntentUtils {
-    /** The String used when storing provider data in intents. */
-    public static final String PROVIDER_DATA_KEY = VoicemailImpl.class.getName() + ".PROVIDER_DATA";
-
-    // Private constructor, utility class.
-    private VoicemailIntentUtils() {
-    }
-
-    /**
-     * Stores the {@link Voicemail#getProviderData()} value into an intent.
-     *
-     * @see #extractIdentifierFromIntent(Intent)
-     */
-    public static void storeIdentifierInIntent(Intent intent, Voicemail message) {
-        intent.putExtra(PROVIDER_DATA_KEY, message.getProviderData());
-    }
-
-    /**
-     * Retrieves the {@link Voicemail#getProviderData()} from an intent.
-     * <p>
-     * Returns null if the Intent contains no such identifier, or has no extras.
-     *
-     * @see #storeIdentifierInIntent(Intent, Voicemail)
-     */
-    public static String extractIdentifierFromIntent(Intent intent) {
-        Bundle extras = intent.getExtras();
-        return (extras == null ? null : extras.getString(PROVIDER_DATA_KEY));
-    }
-
-    /**
-     * Copies the extras stored by {@link #storeIdentifierInIntent(Intent, Voicemail)} between two
-     * intents.
-     */
-    public static void copyExtrasBetween(Intent from, Intent to) {
-        Bundle extras = from.getExtras();
-        if (extras.containsKey(PROVIDER_DATA_KEY)) {
-            to.putExtra(PROVIDER_DATA_KEY, extras.getString(PROVIDER_DATA_KEY));
-        }
-    }
-}
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailPayload.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailPayload.java
deleted file mode 100644
index 0e088a6..0000000
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailPayload.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.voicemail.common.core;
-
-/**
- * The payload for a voicemail, usually audio data.
- */
-public interface VoicemailPayload {
-    public String getMimeType();
-
-    public byte[] getBytes();
-}
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailPayloadImpl.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailPayloadImpl.java
deleted file mode 100644
index 3694b56..0000000
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailPayloadImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.voicemail.common.core;
-
-/**
- * Concrete implementation of {@link VoicemailPayload} interface.
- */
-public class VoicemailPayloadImpl implements VoicemailPayload {
-    private final String mMimeType;
-    private final byte[] mBytes;
-
-    public VoicemailPayloadImpl(String mimeType, byte[] bytes) {
-        mMimeType = mimeType;
-        mBytes = bytes.clone();
-    }
-
-    @Override
-    public byte[] getBytes() {
-        return mBytes.clone();
-    }
-
-    @Override
-    public String getMimeType() {
-        return mMimeType;
-    }
-}
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelper.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelper.java
index 72610a5..d3ff514 100644
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelper.java
+++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelper.java
@@ -16,9 +16,9 @@
 
 package com.example.android.voicemail.common.core;
 
-import android.net.Uri;
+import com.example.android.provider.VoicemailContract;
 
-import com.android.providers.voicemail.api.VoicemailProvider;
+import android.net.Uri;
 
 import java.io.IOException;
 import java.io.OutputStream;
@@ -74,7 +74,7 @@
      * It is expected that there be one such voicemail. Returns null if no such voicemail exists,
      * and returns one chosen arbitrarily if more than one exists.
      */
-    public Voicemail findVoicemailByProviderData(String providerData);
+    public Voicemail findVoicemailBySourceData(String providerData);
 
     /**
      * Returns the {@link Voicemail} corresponding to a given Uri. The uri must correspond to a
@@ -121,7 +121,7 @@
      *
      * @param filter The filter to apply while retrieving voicemails.
      * @param sortColumn The column to sort by. Must be one of the values defined in
-     *            {@link VoicemailProvider.Tables.Voicemails.Columns}.
+     *            {@link VoicemailContract.Voicemails}.
      * @param sortOrder Order to sort by
      * @return the list of voicemails, sorted by the requested DB column in specified sort order.
      */
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelpers.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelpers.java
index eda9b54..cbcf86b 100644
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelpers.java
+++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelpers.java
@@ -16,18 +16,8 @@
 
 package com.example.android.voicemail.common.core;
 
-import static com.android.providers.voicemail.api.VoicemailProvider.CONTENT_URI_PROVIDER_ID_QUERY;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.DATA_MIME_TYPE;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.DATE;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.DURATION;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.NUMBER;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.PROVIDER;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.PROVIDER_DATA;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.READ_STATUS;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns.STATE;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns._DATA_FILE_EXISTS;
-import static com.android.providers.voicemail.api.VoicemailProvider.Tables.Voicemails.Columns._ID;
-
+import com.example.android.provider.VoicemailContract;
+import com.example.android.provider.VoicemailContract.Voicemails;
 import com.example.android.voicemail.common.logging.Logger;
 import com.example.android.voicemail.common.utils.CloseUtils;
 import com.example.android.voicemail.common.utils.DbQueryUtils;
@@ -39,8 +29,6 @@
 import android.database.Cursor;
 import android.net.Uri;
 
-import com.android.providers.voicemail.api.VoicemailProvider;
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
@@ -54,8 +42,15 @@
 
     /** Full projection on the voicemail table, giving us all the columns. */
     private static final String[] FULL_PROJECTION = new String[] {
-            _ID, _DATA_FILE_EXISTS, NUMBER, DURATION, DATE, PROVIDER, PROVIDER_DATA, READ_STATUS,
-            STATE
+            Voicemails._ID,
+            Voicemails.HAS_CONTENT,
+            Voicemails.NUMBER,
+            Voicemails.DURATION,
+            Voicemails.DATE,
+            Voicemails.SOURCE_PACKAGE,
+            Voicemails.SOURCE_DATA,
+            Voicemails.NEW,
+            Voicemails.STATE
     };
 
     private final ContentResolver mContentResolver;
@@ -81,7 +76,7 @@
      * <code>com.android.providers.voicemail.permission.READ_WRITE_OWN_VOICEMAIL</code>.
      */
     public static VoicemailProviderHelper createFullVoicemailProvider(Context context) {
-        return new VoicemailProviderHelpers(VoicemailProvider.CONTENT_URI,
+        return new VoicemailProviderHelpers(VoicemailContract.CONTENT_URI,
                 context.getContentResolver());
     }
 
@@ -93,7 +88,7 @@
      * <code>com.android.providers.voicemail.permission.READ_WRITE_OWN_VOICEMAIL</code>.
      */
     public static VoicemailProviderHelper createPackageScopedVoicemailProvider(Context context) {
-        Uri providerUri = Uri.withAppendedPath(VoicemailProvider.CONTENT_URI_PROVIDER_QUERY,
+        Uri providerUri = Uri.withAppendedPath(VoicemailContract.CONTENT_URI_SOURCE,
                 context.getPackageName());
         return new VoicemailProviderHelpers(providerUri, context.getContentResolver());
     }
@@ -120,7 +115,7 @@
     @Override
     public OutputStream setVoicemailContent(Uri voicemailUri, String mimeType) throws IOException {
         ContentValues values = new ContentValues();
-        values.put(DATA_MIME_TYPE, mimeType);
+        values.put(Voicemails.MIME_TYPE, mimeType);
         int updatedCount = mContentResolver.update(voicemailUri, values, null, null);
         if (updatedCount != 1) {
             throw new IOException("Updating voicemail should have updated 1 row, was: "
@@ -131,15 +126,14 @@
     }
 
     @Override
-    public Voicemail findVoicemailByProviderData(String providerData) {
+    public Voicemail findVoicemailBySourceData(String sourceData) {
         Cursor cursor = null;
         try {
             cursor = mContentResolver.query(mBaseUri, FULL_PROJECTION,
-                    DbQueryUtils.getEqualityClause(
-                            VoicemailProvider.Tables.Voicemails.NAME, PROVIDER_DATA, providerData),
+                    DbQueryUtils.getEqualityClause(Voicemails.SOURCE_DATA, sourceData),
                     null, null);
             if (cursor.getCount() != 1) {
-                logger.w("Expected 1 voicemail matching providerData " + providerData + ", got " +
+                logger.w("Expected 1 voicemail matching sourceData " + sourceData + ", got " +
                         cursor.getCount());
                 return null;
             }
@@ -244,23 +238,26 @@
     }
 
     private VoicemailImpl getVoicemailFromCursor(Cursor cursor) {
-        long id = cursor.getLong(cursor.getColumnIndexOrThrow(_ID));
-        String provider = cursor.getString(cursor.getColumnIndexOrThrow(PROVIDER));
+        long id = cursor.getLong(cursor.getColumnIndexOrThrow(Voicemails._ID));
+        String sourcePackage = cursor.getString(
+                cursor.getColumnIndexOrThrow(Voicemails.SOURCE_PACKAGE));
         Uri voicemailUri = ContentUris.withAppendedId(
-                Uri.withAppendedPath(CONTENT_URI_PROVIDER_ID_QUERY, provider), id);
+                Uri.withAppendedPath(VoicemailContract.CONTENT_URI_SOURCE, sourcePackage), id);
         VoicemailImpl voicemail = VoicemailImpl
                 .createEmptyBuilder()
-                .setTimestamp(cursor.getLong(cursor.getColumnIndexOrThrow(DATE)))
-                .setNumber(cursor.getString(cursor.getColumnIndexOrThrow(NUMBER)))
+                .setTimestamp(cursor.getLong(cursor.getColumnIndexOrThrow(Voicemails.DATE)))
+                .setNumber(cursor.getString(cursor.getColumnIndexOrThrow(Voicemails.NUMBER)))
                 .setId(id)
-                .setDuration(cursor.getLong(cursor.getColumnIndexOrThrow(DURATION)))
-                .setSource(provider)
-                .setProviderData(cursor.getString(cursor.getColumnIndexOrThrow(PROVIDER_DATA)))
+                .setDuration(cursor.getLong(cursor.getColumnIndexOrThrow(Voicemails.DURATION)))
+                .setSourcePackage(sourcePackage)
+                .setSourceData(cursor.getString(
+                        cursor.getColumnIndexOrThrow(Voicemails.SOURCE_DATA)))
                 .setUri(voicemailUri)
-                .setHasContent(cursor.getInt(cursor.getColumnIndexOrThrow(_DATA_FILE_EXISTS)) == 1)
-                .setIsRead(cursor.getInt(cursor.getColumnIndexOrThrow(READ_STATUS)) == 1)
-                .setMailbox(
-                        mapValueToMailBoxEnum(cursor.getInt(cursor.getColumnIndexOrThrow(STATE))))
+                .setHasContent(cursor.getInt(
+                        cursor.getColumnIndexOrThrow(Voicemails.HAS_CONTENT)) == 1)
+                .setIsRead(cursor.getInt(cursor.getColumnIndexOrThrow(Voicemails.NEW)) == 1)
+                .setMailbox(mapValueToMailBoxEnum(cursor.getInt(
+                        cursor.getColumnIndexOrThrow(Voicemails.STATE))))
                 .build();
         return voicemail;
     }
@@ -280,25 +277,25 @@
     private ContentValues getContentValues(Voicemail voicemail) {
         ContentValues contentValues = new ContentValues();
         if (voicemail.hasTimestampMillis()) {
-            contentValues.put(DATE, String.valueOf(voicemail.getTimestampMillis()));
+            contentValues.put(Voicemails.DATE, String.valueOf(voicemail.getTimestampMillis()));
         }
         if (voicemail.hasNumber()) {
-            contentValues.put(NUMBER, voicemail.getNumber());
+            contentValues.put(Voicemails.NUMBER, voicemail.getNumber());
         }
         if (voicemail.hasDuration()) {
-            contentValues.put(DURATION, String.valueOf(voicemail.getDuration()));
+            contentValues.put(Voicemails.DURATION, String.valueOf(voicemail.getDuration()));
         }
-        if (voicemail.hasSource()) {
-            contentValues.put(PROVIDER, voicemail.getSource());
+        if (voicemail.hasSourcePackage()) {
+            contentValues.put(Voicemails.SOURCE_PACKAGE, voicemail.getSourcePackage());
         }
-        if (voicemail.hasProviderData()) {
-            contentValues.put(PROVIDER_DATA, voicemail.getProviderData());
+        if (voicemail.hasSourceData()) {
+            contentValues.put(Voicemails.SOURCE_DATA, voicemail.getSourceData());
         }
         if (voicemail.hasRead()) {
-            contentValues.put(READ_STATUS, voicemail.isRead() ? 1 : 0);
+            contentValues.put(Voicemails.NEW, voicemail.isRead() ? 1 : 0);
         }
         if (voicemail.hasMailbox()) {
-            contentValues.put(STATE, voicemail.getMailbox().getValue());
+            contentValues.put(Voicemails.STATE, voicemail.getMailbox().getValue());
         }
         return contentValues;
     }
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/utils/DbQueryUtils.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/utils/DbQueryUtils.java
index 1805634..a809770 100644
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/utils/DbQueryUtils.java
+++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/utils/DbQueryUtils.java
@@ -27,11 +27,14 @@
     private DbQueryUtils() {
     }
 
-    /** Returns a WHERE clause assert equality of a field to a value. */
+    /** Returns a WHERE clause assert equality of a field to a value for the specified table . */
     public static String getEqualityClause(String table, String field, String value) {
+        return getEqualityClause(table + "." + field, value);
+    }
+
+    /** Returns a WHERE clause assert equality of a field to a value. */
+    public static String getEqualityClause(String field, String value) {
         StringBuilder clause = new StringBuilder();
-        clause.append(table);
-        clause.append(".");
         clause.append(field);
         clause.append(" = ");
         DatabaseUtils.appendEscapedSQLString(clause, value);
diff --git a/sdk/compatibility_README.txt b/sdk/compatibility_README.txt
index d1f15ed..7752b3b 100644
--- a/sdk/compatibility_README.txt
+++ b/sdk/compatibility_README.txt
@@ -4,7 +4,10 @@
 on older platforms. To use those libraries, simply copy them as static libraries
 into your project.
 
-"v4" provides support for using new APIs on Android API 4 (1.6 - Donut) and above.
+Each library is called v<api>, indicating the minimum API level that they require.
+
+
+*** V4 ***
 
 v4/android-support-v4.jar contains:
 - Fragment API. New in API 11 (3.0 - Honeycomb). http://developer.android.com/reference/android/app/Fragment.html
@@ -13,4 +16,13 @@
 - MenuCompat allows calling MenuItem.setShowAsAction which only exists on API 11.
 
 v4/src/ is the source code for the compatibility library
-v4/samples/ provides a version of ApiDemos using the library.
\ No newline at end of file
+v4/samples/ provides a sample app using the library.
+
+
+*** V13 ***
+
+Provides the same features as v4, plus:
+- FragmentPagerAdapter: Implementation of PagerAdapter that represents each page as a Fragment.
+
+v13/src/ is the source code for the compatibility library, not including the v4 source
+v13/samples/ provides a sample app using the library.
diff --git a/sdk/doc_source.properties b/sdk/doc_source.properties
index 82c3cda..5f493e4 100644
--- a/sdk/doc_source.properties
+++ b/sdk/doc_source.properties
@@ -1,5 +1,5 @@
 Pkg.UserSrc=false
 Pkg.Revision=1
-AndroidVersion.ApiLevel=12
+AndroidVersion.ApiLevel=13
 #AndroidVersion.CodeName=
 
diff --git a/sdk/platform_source.properties b/sdk/platform_source.properties
index 6be2cb1..7b6a869 100644
--- a/sdk/platform_source.properties
+++ b/sdk/platform_source.properties
@@ -1,6 +1,6 @@
-Pkg.Desc=Android SDK Platform 3.1
+Pkg.Desc=Android SDK Platform 3.2
 Pkg.UserSrc=false
-Platform.Version=3.1
+Platform.Version=3.2
 Pkg.Revision=1
-AndroidVersion.ApiLevel=12
+AndroidVersion.ApiLevel=13
 #AndroidVersion.CodeName=
diff --git a/sdk/sdk.properties b/sdk/sdk.properties
index 7f67ae8..54318cb 100644
--- a/sdk/sdk.properties
+++ b/sdk/sdk.properties
@@ -2,5 +2,4 @@
 # This file is copied in the root folder of each platform component.
 # If it used by various tools to figure out what the platform can do.
 sdk.ant.templates.revision=1
-sdk.layoutlib.api=5
 sdk.skin.default=WXGA
\ No newline at end of file
diff --git a/testrunner/adb_interface.py b/testrunner/adb_interface.py
index 3bd4396..feb1c89 100755
--- a/testrunner/adb_interface.py
+++ b/testrunner/adb_interface.py
@@ -155,6 +155,7 @@
       return True
     elif "restarting adbd as root" in output:
       # device will disappear from adb, wait for it to come back
+      time.sleep(2)
       self.SendCommand("wait-for-device")
       return True
     else:
diff --git a/testrunner/runtest.py b/testrunner/runtest.py
index 19102c6..6226350 100755
--- a/testrunner/runtest.py
+++ b/testrunner/runtest.py
@@ -35,6 +35,7 @@
 import os
 from sets import Set
 import sys
+import time
 
 # local imports
 import adb_interface
@@ -195,18 +196,21 @@
     Raises:
       AbortError: If a fatal error occurred when parsing the tests.
     """
-    core_test_path = os.path.join(self._root_path, self._CORE_TEST_PATH)
     try:
       known_tests = test_defs.TestDefinitions()
-      known_tests.Parse(core_test_path)
-      # read all <android root>/vendor/*/tests/testinfo/test_defs.xml paths
-      vendor_tests_pattern = os.path.join(self._root_path,
-                                          self._VENDOR_TEST_PATH)
-      test_file_paths = glob.glob(vendor_tests_pattern)
-      for test_file_path in test_file_paths:
-        known_tests.Parse(test_file_path)
-      if os.path.isfile(self._options.user_tests_file):
-        known_tests.Parse(self._options.user_tests_file)
+      # only read tests when not in path mode
+      if not self._options.test_path:
+        core_test_path = os.path.join(self._root_path, self._CORE_TEST_PATH)
+        if os.path.isfile(core_test_path):
+          known_tests.Parse(core_test_path)
+        # read all <android root>/vendor/*/tests/testinfo/test_defs.xml paths
+        vendor_tests_pattern = os.path.join(self._root_path,
+                                            self._VENDOR_TEST_PATH)
+        test_file_paths = glob.glob(vendor_tests_pattern)
+        for test_file_path in test_file_paths:
+          known_tests.Parse(test_file_path)
+        if os.path.isfile(self._options.user_tests_file):
+          known_tests.Parse(self._options.user_tests_file)
       return known_tests
     except errors.ParseError:
       raise errors.AbortError
@@ -261,7 +265,7 @@
 
       # mmm cannot be used from python, so perform a similar operation using
       # ONE_SHOT_MAKEFILE
-      cmd = 'ONE_SHOT_MAKEFILE="%s" make -j%s -C "%s" files %s' % (
+      cmd = 'ONE_SHOT_MAKEFILE="%s" make -j%s -C "%s" all_modules %s' % (
           target_build_string, self._options.make_jobs, self._root_path,
           extra_args_string)
       logger.Log(cmd)
@@ -385,6 +389,8 @@
           self._adb.SendShellCommand("\"echo %s >> /data/local.prop\""
                                      % self._DALVIK_VERIFIER_OFF_PROP)
           self._adb.SendCommand("reboot")
+          # wait for device to go offline
+          time.sleep(10)
           self._adb.SendCommand("wait-for-device", timeout_time=60,
                                 retry_count=3)
           self._adb.EnableAdbRoot()
diff --git a/tools/a3dconvert/Android.mk b/tools/a3dconvert/Android.mk
index 7bc634e..2b09fbf 100644
--- a/tools/a3dconvert/Android.mk
+++ b/tools/a3dconvert/Android.mk
@@ -29,12 +29,19 @@
     ColladaGeometry.cpp \
     ColladaLoader.cpp
 
+# Needed to maintain libRS dependencies
+intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,HOST,)
+librs_generated_headers := \
+    $(intermediates)/rsgApiStructs.h \
+    $(intermediates)/rsgApiFuncDecl.h
+LOCAL_GENERATED_SOURCES := $(librs_generated_headers)
 
 LOCAL_C_INCLUDES += external/collada/include
 LOCAL_C_INCLUDES += external/collada/include/1.4
 LOCAL_C_INCLUDES += frameworks/base/libs/rs
+LOCAL_C_INCLUDES += $(intermediates)
 
 LOCAL_LDLIBS := -lpthread
-LOCAL_STATIC_LIBRARIES += libRSserialize libutils libcutils
+LOCAL_STATIC_LIBRARIES += libRS libutils libcutils
 LOCAL_STATIC_LIBRARIES += colladadom libtinyxml libpcrecpp libpcre
 include $(BUILD_HOST_EXECUTABLE)
diff --git a/tools/a3dconvert/a3dconvert.cpp b/tools/a3dconvert/a3dconvert.cpp
index 893df10..6094473 100644
--- a/tools/a3dconvert/a3dconvert.cpp
+++ b/tools/a3dconvert/a3dconvert.cpp
@@ -19,24 +19,67 @@
 
 #include "ColladaLoader.h"
 #include "ObjLoader.h"
-#include "rsContext.h"
-#include "rsFileA3D.h"
+#include <rsContext.h>
+#include <rsFileA3D.h>
+
+bool rsdAllocationInit(const Context *rsc, Allocation *alloc, bool forceZero) {
+    void * ptr = malloc(alloc->mHal.state.type->getSizeBytes());
+    if (!ptr) {
+        return false;
+    }
+
+    alloc->mHal.drvState.mallocPtr = ptr;
+    if (forceZero) {
+        memset(ptr, 0, alloc->mHal.state.type->getSizeBytes());
+    }
+    return true;
+}
+
+void rsdAllocationDestroy(const Context *rsc, Allocation *alloc) {
+    if (alloc->mHal.drvState.mallocPtr) {
+        free(alloc->mHal.drvState.mallocPtr);
+        alloc->mHal.drvState.mallocPtr = NULL;
+    }
+}
+
+// We only care to implement allocation memory initialization and destruction
+// because we need no other renderscript hal features for serialization
+static RsdHalFunctions FunctionTable = {
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL },
+    {
+        rsdAllocationInit,
+        rsdAllocationDestroy,
+        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+    },
+    { NULL, NULL, NULL }, { NULL, NULL, NULL }, { NULL, NULL, NULL },
+    { NULL, NULL, NULL }, { NULL, NULL, NULL }, { NULL, NULL },
+    { NULL, NULL, NULL},
+};
+
+// No-op initizlizer for rs context hal since we only
+bool rsdHalInit(Context *rsc, uint32_t version_major, uint32_t version_minor) {
+    rsc->mHal.funcs = FunctionTable;
+    return true;
+}
 
 bool convertToA3D(GeometryLoader *loader, const char *a3dFile) {
     if (!loader->getNumMeshes()) {
         return false;
     }
     // Now write all this stuff out
-    Context rsc;
-    FileA3D file(&rsc);
+    Context *rsc = Context::createContextLite();
+    rsdHalInit(rsc, 0, 0);
+    FileA3D file(rsc);
 
     for (uint32_t i = 0; i < loader->getNumMeshes(); i ++) {
-        Mesh *exportedMesh = loader->getMesh(i)->getRsMesh(&rsc);
+        Mesh *exportedMesh = loader->getMesh(i)->getRsMesh(rsc);
         file.appendToFile(exportedMesh);
         delete exportedMesh;
     }
 
     file.writeFile(a3dFile);
+    delete rsc;
     return true;
 }
 
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/Android.mk b/tools/emulator/opengl/host/libs/Translator/EGL/Android.mk
index 4e97836..2fd38fa 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/Android.mk
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/Android.mk
@@ -14,7 +14,11 @@
 endif
 
 ifeq ($(HOST_OS),darwin)
-    OS_SRCS = EglMacApi.cpp
+    OS_SRCS = EglMacApi.cpp \
+              MacNative.m   \
+              MacPixelFormatsAttribs.m
+
+    LOCAL_LDLIBS := -Wl,-framework,AppKit
 endif
 
 ifeq ($(HOST_OS),windows)
@@ -47,13 +51,11 @@
 LOCAL_MODULE := libEGL_translator
 
 LOCAL_STATIC_LIBRARIES :=    \
+                 libGLcommon \
                  libcutils   \
                  libutils    \
                  liblog      \
                  libOpenglOsUtils
 
-LOCAL_SHARED_LIBRARIES := \
-    libGLcommon
-
 include $(BUILD_HOST_SHARED_LIBRARY)
 
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp
index 609e231..9fcdf64 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp
@@ -27,6 +27,7 @@
                      EGLint     max_pbuffer_height,
                      EGLint     max_pbuffer_size,
                      EGLBoolean native_renderable,
+                     EGLint     renderable_type,
                      EGLint     native_visual_id,
                      EGLint     native_visual_type,
                      EGLint     samples_per_pixel,
@@ -55,6 +56,7 @@
                      m_max_swap_interval(MAX_SWAP_INTERVAL),
                      m_min_swap_interval(MIN_SWAP_INTERVAL),
                      m_native_renderable(native_renderable),
+                     m_renderable_type(renderable_type),
                      m_native_visual_id(native_visual_id),
                      m_native_visual_type(native_visual_type),
                      m_sample_buffers_num(samples_per_pixel > 0 ?1:0),
@@ -85,6 +87,7 @@
                                                 m_max_swap_interval(conf.m_max_swap_interval),
                                                 m_min_swap_interval(conf.m_min_swap_interval),
                                                 m_native_renderable(conf.m_native_renderable),
+                                                m_renderable_type(conf.m_renderable_type),
                                                 m_native_visual_id(conf.m_native_visual_id),
                                                 m_native_visual_type(conf.m_native_visual_type),
                                                 m_sample_buffers_num(conf.m_sample_buffers_num),
@@ -158,6 +161,8 @@
     case EGL_NATIVE_VISUAL_TYPE:
         *val = m_native_visual_type;
         break;
+    case EGL_RENDERABLE_TYPE:
+        *val = m_renderable_type;
     case EGL_SAMPLE_BUFFERS:
         *val = m_sample_buffers_num;
         break;
@@ -279,6 +284,9 @@
    if(dummy.m_surface_type != EGL_DONT_CARE &&
     ((dummy.m_surface_type & m_surface_type) != dummy.m_surface_type)) return false;
 
+   if(dummy.m_renderable_type != EGL_DONT_CARE &&
+    ((dummy.m_renderable_type & m_renderable_type) != dummy.m_renderable_type)) return false;
+
    //passed all checks
    return true;
 }
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.h
index c77c334..3336f0e 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglConfig.h
@@ -17,6 +17,7 @@
 #define EGL_CONFIG_H
 
 #include<EGL/egl.h>
+#include<EGL/eglinternalplatform.h>
 
 #define MIN_SWAP_INTERVAL 1
 #define MAX_SWAP_INTERVAL 10
@@ -45,6 +46,7 @@
               EGLint max_pbuffer_height,
               EGLint max_pbuffer_size,
               EGLBoolean native_renderable,
+              EGLint renderable_type,
               EGLint native_visual_id,
               EGLint native_visual_type,
               EGLint samples_per_pixel,
@@ -78,6 +80,7 @@
     const EGLint                    m_max_swap_interval;
     const EGLint                    m_min_swap_interval;
     const EGLBoolean                m_native_renderable;
+    const EGLint                    m_renderable_type;
     const EGLint                    m_native_visual_id;
     const EGLint                    m_native_visual_type;
     const EGLint                    m_sample_buffers_num;
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h
index 0c20723..5b528ab 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h
@@ -18,6 +18,7 @@
 
 #include <map>
 #include <EGL/egl.h>
+#include <GLcommon/GLutils.h>
 #include <GLcommon/SmartPtr.h>
 #include <GLcommon/TranslatorIfaces.h>
 #include <GLcommon/objectNameManager.h>
@@ -27,11 +28,6 @@
 #include "EglSurface.h"
 
 
-typedef enum{
-             GLES_1_1 = 0,
-             GLES_2_0 = 1,
-             MAX_GLES_VERSION //Must be last
-            }GLESVersion;
 
 class EglContext;
 typedef  SmartPtr<EglContext> ContextPtr;
@@ -57,6 +53,7 @@
     bool attachImage(unsigned int imageId,ImagePtr img);
     void detachImage(unsigned int imageId);
 
+    ~EglContext(){}
 private:
     static unsigned int  s_nextContextHndl;
     EGLNativeContextType m_native;
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp
index 31a425f..ad64c90 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp
@@ -18,7 +18,16 @@
 #include <GLcommon/GLutils.h>
 #include <utils/threads.h>
 
-EglDisplay::EglDisplay(EGLNativeDisplayType dpy,bool isDefault):m_dpy(dpy),m_initialized(false),m_configInitialized(false),m_isDefault(isDefault),m_nextEglImageId(0){};
+EglDisplay::EglDisplay(EGLNativeDisplayType dpy,bool isDefault) :
+    m_dpy(dpy),
+    m_initialized(false),
+    m_configInitialized(false),
+    m_isDefault(isDefault),
+    m_nextEglImageId(0)
+{
+    m_manager[GLES_1_1] = new ObjectNameManager(&m_globalNameSpace);
+    m_manager[GLES_2_0] = new ObjectNameManager(&m_globalNameSpace);
+};
 
 EglDisplay::~EglDisplay() {
     android::Mutex::Autolock mutex(m_lock);
@@ -31,14 +40,17 @@
         EglConfig* pConfig = *it;
         if(pConfig) delete pConfig;
     }
+
+    delete m_manager[GLES_1_1];
+    delete m_manager[GLES_2_0];
 }
 
 EGLNativeDisplayType EglDisplay::nativeType(){return m_dpy;}
 
-void EglDisplay::initialize() {
+void EglDisplay::initialize(int renderableType) {
     android::Mutex::Autolock mutex(m_lock);
     m_initialized = true;
-    initConfigurations();
+    initConfigurations(renderableType);
     m_configInitialized = true;
 }
 
@@ -55,9 +67,9 @@
     return *first < *second ;
 }
 
-void EglDisplay::initConfigurations() {
+void EglDisplay::initConfigurations(int renderableType) {
     if(m_configInitialized) return;
-    EglOS::queryConfigs(m_dpy,m_configs);
+    EglOS::queryConfigs(m_dpy,renderableType,m_configs);
     m_configs.sort(compareEglConfigsPtrs);
 }
 
@@ -108,7 +120,7 @@
     SurfacesHndlMap::iterator it;
     for(it = m_surfaces.begin(); it!= m_surfaces.end();it++)
     {
-        if((*it).second == s.Ptr()) {
+        if((*it).second.Ptr() == s.Ptr()) {
             break;
         }
     }
@@ -135,7 +147,7 @@
 
     ContextsHndlMap::iterator it;
     for(it = m_contexts.begin(); it != m_contexts.end();it++) {
-        if((*it).second == ctx.Ptr()){
+        if((*it).second.Ptr() == ctx.Ptr()){
             break;
         }
     }
@@ -170,10 +182,13 @@
 int EglDisplay::chooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size) {
     android::Mutex::Autolock mutex(m_lock);
     int added = 0;
-    for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() && added < config_size;it++) {
+    for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() && (added < config_size || !configs);it++) {
 
        if( (*it)->choosen(dummy)){
-           configs[added++] = static_cast<EGLConfig>(*it);
+            if(configs) {
+                configs[added] = static_cast<EGLConfig>(*it);
+            }
+            added++;
        }
     }
     //no need to sort since the configurations are saved already in sorted maner
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h
index 81e82e1..dadda09 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h
@@ -55,10 +55,10 @@
     ContextPtr getContext(EGLContext ctx);
     bool removeContext(EGLContext ctx);
     bool removeContext(ContextPtr ctx);
-    ObjectNameManager* getManager(GLESVersion ver){ return &m_manager[ver];}
+    ObjectNameManager* getManager(GLESVersion ver){ return m_manager[ver];}
 
     ~EglDisplay();
-    void initialize();
+    void initialize(int renderableType);
     void terminate();
     bool isInitialize();
 
@@ -67,7 +67,7 @@
     bool destroyImageKHR(EGLImageKHR img);
 
 private:
-   void initConfigurations();
+   void initConfigurations(int renderableType);
 
    EGLNativeDisplayType   m_dpy;
    bool                   m_initialized;
@@ -76,7 +76,8 @@
    ConfigsList            m_configs;
    ContextsHndlMap        m_contexts;
    SurfacesHndlMap        m_surfaces;
-   ObjectNameManager      m_manager[MAX_GLES_VERSION];
+   GlobalNameSpace        m_globalNameSpace;
+   ObjectNameManager      *m_manager[MAX_GLES_VERSION];
    android::Mutex         m_lock;
    ImagesHndlMap           m_eglImages;
    unsigned int           m_nextEglImageId;
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp
index 8c432d3..1e47f0f 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp
@@ -37,9 +37,8 @@
 #include "EglConfig.h"
 #include "EglOsApi.h"
 
-
-#define MINOR          1
-#define MAJOR          4
+#define MAJOR          1
+#define MINOR          4
 
 //declarations
 
@@ -159,14 +158,15 @@
     return func;
 }
 
-
-
 #ifdef _WIN32
-#define LIB_GLES_NAME "libGLES_CM_translator"
+#define LIB_GLES_CM_NAME "libGLES_CM_translator"
+#define LIB_GLES_V2_NAME "libGLES_V2_translator"
 #elif __linux__
-#define LIB_GLES_NAME "libGLES_CM_translator.so"
-#else
-#define LIB_GLES_NAME "libGLES_CM_translator"
+#define LIB_GLES_CM_NAME "libGLES_CM_translator.so"
+#define LIB_GLES_V2_NAME "libGLES_V2_translator.so"
+#elif __APPLE__
+#define LIB_GLES_CM_NAME "libGLES_CM_translator.dylib"
+#define LIB_GLES_V2_NAME "libGLES_V2_translator.dylib"
 #endif
 
 EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay display, EGLint *major, EGLint *minor) {
@@ -177,17 +177,29 @@
 
     if(major) *major = MAJOR;
     if(minor) *minor = MINOR;
-     if(!g_eglInfo->getIface(GLES_1_1)) {
-        __translator_getGLESIfaceFunc func  = loadIfaces(LIB_GLES_NAME);
 
+    __translator_getGLESIfaceFunc func  = NULL;
+    int renderableType = EGL_OPENGL_ES_BIT;
+
+    if(!g_eglInfo->getIface(GLES_1_1)) {
+        func  = loadIfaces(LIB_GLES_CM_NAME);
         if(func){
             g_eglInfo->setIface(func(&s_eglIface),GLES_1_1);
         } else {
-           fprintf(stderr,"could not find ifaces...\n");
+           fprintf(stderr,"could not find ifaces for GLES CM 1.1\n");
            return EGL_FALSE;
         }
     }
-    dpy->initialize();
+    if(!g_eglInfo->getIface(GLES_2_0)) {
+        func  = loadIfaces(LIB_GLES_V2_NAME);
+        if(func){
+            renderableType |= EGL_OPENGL_ES2_BIT;
+            g_eglInfo->setIface(func(&s_eglIface),GLES_2_0);
+        } else {
+           fprintf(stderr,"could not find ifaces for GLES 2.0\n");
+        }
+    }
+    dpy->initialize(renderableType);
     return EGL_TRUE;
 }
 
@@ -242,6 +254,7 @@
 
         //selection defaults
         EGLint      surface_type       = EGL_WINDOW_BIT;
+        EGLint      renderable_type    = EGL_OPENGL_ES_BIT;
         EGLBoolean  bind_to_tex_rgb    = EGL_DONT_CARE;
         EGLBoolean  bind_to_tex_rgba   = EGL_DONT_CARE;
         EGLenum     caveat             = EGL_DONT_CARE;
@@ -351,6 +364,9 @@
             case EGL_NATIVE_RENDERABLE:
                 native_renderable = attrib_list[i+1];
                 break;
+            case EGL_RENDERABLE_TYPE:
+                renderable_type = attrib_list[i+1];
+                break;
             case EGL_NATIVE_VISUAL_TYPE:
                 native_visual_type = attrib_list[i+1];
                 break;
@@ -399,19 +415,21 @@
             i+=2;
         }
         if(hasConfigId) {
-           EglConfig* pConfig = dpy->getConfig(config_id);
-           if(pConfig) {
-               configs[0]  = static_cast<EGLConfig>(pConfig);
-               *num_config = 0;
-               return EGL_TRUE;
-           } else {
+            EglConfig* pConfig = dpy->getConfig(config_id);
+            if(pConfig) {
+                if(configs) {
+                    configs[0]  = static_cast<EGLConfig>(pConfig);
+                }
+                *num_config = 1;
+                return EGL_TRUE;
+            } else {
                 RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
-           }
+            }
         }
     }
     EGLNativePixelFormatType tmpfrmt = PIXEL_FORMAT_INITIALIZER;
     EglConfig dummy(red_size,green_size,blue_size,alpha_size,caveat,config_id,depth_size,
-                    frame_buffer_level,0,0,0,native_renderable,0,native_visual_type,
+                    frame_buffer_level,0,0,0,native_renderable,renderable_type,0,native_visual_type,
                     samples_per_pixel,stencil_size,surface_type,transparent_type,
                     trans_red_val,trans_green_val,trans_blue_val,tmpfrmt);
 
@@ -551,7 +569,7 @@
         RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
     }
 
-    srfc->destroy(); //mark surface for destruction
+    srfc->markForDestruction(); //mark surface for destruction
     if(destroySurfaceIfNotCurrent(dpy,srfc)) { //removes surface from the list if not current
         dpy->removeSurface(surface);
     }
@@ -646,7 +664,7 @@
     VALIDATE_DISPLAY(display);
     VALIDATE_CONTEXT(context);
 
-    ctx->destroy(); //mark for destruction
+    ctx->markForDestruction(); //mark for destruction
     if(destroyContextIfNotCurrent(dpy,ctx)){ //removes the context from the list if it is not current
         g_eglInfo->getIface(ctx->version())->deleteGLESContext(ctx->getGlesContext());
         dpy->removeContext(context);
@@ -663,13 +681,6 @@
         RETURN_ERROR(EGL_FALSE,EGL_BAD_MATCH);
     }
 
-    VALIDATE_CONTEXT(context);
-    VALIDATE_SURFACE(draw,newDrawSrfc);
-    VALIDATE_SURFACE(read,newReadSrfc);
-
-    EglSurface* newDrawPtr = newDrawSrfc.Ptr();
-    EglSurface* newReadPtr = newReadSrfc.Ptr();
-    EglContext* newCtx     = ctx.Ptr();
     ThreadInfo* thread     = getThreadInfo();
     EglContext* prevCtx    = static_cast<EglContext*>(thread->eglContext);
 
@@ -679,11 +690,17 @@
            if(!EglOS::makeCurrent(dpy->nativeType(),NULL,NULL,NULL)) {
                RETURN_ERROR(EGL_FALSE,EGL_BAD_ACCESS);
            }
-           thread->updateInfo(newCtx,dpy,NULL,newCtx->getShareGroup(),dpy->getManager(newCtx->version()));
-           g_eglInfo->getIface(prevCtx->version())->setShareGroup(newCtx->getGlesContext(),ShareGroupPtr(NULL));
-           ctx->setSurfaces(SurfacePtr(NULL),SurfacePtr(NULL));
+           thread->updateInfo(NULL,dpy,NULL,ShareGroupPtr(NULL),dpy->getManager(prevCtx->version()));
        }
     } else { //assining new context
+        VALIDATE_CONTEXT(context);
+        VALIDATE_SURFACE(draw,newDrawSrfc);
+        VALIDATE_SURFACE(read,newReadSrfc);
+
+        EglSurface* newDrawPtr = newDrawSrfc.Ptr();
+        EglSurface* newReadPtr = newReadSrfc.Ptr();
+        EglContext* newCtx     = ctx.Ptr();
+
         //surfaces compitability check
         if(!((*ctx->getConfig()).compitableWith((*newDrawPtr->getConfig()))) ||
            !((*ctx->getConfig()).compitableWith((*newReadPtr->getConfig())))) {
@@ -747,6 +764,8 @@
                 dpy->removeContext(prevCtxPtr);
            }
         }
+
+        prevCtx->setSurfaces(SurfacePtr(NULL),SurfacePtr(NULL));
     }
     return EGL_TRUE;
 }
@@ -803,7 +822,13 @@
     EglDisplay* dpy    = static_cast<EglDisplay*>(thread->eglDisplay);
     EglContext* ctx    = static_cast<EglContext*>(thread->eglContext);
     if(dpy && ctx){
-        return dpy->getContext(ContextPtr(ctx));
+        // This double check is required because a context might still be current after it is destroyed - in which case
+        // its handle should be invalid, that is EGL_NO_CONTEXT should be returned even though the context is current
+        EGLContext c = (EGLContext)ctx->getHndl();
+        if(dpy->getContext(c).Ptr())
+        {
+            return c;
+        }
     }
     return EGL_NO_CONTEXT;
 }
@@ -817,7 +842,19 @@
 
     if(dpy && ctx) {
         SurfacePtr surface = readdraw == EGL_READ ? ctx->read() : ctx->draw();
-        return dpy->getSurface(surface);
+        if(surface.Ptr())
+        {
+            // This double check is required because a surface might still be
+            // current after it is destroyed - in which case its handle should
+            // be invalid, that is EGL_NO_SURFACE should be returned even
+            // though the surface is current.
+            EGLSurface s = (EGLSurface)surface->getHndl();
+            surface = dpy->getSurface(s);
+            if(surface.Ptr())
+            {
+                return s;
+            }
+        }
     }
     return EGL_NO_SURFACE;
 }
@@ -845,7 +882,7 @@
         SurfacePtr draw = currCtx->draw();
 
         EGLNativeDisplayType nativeDisplay = dpy->nativeType();
-        if(read) {
+        if(read.Ptr()) {
             if(read->type() == EglSurface::WINDOW &&
                !EglOS::validNativeWin(nativeDisplay,reinterpret_cast<EGLNativeWindowType>(read->native()))) {
                 RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
@@ -855,7 +892,7 @@
                 RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
             }
         }
-        if(draw) {
+        if(draw.Ptr()) {
             if(draw->type() == EglSurface::WINDOW &&
                !EglOS::validNativeWin(nativeDisplay,reinterpret_cast<EGLNativeWindowType>(draw->native()))) {
                 RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp
index 041309b..8ff8fae 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp
@@ -1,4 +1,3 @@
-
 /*
 * Copyright (C) 2011 The Android Open Source Project
 *
@@ -15,69 +14,177 @@
 * limitations under the License.
 */
 #include "EglOsApi.h"
+#include "MacNative.h"
+#define MAX_PBUFFER_MIPMAP_LEVEL 1
 
-
-//TODO: implementation for mac for all funcs
 namespace EglOS {
 
-EGLNativeDisplayType getDefaultDisplay() {return NULL;}
+static std::list<EGLNativePixelFormatType> s_nativeConfigs;
+
+EGLNativeDisplayType getDefaultDisplay() {return 0;}
 
 bool releaseDisplay(EGLNativeDisplayType dpy) {
-    return false;
+    return true;
 }
 
-EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,EGLNativePixelFormatType* frmt){
-    return NULL;
+static EglConfig* pixelFormatToConfig(int index,int renderableType,EGLNativePixelFormatType* frmt){
+    if(!frmt) return NULL;
+
+    EGLint  red,green,blue,alpha,depth,stencil;
+    EGLint  supportedSurfaces,visualType,visualId;
+    EGLint  transparentType,samples;
+    EGLint  tRed,tGreen,tBlue;
+    EGLint  pMaxWidth,pMaxHeight,pMaxPixels;
+    EGLint  configId,level;
+    EGLint  window,pbuffer;
+    EGLint  doubleBuffer,colorSize;
+
+    getPixelFormatAttrib(*frmt,MAC_HAS_DOUBLE_BUFFER,&doubleBuffer);
+    if(!doubleBuffer) return NULL; //pixel double buffer
+
+    supportedSurfaces = 0;
+
+    getPixelFormatAttrib(*frmt,MAC_DRAW_TO_WINDOW,&window);
+    getPixelFormatAttrib(*frmt,MAC_DRAW_TO_PBUFFER,&pbuffer);
+
+    if(window)  supportedSurfaces |= EGL_WINDOW_BIT;
+    if(pbuffer) supportedSurfaces |= EGL_PBUFFER_BIT;
+
+    if(!supportedSurfaces) return NULL;
+
+    //default values
+    visualId                  = 0;
+    visualType                = EGL_NONE;
+    EGLenum caveat            = EGL_NONE;
+    EGLBoolean renderable     = EGL_FALSE;
+    pMaxWidth                 = PBUFFER_MAX_WIDTH;
+    pMaxHeight                = PBUFFER_MAX_HEIGHT;
+    pMaxPixels                = PBUFFER_MAX_PIXELS;
+    samples                   = 0;
+    level                     = 0;
+    tRed = tGreen = tBlue     = 0;
+
+    transparentType = EGL_NONE;
+
+    getPixelFormatAttrib(*frmt,MAC_SAMPLES_PER_PIXEL,&samples);
+    getPixelFormatAttrib(*frmt,MAC_COLOR_SIZE,&colorSize);
+    getPixelFormatAttrib(*frmt,MAC_ALPHA_SIZE,&alpha);
+    getPixelFormatAttrib(*frmt,MAC_DEPTH_SIZE,&depth);
+    getPixelFormatAttrib(*frmt,MAC_STENCIL_SIZE,&stencil);
+
+    red = green = blue = (colorSize / 4); //TODO: ask guy if it is OK
+
+    return new EglConfig(red,green,blue,alpha,caveat,(EGLint)index,depth,level,pMaxWidth,pMaxHeight,pMaxPixels,renderable,renderableType,
+                         visualId,visualType,samples,stencil,supportedSurfaces,transparentType,tRed,tGreen,tBlue,*frmt);
 }
 
-void queryConfigs(EGLNativeDisplayType dpy,ConfigsList& listOut) {
+
+static void initNativeConfigs(){
+    int nConfigs = getNumPixelFormats();
+    if(s_nativeConfigs.empty()){
+        for(int i=0; i < nConfigs ;i++){
+             EGLNativePixelFormatType frmt = getPixelFormat(i);
+             if(frmt){
+                 s_nativeConfigs.push_back(frmt);
+             }
+        }
+    }
+}
+
+void queryConfigs(EGLNativeDisplayType dpy,int renderableType,ConfigsList& listOut) {
+    int i = 0 ;
+    initNativeConfigs();
+    for(std::list<EGLNativePixelFormatType>::iterator it = s_nativeConfigs.begin(); it != s_nativeConfigs.end();it++){
+         EGLNativePixelFormatType frmt = *it;
+         EglConfig* conf = pixelFormatToConfig(i++,renderableType,&frmt);
+         if(conf){
+             listOut.push_front(conf);
+         };
+    }
 }
 
 bool validNativeWin(EGLNativeDisplayType dpy, EGLNativeWindowType win) {
-   return true;
+    unsigned int width,height;
+    return nsGetWinDims(win,&width,&height);
 }
 
+//no support for pixmap in mac
 bool validNativePixmap(EGLNativeDisplayType dpy, EGLNativePixmapType pix) {
+
    return true;
 }
 
 bool checkWindowPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativeWindowType win,EglConfig* cfg,unsigned int* width,unsigned int* height) {
-    return false;
+    int r,g,b;
+    bool ret = nsGetWinDims(win,width,height);
+ 
+    cfg->getConfAttrib(EGL_RED_SIZE,&r);
+    cfg->getConfAttrib(EGL_GREEN_SIZE,&g);
+    cfg->getConfAttrib(EGL_BLUE_SIZE,&b);
+    bool match = nsCheckColor(win,r + g + b);
+
+    return ret && match;
 }
 
+//no support for pixmap in mac
 bool checkPixmapPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativePixmapType pix,EglConfig* cfg,unsigned int* width,unsigned int* height) {
     return false;
 }
 
 EGLNativePbufferType createPbuffer(EGLNativeDisplayType dpy,EglConfig* cfg,EglPbufferSurface* srfc){
-    return NULL;
+    EGLint width,height,hasMipmap,tmp;
+    EGLint target,format;
+    srfc->getDim(&width,&height,&tmp);
+    srfc->getTexInfo(&format,&target);
+    srfc->getAttrib(EGL_MIPMAP_TEXTURE,&hasMipmap);
+    EGLint maxMipmap = hasMipmap ? MAX_PBUFFER_MIPMAP_LEVEL:0;
+    return nsCreatePBuffer(target,format,maxMipmap,width,height);
 }
 
 bool releasePbuffer(EGLNativeDisplayType dis,EGLNativePbufferType pb) {
+    nsDestroyPBuffer(pb);
     return true;
 }
 
 EGLNativeContextType createContext(EGLNativeDisplayType dpy,EglConfig* cfg,EGLNativeContextType sharedContext) {
- return NULL;
+ return nsCreateContext(cfg->nativeConfig(),sharedContext);
 }
 
 bool destroyContext(EGLNativeDisplayType dpy,EGLNativeContextType ctx) {
-    return false;
+    nsDestroyContext(ctx);
+    return true;
 }
 
-
-
 bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLNativeContextType ctx){
-    return false;
+    //dont supporting diffrent read & draw surfaces on Mac
+    if(read->native() != draw->native()) return false;
+    switch(draw->type()){
+    case EglSurface::WINDOW:
+        nsWindowMakeCurrent(ctx,draw->native());
+        break;
+    case EglSurface::PBUFFER:
+    {
+        EGLint hasMipmap;
+        draw->getAttrib(EGL_MIPMAP_TEXTURE,&hasMipmap);
+        int mipmapLevel = hasMipmap ? MAX_PBUFFER_MIPMAP_LEVEL:0;
+        nsPBufferMakeCurrent(ctx,draw->native(),mipmapLevel);
+        break;
+    }
+    case EglSurface::PIXMAP: // not supported on Mac
+    default:
+        return false;
+    }
+    return true;
 }
 
 void swapBuffers(EGLNativeDisplayType dpy,EGLNativeWindowType win) {
+    nsSwapBuffers();
 }
 
-void waitNative() {
-}
+void waitNative(){}
 
 void swapInterval(EGLNativeDisplayType dpy,EGLNativeWindowType win,int interval){
+    nsSwapInterval(&interval);
 }
 
 };
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h
index 09d29f3..33813ab 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h
@@ -17,6 +17,7 @@
 #define EGL_OS_API_H
 
 #include <EGL/egl.h>
+#include <EGL/eglinternalplatform.h>
 #ifdef __APPLE__
 #include <OpenGL/gl.h>
 #else
@@ -32,7 +33,7 @@
 
 namespace EglOS{
 
-    void queryConfigs(EGLNativeDisplayType dpy,ConfigsList& listOut);
+    void queryConfigs(EGLNativeDisplayType dpy,int renderable_type,ConfigsList& listOut);
     bool releasePbuffer(EGLNativeDisplayType dis,EGLNativePbufferType pb);
     bool destroyContext(EGLNativeDisplayType dpy,EGLNativeContextType ctx);
     bool releaseDisplay(EGLNativeDisplayType dpy);
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglSurface.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglSurface.h
index 204bbc6..29a8843 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglSurface.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglSurface.h
@@ -42,6 +42,7 @@
   bool          destroy(){return m_destroy;};
   EglConfig*    getConfig(){return m_config;};
   unsigned int  getHndl(){return m_hndl;};
+  virtual       ~EglSurface(){};
 
 private:
     static unsigned int   s_nextSurfaceHndl;
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp
index 8734e5c..a4b2cc6 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp
@@ -34,6 +34,7 @@
     case EGL_MAX_PBUFFER_PIXELS:
     case EGL_MAX_SWAP_INTERVAL:
     case EGL_MIN_SWAP_INTERVAL:
+    case EGL_RENDERABLE_TYPE:
     case EGL_NATIVE_RENDERABLE:
     case EGL_NATIVE_VISUAL_ID:
     case EGL_NATIVE_VISUAL_TYPE:
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
index ddaf2aa..11cce61 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
@@ -224,7 +224,7 @@
 
 
 
-EglConfig* pixelFormatToConfig(EGLNativeDisplayType display,EGLNativePixelFormatType* frmt,int index){
+EglConfig* pixelFormatToConfig(EGLNativeDisplayType display,int renderableType,EGLNativePixelFormatType* frmt,int index){
 
     EGLint  red,green,blue,alpha,depth,stencil;
     EGLint  supportedSurfaces,visualType,visualId;
@@ -287,12 +287,12 @@
     alpha   = frmt->cAlphaBits;
     depth   = frmt->cDepthBits;
     stencil = frmt->cStencilBits;
-    return new EglConfig(red,green,blue,alpha,caveat,(EGLint)index,depth,level,pMaxWidth,pMaxHeight,pMaxPixels,renderable,
+    return new EglConfig(red,green,blue,alpha,caveat,(EGLint)index,depth,level,pMaxWidth,pMaxHeight,pMaxPixels,renderable,renderableType,
                          visualId,visualType,samples,stencil,supportedSurfaces,transparentType,tRed,tGreen,tBlue,*frmt);
 }
 
 
-void queryConfigs(EGLNativeDisplayType display,ConfigsList& listOut) {
+void queryConfigs(EGLNativeDisplayType display,int renderableType,ConfigsList& listOut) {
     PIXELFORMATDESCRIPTOR  pfd;
     int  iPixelFormat = 1;
     HDC dpy = display->getCurrentDC();
@@ -304,7 +304,7 @@
     //inserting rest of formats
     for(iPixelFormat;iPixelFormat < nFormats; iPixelFormat++) {
          DescribePixelFormat(dpy, iPixelFormat,sizeof(PIXELFORMATDESCRIPTOR), &pfd);
-         EglConfig* pConfig = pixelFormatToConfig(display,&pfd,iPixelFormat);
+         EglConfig* pConfig = pixelFormatToConfig(display,renderableType,&pfd,iPixelFormat);
          if(pConfig) listOut.push_back(pConfig);
     }
 
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
index c863f88..a695d37 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
@@ -68,7 +68,7 @@
     return XCloseDisplay(dpy);
 }
 
-EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,EGLNativePixelFormatType* frmt){
+EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,int renderableType,EGLNativePixelFormatType* frmt){
 
     int  bSize,red,green,blue,alpha,depth,stencil;
     int  supportedSurfaces,visualType,visualId;
@@ -133,15 +133,15 @@
 
 
     return new EglConfig(red,green,blue,alpha,caveat,configId,depth,level,pMaxWidth,pMaxHeight,
-                              pMaxPixels,renderable,visualId,visualType,samples,stencil,
+                              pMaxPixels,renderable,renderableType,visualId,visualType,samples,stencil,
                               supportedSurfaces,transparentType,tRed,tGreen,tBlue,*frmt);
 }
 
-void queryConfigs(EGLNativeDisplayType dpy,ConfigsList& listOut) {
+void queryConfigs(EGLNativeDisplayType dpy,int renderableType,ConfigsList& listOut) {
     int n;
     EGLNativePixelFormatType*  frmtList =  glXGetFBConfigs(dpy,0,&n);
     for(int i =0 ;i < n ; i++) {
-        EglConfig* conf = pixelFormatToConfig(dpy,&frmtList[i]);
+        EglConfig* conf = pixelFormatToConfig(dpy,renderableType,&frmtList[i]);
         if(conf) listOut.push_back(conf);
     }
     XFree(frmtList);
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.h b/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.h
new file mode 100644
index 0000000..63145ec
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.h
@@ -0,0 +1,50 @@
+#ifndef  MAC_NATIVE_H
+#define  MAC_NATIVE_H
+
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+typedef enum {                               // Mac equivalence
+                 MAC_HAS_DOUBLE_BUFFER = 5,  // NSOpenGLPFADoubleBuffer
+                 MAC_DRAW_TO_WINDOW    = 80, // NSOpenGLPFAWindow
+                 MAC_DRAW_TO_PBUFFER   = 90, // NSOpenGLPFAPixelBuffer
+                 MAC_SAMPLES_PER_PIXEL = 56, // NSOpenGLPFASamples
+                 MAC_COLOR_SIZE        = 8,  // NSOpenGLPFAColorSize
+                 MAC_ALPHA_SIZE        = 11, // NSOpenGLPFAAlphaSize
+                 MAC_DEPTH_SIZE        = 12, // NSOpenGLPFADepthSize
+                 MAC_STENCIL_SIZE      = 13  // NSOpenGLPFAStencilSize
+             } MacPixelFormatAttribs;
+
+
+extern "C"{
+
+int   getNumPixelFormats();
+void* getPixelFormat(int i);
+void  getPixelFormatAttrib(void* pixelFormat,int attrib,int* val);
+void* nsCreateContext(void* format,void* share);
+void  nsWindowMakeCurrent(void* context,void* nativeWin);
+void  nsPBufferMakeCurrent(void* context,void* nativePBuffer,int level);
+void  nsSwapBuffers();
+void  nsSwapInterval(int *interval);
+void  nsDestroyContext(void* context);
+void* nsCreatePBuffer(GLenum target,GLenum format,int maxMip,int width,int height);
+void  nsDestroyPBuffer(void* pbuffer);
+bool  nsGetWinDims(void* win,unsigned int* width,unsigned int* height);
+bool  nsCheckColor(void* win,int colorSize);
+
+}
+
+#endif
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.m b/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.m
new file mode 100644
index 0000000..e240bc1
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.m
@@ -0,0 +1,137 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#include <stdio.h>
+#include <Cocoa/Cocoa.h>
+#include <OpenGL/OpenGL.h>
+#include "MacPixelFormatsAttribs.h"
+
+
+int getNumPixelFormats(){
+    int size;
+    NSOpenGLPixelFormatAttribute** attrib_lists = getPixelFormatsAttributes(&size);
+    return size;
+}
+
+void* getPixelFormat(int i){
+    int size;
+    NSOpenGLPixelFormatAttribute** attrib_lists = getPixelFormatsAttributes(&size);
+    return [[NSOpenGLPixelFormat alloc] initWithAttributes:attrib_lists[i]];
+}
+
+void getPixelFormatAttrib(void* pixelFormat,int attrib,int* val){
+    NSOpenGLPixelFormat *frmt = (NSOpenGLPixelFormat *)pixelFormat;
+    [frmt getValues:val forAttribute:attrib forVirtualScreen:0]; 
+}
+
+void* nsCreateContext(void* format,void* share){
+    NSOpenGLPixelFormat* frmt = (NSOpenGLPixelFormat*)format;
+    return [[NSOpenGLContext alloc] initWithFormat:frmt shareContext:share];
+}
+
+void  nsPBufferMakeCurrent(void* context,void* nativePBuffer,int level){
+    NSOpenGLContext* ctx = (NSOpenGLContext *)context;
+    NSOpenGLPixelBuffer* pbuff = (NSOpenGLPixelBuffer *)nativePBuffer;
+    if(ctx == nil){
+        [NSOpenGLContext clearCurrentContext];
+    } else {
+        if(pbuff != nil){
+            [ctx clearDrawable];
+            [ctx setPixelBuffer:pbuff cubeMapFace:0 mipMapLevel:level currentVirtualScreen:0];
+            [ctx makeCurrentContext];
+        }
+    }
+}
+
+void nsWindowMakeCurrent(void* context,void* nativeWin){
+    NSOpenGLContext* ctx = (NSOpenGLContext *)context;
+    NSView* win = (NSView *)nativeWin;
+    if(ctx == nil){
+        [NSOpenGLContext clearCurrentContext];
+    } else {
+        if(win != nil){
+            [ctx clearDrawable];
+            [ctx setView: win];
+            [ctx makeCurrentContext];
+        }
+    }
+}
+
+void nsSwapBuffers(){
+    NSOpenGLContext* ctx = [NSOpenGLContext currentContext];
+    if(ctx != nil){
+        [ctx flushBuffer];
+    }
+}
+
+void nsSwapInterval(int *interval){
+    NSOpenGLContext* ctx = [NSOpenGLContext currentContext];
+    if( ctx != nil){
+        [ctx setValues:interval forParameter:NSOpenGLCPSwapInterval];
+    }
+}
+
+
+void nsDestroyContext(void* context){
+    NSOpenGLContext *ctx = (NSOpenGLContext*)context;
+    if(ctx != nil){
+        [ctx release];
+    }
+}
+
+
+void* nsCreatePBuffer(GLenum target,GLenum format,int maxMip,int width,int height){
+    return [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:target 
+                                        textureInternalFormat:format 
+                                        textureMaxMipMapLevel:maxMip 
+                                        pixelsWide:width pixelsHigh:height];
+    
+}
+
+void nsDestroyPBuffer(void* pbuffer){
+    NSOpenGLPixelBuffer *pbuf = (NSOpenGLPixelBuffer*)pbuffer;
+    if(pbuf != nil){
+        [pbuf release];
+    }
+}
+
+bool nsGetWinDims(void* win,unsigned int* width,unsigned int* height){
+    NSView* view = (NSView*)win;
+    if(view != nil){
+        NSRect rect = [view bounds];
+        *width  = rect.size.width;
+        *height = rect.size.height;
+        return true;
+    }
+    return false;
+}
+
+bool  nsCheckColor(void* win,int colorSize){
+    NSView* view = (NSView*)win;
+   if(view != nil){
+       NSWindow* wnd = [view window];
+       if(wnd != nil){
+           NSWindowDepth limit = [wnd depthLimit];
+           NSWindowDepth defaultLimit = [NSWindow defaultDepthLimit];
+
+           int depth = (limit != 0) ? NSBitsPerPixelFromDepth(limit):
+                                      NSBitsPerPixelFromDepth(defaultLimit);
+           return depth >= colorSize;
+ 
+       }
+   }
+   return false;
+
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLfixed_ops.h b/tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.h
similarity index 64%
copy from tools/emulator/opengl/host/libs/Translator/GLES_CM/GLfixed_ops.h
copy to tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.h
index 824bb94..112aeec 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLfixed_ops.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.h
@@ -1,3 +1,6 @@
+#ifndef MAC_PIXELS_FORMATS_ATTRIBS_H	
+#define MAC_PIXELS_FORMATS_ATTRIBS_H	
+
 /*
 * Copyright (C) 2011 The Android Open Source Project
 *
@@ -13,17 +16,8 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-#ifndef _GL_FIXED_OPS_H
-#define _GL_FIXED_OPS_H
 
-#define X2F(x)  (((float)(x))/65536.0f)
-#define X2D(x)  (((double)(x))/65536.0)
-#define X2I(x)             ((x) /65536)
-
-
-#define F2X(d) ((d) > 32767.65535 ? 32767 * 65536 + 65535 :  \
-               (d) < -32768.65535 ? -32768 * 65536 + 65535 : \
-               ((GLfixed) ((d) * 65536)))
-
+#include <Cocoa/Cocoa.h>
+NSOpenGLPixelFormatAttribute** getPixelFormatsAttributes(int* size);
 
 #endif
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.m b/tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.m
new file mode 100644
index 0000000..abbaf08
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.m
@@ -0,0 +1,214 @@
+#include "MacPixelFormatsAttribs.h"
+
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+static NSOpenGLPixelFormatAttribute attrs32_1[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,32,
+    NSOpenGLPFADepthSize   ,24,
+    NSOpenGLPFAStencilSize ,8,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs32_2[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,32,
+    NSOpenGLPFAAlphaSize   ,8,
+    NSOpenGLPFADepthSize   ,24,
+    NSOpenGLPFAStencilSize ,8,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs32_3[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,32,
+    NSOpenGLPFAAlphaSize   ,8,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs32_4[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,32,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs32_5[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,32,
+    NSOpenGLPFADepthSize   ,24,
+    NSOpenGLPFASamples     ,2,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs32_6[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,32,
+    NSOpenGLPFADepthSize   ,24,
+    NSOpenGLPFASamples     ,4,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs32_7[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,32,
+    NSOpenGLPFAAlphaSize   ,8,
+    NSOpenGLPFADepthSize   ,24,
+    NSOpenGLPFAStencilSize ,8,
+    NSOpenGLPFASamples     ,4,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs16_1[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,16,
+    NSOpenGLPFADepthSize   ,24,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs16_2[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,16,
+    NSOpenGLPFADepthSize   ,24,
+    NSOpenGLPFAStencilSize ,8,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs64_1[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,64,
+    NSOpenGLPFAAlphaSize   ,16,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs64_2[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,64,
+    NSOpenGLPFAAlphaSize   ,16,
+    NSOpenGLPFADepthSize   ,24,
+    NSOpenGLPFAStencilSize ,8,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs64_3[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,64,
+    NSOpenGLPFAAlphaSize   ,16,
+    NSOpenGLPFADepthSize   ,24,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs64_4[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,64,
+    NSOpenGLPFADepthSize   ,24,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs64_5[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,64,
+    NSOpenGLPFADepthSize   ,24,
+    NSOpenGLPFAStencilSize ,8,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs128_1[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,128,
+    NSOpenGLPFAAlphaSize   ,32,
+    0
+};
+
+static NSOpenGLPixelFormatAttribute attrs128_2[] =
+{
+    NSOpenGLPFADoubleBuffer,
+    NSOpenGLPFAWindow,
+    NSOpenGLPFAPixelBuffer,
+    NSOpenGLPFAColorSize   ,128,
+    NSOpenGLPFAAlphaSize   ,32,
+    NSOpenGLPFADepthSize   ,24,
+    0
+};
+
+NSOpenGLPixelFormatAttribute** getPixelFormatsAttributes(int* size){
+static NSOpenGLPixelFormatAttribute* arr[] =
+{
+    attrs16_1,
+    attrs16_2,
+    attrs32_1,
+    attrs32_2,
+    attrs32_3,
+    attrs32_4,
+    attrs32_5,
+    attrs32_6,
+    attrs32_7,
+    attrs64_1,
+    attrs64_2,
+    attrs64_3,
+    attrs64_4,
+    attrs64_5,
+    attrs128_1,
+    attrs128_2
+};
+    *size = sizeof(arr)/sizeof(arr[0]);
+    return arr;
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp
index 6814fe9..8acf8a1 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp
@@ -17,7 +17,12 @@
 #include <GLcommon/ThreadInfo.h>
 
 
-void ThreadInfo::updateInfo(void* eglCtx,void* dpy,void* glesCtx,ShareGroupPtr share,ObjectNameManager* manager) {
+void ThreadInfo::updateInfo(EglContext* eglCtx,
+                            EglDisplay* dpy,
+                            GLEScontext* glesCtx,
+                            ShareGroupPtr share,
+                            ObjectNameManager* manager) {
+
     eglContext  = eglCtx;
     eglDisplay  = dpy;
     glesContext = glesCtx;
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk b/tools/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk
index 67eab95..b18492e 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk
@@ -4,32 +4,24 @@
 include $(CLEAR_VARS)
 
 translator_path := $(LOCAL_PATH)/..
-#exclude darwin builds
-ifeq (, $(findstring $(HOST_OS), darwin))
 
-LOCAL_SRC_FILES :=    \
-     GLDispatch.cpp   \
-     GLEScontext.cpp  \
-     GLESimp.cpp      \
-     GLESpointer.cpp  \
-     GLESvalidate.cpp \
-     GLESutils.cpp    \
-     GLESbuffer.cpp   \
-     TextureUtils.cpp \
-     RangeManip.cpp
+LOCAL_SRC_FILES :=      \
+     GLEScmImp.cpp      \
+     GLEScmUtils.cpp    \
+     TextureUtils.cpp   \
+     GLEScmContext.cpp  \
+     GLEScmValidate.cpp 
 
 LOCAL_C_INCLUDES += \
                  $(translator_path)/include \
                  $(translator_path)/../../../shared
 
 LOCAL_STATIC_LIBRARIES := \
+    libGLcommon           \
     libOpenglOsUtils      \
     libutils              \
     libcutils
 
-LOCAL_SHARED_LIBRARIES := \
-    libGLcommon
-
 LOCAL_CFLAGS := -g -O0
 LOCAL_MODULE_TAGS := debug
 LOCAL_MODULE := libGLES_CM_translator
@@ -44,4 +36,3 @@
 
 include $(BUILD_HOST_SHARED_LIBRARY)
 
-endif
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
new file mode 100644
index 0000000..3c4758a
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
@@ -0,0 +1,208 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include "GLEScmContext.h"
+#include "GLEScmUtils.h"
+#include <GLcommon/GLutils.h>
+#include <string.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
+void GLEScmContext::init() {
+    android::Mutex::Autolock mutex(s_lock);
+    if(!m_initialized) {
+        s_glDispatch.dispatchFuncs(GLES_1_1);
+        initCapsLocked(s_glDispatch.glGetString(GL_EXTENSIONS));
+        initExtensionString();
+    }
+    m_texCoords = new GLESpointer[s_glSupport.maxTexUnits];
+    m_map[GL_TEXTURE_COORD_ARRAY]  = &m_texCoords[m_clientActiveTexture];
+    m_initialized = true;
+}
+
+GLEScmContext::GLEScmContext():GLEScontext(),m_pointsIndex(-1), m_clientActiveTexture(0) {
+
+    m_map[GL_COLOR_ARRAY]          = new GLESpointer();
+    m_map[GL_NORMAL_ARRAY]         = new GLESpointer();
+    m_map[GL_VERTEX_ARRAY]         = new GLESpointer();
+    m_map[GL_POINT_SIZE_ARRAY_OES] = new GLESpointer();
+}
+
+
+void GLEScmContext::setActiveTexture(GLenum tex) {
+   m_activeTexture = tex - GL_TEXTURE0;
+}
+
+void GLEScmContext::setClientActiveTexture(GLenum tex) {
+   m_clientActiveTexture = tex - GL_TEXTURE0;
+   m_map[GL_TEXTURE_COORD_ARRAY] = &m_texCoords[m_clientActiveTexture];
+}
+
+GLEScmContext::~GLEScmContext(){
+    if(m_texCoords){
+        delete[] m_texCoords;
+        m_texCoords = NULL;
+    }
+}
+
+
+//sending data to server side
+void GLEScmContext::sendArr(GLvoid* arr,GLenum arrayType,GLint size,GLsizei stride,int index) {
+    switch(arrayType) {
+        case GL_VERTEX_ARRAY:
+            s_glDispatch.glVertexPointer(size,GL_FLOAT,stride,arr);
+            break;
+        case GL_NORMAL_ARRAY:
+            s_glDispatch.glNormalPointer(GL_FLOAT,stride,arr);
+            break;
+        case GL_TEXTURE_COORD_ARRAY:
+            s_glDispatch.glTexCoordPointer(size,GL_FLOAT,stride,arr);
+            break;
+        case GL_COLOR_ARRAY:
+            s_glDispatch.glColorPointer(size,GL_FLOAT,stride,arr);
+            break;
+        case GL_POINT_SIZE_ARRAY_OES:
+            m_pointsIndex = index;
+            break;
+    }
+}
+
+void GLEScmContext::convertArrs(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct) {
+    ArraysMap::iterator it;
+    unsigned int index = 0;
+    m_pointsIndex = -1;
+
+    //going over all clients arrays Pointers
+    for ( it=m_map.begin() ; it != m_map.end(); it++ ) {
+        GLenum array_id   = (*it).first;
+        GLESpointer* p = (*it).second;
+
+        if(array_id == GL_TEXTURE_COORD_ARRAY) continue; //handling textures later
+        chooseConvertMethod(fArrs,first,count,type,indices,direct,p,array_id,index);
+    }
+
+    unsigned int activeTexture = m_clientActiveTexture + GL_TEXTURE0;
+
+    s_lock.lock();
+    int maxTexUnits = s_glSupport.maxTexUnits;
+    s_lock.unlock();
+
+    //converting all texture coords arrays
+    for(int i=0; i< maxTexUnits;i++) {
+
+        unsigned int tex = GL_TEXTURE0+i;
+        setClientActiveTexture(tex);
+        s_glDispatch.glClientActiveTexture(tex);
+
+        GLenum array_id   = GL_TEXTURE_COORD_ARRAY;
+        GLESpointer* p = m_map[array_id];
+        chooseConvertMethod(fArrs,first,count,type,indices,direct,p,array_id,index);
+    }
+
+    setClientActiveTexture(activeTexture);
+    s_glDispatch.glClientActiveTexture(activeTexture);
+}
+
+void GLEScmContext::drawPoints(PointSizeIndices* points) {
+
+    GLushort* indices = NULL;
+    int last_size = 0;
+
+    //drawing each group of vertices by the points size
+    for(PointSizeIndices::iterator it = points->begin();it != points->end(); it++) {
+            int count = (*it).second.size();
+            int pointSize = (*it).first;
+            std::vector<int>& arr = (*it).second;
+
+            if(count > last_size) {
+             if(indices) delete [] indices;
+             indices = new GLushort[count];
+            }
+            int i = 0 ;
+            for(std::vector<int>::iterator it2 = arr.begin();it2 != arr.end();it2++) {
+                indices[i++] = (*it2);
+            }
+            s_glDispatch.glPointSize(pointSize);
+            s_glDispatch.glDrawElements(GL_POINTS,count,GL_UNSIGNED_SHORT,indices);
+    }
+    if(indices) delete [] indices;
+}
+
+void  GLEScmContext::drawPointsData(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices_in,bool isElemsDraw) {
+    const GLfloat  *pointsArr =  NULL;
+    int stride = 0; //steps in GLfloats
+
+    //choosing the right points sizes array source
+    if(m_pointsIndex >= 0) { //point size array was converted
+        pointsArr=fArrs.arrays[m_pointsIndex];
+        stride = 1;
+    } else {
+        GLESpointer* p = m_map[GL_POINT_SIZE_ARRAY_OES];
+        pointsArr = static_cast<const GLfloat*>(isBindedBuffer(GL_ARRAY_BUFFER)?p->getBufferData():p->getArrayData());
+        stride = p->getStride()?p->getStride()/sizeof(GLfloat):1;
+    }
+
+    //filling  arrays before sorting them
+    PointSizeIndices  points;
+    if(isElemsDraw) {
+        for(int i=0; i< count; i++) {
+            GLushort index = (type == GL_UNSIGNED_SHORT?
+                    static_cast<const GLushort*>(indices_in)[i]:
+                    static_cast<const GLubyte*>(indices_in)[i]);
+            points[pointsArr[index*stride]].push_back(index);
+        }
+    } else {
+        for(int i=0; i< count; i++) {
+            points[pointsArr[first+i*stride]].push_back(i+first);
+        }
+    }
+    drawPoints(&points);
+}
+
+void  GLEScmContext::drawPointsArrs(GLESFloatArrays& arrs,GLint first,GLsizei count) {
+    drawPointsData(arrs,first,count,0,NULL,false);
+}
+
+void GLEScmContext::drawPointsElems(GLESFloatArrays& arrs,GLsizei count,GLenum type,const GLvoid* indices_in) {
+    drawPointsData(arrs,0,count,type,indices_in,true);
+}
+
+void GLEScmContext::initExtensionString() {
+    *s_glExtensions = "GL_OES_blend_func_separate GL_OES_blend_equation_separate GL_OES_blend_subtract "
+                      "GL_OES_byte_coordinates GL_OES_compressed_paletted_texture GL_OES_point_size_array "
+                      "GL_OES_point_sprite GL_OES_single_precision GL_OES_stencil_wrap GL_OES_texture_env_crossbar "
+                      "GL_OES_texture_mirored_repeat GL_OES_EGL_image GL_OES_element_index_uint GL_OES_draw_texture "
+                      "GL_OES_texture_cube_map GL_OES_draw_texture ";
+    if (s_glSupport.GL_OES_READ_FORMAT)
+        *s_glExtensions+="GL_OES_read_format ";
+    if (s_glSupport.GL_EXT_FRAMEBUFFER_OBJECT) {
+        *s_glExtensions+="GL_OES_framebuffer_object GL_OES_depth24 GL_OES_depth32 GL_OES_fbo_render_mipmap "
+                         "GL_OES_rgb8_rgba8 GL_OES_stencil1 GL_OES_stencil4 GL_OES_stencil8 ";
+    }
+    if (s_glSupport.GL_NV_PACKED_DEPTH_STENCIL)
+        *s_glExtensions+="GL_OES_packed_depth_stencil ";
+    if (s_glSupport.GL_EXT_TEXTURE_FORMAT_BGRA8888)
+        *s_glExtensions+="GL_EXT_texture_format_BGRA8888 GL_APPLE_texture_format_BGRA8888 ";
+    if (s_glSupport.GL_ARB_MATRIX_PALETTE && s_glSupport.GL_ARB_VERTEX_BLEND) {
+        *s_glExtensions+="GL_OES_matrix_palette ";
+        GLint max_palette_matrices=0;
+        GLint max_vertex_units=0;
+        dispatcher().glGetIntegerv(GL_MAX_PALETTE_MATRICES_OES,&max_palette_matrices);
+        dispatcher().glGetIntegerv(GL_MAX_VERTEX_UNITS_OES,&max_vertex_units);
+        if (max_palette_matrices>=32 && max_vertex_units>=4)
+            *s_glExtensions+="GL_OES_extended_matrix_palette ";
+    } 
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h
new file mode 100644
index 0000000..d683755
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h
@@ -0,0 +1,59 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef GLES_CM_CONTEX_H
+#define GLES_CM_CONTEX_H
+
+#include <GLcommon/GLDispatch.h>
+#include <GLcommon/GLESpointer.h>
+#include <GLcommon/GLESbuffer.h>
+#include <GLcommon/GLEScontext.h>
+#include <map>
+#include <vector>
+#include <string>
+#include <utils/threads.h>
+
+
+typedef std::map<GLfloat,std::vector<int> > PointSizeIndices;
+
+class GLEScmContext: public GLEScontext
+{
+public:
+    void init();
+    GLEScmContext();
+
+    void setActiveTexture(GLenum tex);
+    void  setClientActiveTexture(GLenum tex);
+    GLenum  getActiveTexture() { return GL_TEXTURE0 + m_activeTexture;};
+    GLenum  getClientActiveTexture() { return GL_TEXTURE0 + m_clientActiveTexture;};
+    void convertArrs(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct);
+    void drawPointsArrs(GLESFloatArrays& arrs,GLint first,GLsizei count);
+    void drawPointsElems(GLESFloatArrays& arrs,GLsizei count,GLenum type,const GLvoid* indices);
+  
+    ~GLEScmContext();
+
+private:
+    void sendArr(GLvoid* arr,GLenum arrayType,GLint size,GLsizei stride,int pointsIndex = -1);
+    void drawPoints(PointSizeIndices* points);
+    void drawPointsData(GLESFloatArrays& arrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices_in,bool isElemsDraw);
+    void initExtensionString();
+
+    GLESpointer*          m_texCoords;
+    int                   m_pointsIndex;
+    unsigned int          m_clientActiveTexture;
+};
+
+#endif
+
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
new file mode 100644
index 0000000..e4afd54
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
@@ -0,0 +1,1903 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifdef _WIN32
+#undef GL_API
+#define GL_API __declspec(dllexport)
+#endif
+#define GL_GLEXT_PROTOTYPES
+#include "GLEScmContext.h"
+#include "GLEScmValidate.h"
+#include "GLEScmUtils.h"
+#include "TextureUtils.h"
+
+#include <stdio.h>
+#include <GLcommon/gldefs.h>
+#include <GLcommon/GLDispatch.h>
+#include <GLcommon/GLfixed_ops.h>
+#include <GLcommon/TranslatorIfaces.h>
+#include <GLcommon/ThreadInfo.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+#include <cmath>
+#include <map>
+
+extern "C" {
+
+//decleration
+static void initContext(GLEScontext* ctx);
+static void deleteGLESContext(GLEScontext* ctx);
+static void setShareGroup(GLEScontext* ctx,ShareGroupPtr grp);
+static GLEScontext* createGLESContext();
+static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName);
+
+}
+
+/************************************** GLES EXTENSIONS *********************************************************/
+//extentions descriptor
+typedef std::map<std::string, __translatorMustCastToProperFunctionPointerType> ProcTableMap;
+ProcTableMap *s_glesExtensions = NULL;
+/****************************************************************************************************************/
+
+static EGLiface*  s_eglIface = NULL;
+static GLESiface  s_glesIface = {
+    createGLESContext:createGLESContext,
+    initContext      :initContext,
+    deleteGLESContext:deleteGLESContext,
+    flush            :(FUNCPTR)glFlush,
+    finish           :(FUNCPTR)glFinish,
+    setShareGroup    :setShareGroup,
+    getProcAddress   :getProcAddress
+};
+
+#include <GLcommon/GLESmacros.h>
+
+extern "C" {
+
+static void initContext(GLEScontext* ctx) {
+    ctx->init();
+}
+
+static GLEScontext* createGLESContext() {
+    return new GLEScmContext();
+}
+
+static void deleteGLESContext(GLEScontext* ctx) {
+    if(ctx) delete ctx;
+}
+
+static void setShareGroup(GLEScontext* ctx,ShareGroupPtr grp) {
+    if(ctx) {
+        ctx->setShareGroup(grp);
+    }
+}
+static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName) {
+    GET_CTX_RET(NULL)
+    ctx->getGlobalLock();
+    static bool proc_table_initialized = false;
+    if (!proc_table_initialized) {
+        proc_table_initialized = true;
+        if (!s_glesExtensions)
+            s_glesExtensions = new ProcTableMap();
+        else
+            s_glesExtensions->clear();
+        (*s_glesExtensions)["glEGLImageTargetTexture2DOES"] = (__translatorMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES;
+        (*s_glesExtensions)["glEGLImageTargetRenderbufferStorageOES"]=(__translatorMustCastToProperFunctionPointerType)glEGLImageTargetRenderbufferStorageOES;
+        (*s_glesExtensions)["glBlendEquationSeparateOES"] = (__translatorMustCastToProperFunctionPointerType)glBlendEquationSeparateOES;
+        (*s_glesExtensions)["glBlendFuncSeparateOES"] = (__translatorMustCastToProperFunctionPointerType)glBlendFuncSeparateOES;
+        (*s_glesExtensions)["glBlendEquationOES"] = (__translatorMustCastToProperFunctionPointerType)glBlendEquationOES;
+
+        if (ctx->getCaps()->GL_ARB_MATRIX_PALETTE && ctx->getCaps()->GL_ARB_VERTEX_BLEND) {
+            (*s_glesExtensions)["glCurrentPaletteMatrixOES"] = (__translatorMustCastToProperFunctionPointerType)glCurrentPaletteMatrixOES;
+            (*s_glesExtensions)["glLoadPaletteFromModelViewMatrixOES"]=(__translatorMustCastToProperFunctionPointerType)glLoadPaletteFromModelViewMatrixOES;
+            (*s_glesExtensions)["glMatrixIndexPointerOES"] = (__translatorMustCastToProperFunctionPointerType)glMatrixIndexPointerOES;
+            (*s_glesExtensions)["glWeightPointerOES"] = (__translatorMustCastToProperFunctionPointerType)glWeightPointerOES;
+        }
+        (*s_glesExtensions)["glDepthRangefOES"] = (__translatorMustCastToProperFunctionPointerType)glDepthRangef;
+        (*s_glesExtensions)["glFrustumfOES"] = (__translatorMustCastToProperFunctionPointerType)glFrustumf;
+        (*s_glesExtensions)["glOrthofOES"] = (__translatorMustCastToProperFunctionPointerType)glOrthof;
+        (*s_glesExtensions)["glClipPlanefOES"] = (__translatorMustCastToProperFunctionPointerType)glClipPlanef;
+        (*s_glesExtensions)["glGetClipPlanefOES"] = (__translatorMustCastToProperFunctionPointerType)glGetClipPlanef;
+        (*s_glesExtensions)["glClearDepthfOES"] = (__translatorMustCastToProperFunctionPointerType)glClearDepthf;
+        (*s_glesExtensions)["glPointSizePointerOES"] = (__translatorMustCastToProperFunctionPointerType)glPointSizePointerOES;
+        (*s_glesExtensions)["glTexGenfOES"] = (__translatorMustCastToProperFunctionPointerType)glTexGenfOES;
+        (*s_glesExtensions)["glTexGenfvOES"] = (__translatorMustCastToProperFunctionPointerType)glTexGenfvOES;
+        (*s_glesExtensions)["glTexGeniOES"] = (__translatorMustCastToProperFunctionPointerType)glTexGeniOES;
+        (*s_glesExtensions)["glTexGenivOES"] = (__translatorMustCastToProperFunctionPointerType)glTexGenivOES;
+        (*s_glesExtensions)["glTexGenxOES"] = (__translatorMustCastToProperFunctionPointerType)glTexGenxOES;
+        (*s_glesExtensions)["glTexGenxvOES"] = (__translatorMustCastToProperFunctionPointerType)glTexGenxvOES;
+        (*s_glesExtensions)["glGetTexGenfvOES"] = (__translatorMustCastToProperFunctionPointerType)glGetTexGenfvOES;
+        (*s_glesExtensions)["glGetTexGenivOES"] = (__translatorMustCastToProperFunctionPointerType)glGetTexGenivOES;
+        (*s_glesExtensions)["glGetTexGenxvOES"] = (__translatorMustCastToProperFunctionPointerType)glGetTexGenxvOES;
+        if (ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT) {
+            (*s_glesExtensions)["glIsRenderbufferOES"] = (__translatorMustCastToProperFunctionPointerType)glIsRenderbufferOES;
+            (*s_glesExtensions)["glBindRenderbufferOES"] = (__translatorMustCastToProperFunctionPointerType)glBindRenderbufferOES;
+            (*s_glesExtensions)["glDeleteRenderbuffersOES"] = (__translatorMustCastToProperFunctionPointerType)glDeleteRenderbuffersOES;
+            (*s_glesExtensions)["glGenRenderbuffersOES"] = (__translatorMustCastToProperFunctionPointerType)glGenRenderbuffersOES;
+            (*s_glesExtensions)["glRenderbufferStorageOES"] = (__translatorMustCastToProperFunctionPointerType)glRenderbufferStorageOES;
+            (*s_glesExtensions)["glGetRenderbufferParameterivOES"] = (__translatorMustCastToProperFunctionPointerType)glGetRenderbufferParameterivOES;
+            (*s_glesExtensions)["glIsFramebufferOES"] = (__translatorMustCastToProperFunctionPointerType)glIsFramebufferOES;
+            (*s_glesExtensions)["glBindFramebufferOES"] = (__translatorMustCastToProperFunctionPointerType)glBindFramebufferOES;
+            (*s_glesExtensions)["glDeleteFramebuffersOES"] = (__translatorMustCastToProperFunctionPointerType)glDeleteFramebuffersOES;
+            (*s_glesExtensions)["glGenFramebuffersOES"] = (__translatorMustCastToProperFunctionPointerType)glGenFramebuffersOES;
+            (*s_glesExtensions)["glCheckFramebufferStatusOES"] = (__translatorMustCastToProperFunctionPointerType)glCheckFramebufferStatusOES;
+            (*s_glesExtensions)["glFramebufferTexture2DOES"] = (__translatorMustCastToProperFunctionPointerType)glFramebufferTexture2DOES;
+            (*s_glesExtensions)["glFramebufferRenderbufferOES"] = (__translatorMustCastToProperFunctionPointerType)glFramebufferRenderbufferOES;
+            (*s_glesExtensions)["glGetFramebufferAttachmentParameterivOES"] = (__translatorMustCastToProperFunctionPointerType)glGetFramebufferAttachmentParameterivOES;
+            (*s_glesExtensions)["glGenerateMipmapOES"] = (__translatorMustCastToProperFunctionPointerType)glGenerateMipmapOES;
+        }
+        (*s_glesExtensions)["glDrawTexsOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexsOES;
+        (*s_glesExtensions)["glDrawTexiOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexiOES;
+        (*s_glesExtensions)["glDrawTexfOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexfOES;
+        (*s_glesExtensions)["glDrawTexxOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexxOES;
+        (*s_glesExtensions)["glDrawTexsvOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexsvOES;
+        (*s_glesExtensions)["glDrawTexivOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexivOES;
+        (*s_glesExtensions)["glDrawTexfvOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexfvOES;
+        (*s_glesExtensions)["glDrawTexxvOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexxvOES;
+    }
+    __translatorMustCastToProperFunctionPointerType ret=NULL;
+    ProcTableMap::iterator val = s_glesExtensions->find(procName);
+    if (val!=s_glesExtensions->end())
+        ret = val->second;
+    ctx->releaseGlobalLock();
+
+    return ret;
+}
+
+GLESiface* __translator_getIfaces(EGLiface* eglIface){
+    s_eglIface = eglIface;
+    return & s_glesIface;
+}
+
+}
+
+static TextureData* getTextureData(){
+    GET_CTX_RET(NULL);
+    unsigned int tex = ctx->getBindedTexture();
+    if (tex==0)
+        return NULL;
+    TextureData *texData = NULL;
+    ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex);
+    if(!objData.Ptr()){
+        texData = new TextureData();
+        thrd->shareGroup->setObjectData(TEXTURE, tex, ObjectDataPtr(texData));
+    } else {
+        texData = (TextureData*)objData.Ptr();
+    }
+    return texData;
+}
+
+GL_API GLboolean GL_APIENTRY glIsBuffer(GLuint buffer) {
+    GET_CTX_RET(GL_FALSE)
+
+    if(buffer && thrd->shareGroup.Ptr()) {
+       ObjectDataPtr objData = thrd->shareGroup->getObjectData(VERTEXBUFFER,buffer);
+       return objData.Ptr() ? ((GLESbuffer*)objData.Ptr())->wasBinded():GL_FALSE;
+    }
+    return GL_FALSE;
+}
+
+GL_API GLboolean GL_APIENTRY  glIsEnabled( GLenum cap) {
+    GET_CTX_CM_RET(GL_FALSE)
+    RET_AND_SET_ERROR_IF(!GLEScmValidate::capability(cap,ctx->getMaxLights(),ctx->getMaxClipPlanes()),GL_INVALID_ENUM,GL_FALSE);
+
+    if (cap == GL_POINT_SIZE_ARRAY_OES) 
+        return ctx->isArrEnabled(cap);
+    else if (cap==GL_TEXTURE_GEN_STR_OES)
+        return (ctx->dispatcher().glIsEnabled(GL_TEXTURE_GEN_S) &&
+                ctx->dispatcher().glIsEnabled(GL_TEXTURE_GEN_T) &&
+                ctx->dispatcher().glIsEnabled(GL_TEXTURE_GEN_R));
+    else
+        return ctx->dispatcher().glIsEnabled(cap);
+}
+
+GL_API GLboolean GL_APIENTRY  glIsTexture( GLuint texture) {
+    GET_CTX_RET(GL_FALSE)
+    if(texture && thrd->shareGroup.Ptr()){
+        return thrd->shareGroup->isObject(TEXTURE,texture) ? GL_TRUE :GL_FALSE;
+    }
+    return ctx->dispatcher().glIsTexture(texture);
+}
+
+GL_API GLenum GL_APIENTRY  glGetError(void) {
+    GET_CTX_RET(GL_NO_ERROR)
+    GLenum err = ctx->getGLerror();
+    if(err != GL_NO_ERROR) {
+        ctx->setGLerror(GL_NO_ERROR);
+        return err;
+    }
+
+    return ctx->dispatcher().glGetError();
+}
+
+GL_API const GLubyte * GL_APIENTRY  glGetString( GLenum name) {
+
+    GET_CTX_RET(NULL)
+    static GLubyte VENDOR[]     = "Google";
+    static GLubyte RENDERER[]   = "OpenGL ES-CM 1.1";
+    static GLubyte VERSION[]    = "OpenGL ES-CM 1.1";
+
+    switch(name) {
+        case GL_VENDOR:
+            return VENDOR;
+        case GL_RENDERER:
+            return RENDERER;
+        case GL_VERSION:
+            return VERSION;
+        case GL_EXTENSIONS:
+            return (const GLubyte*)ctx->getExtensionString();
+        default:
+            RET_AND_SET_ERROR_IF(true,GL_INVALID_ENUM,NULL);
+    }
+}
+
+GL_API void GL_APIENTRY  glActiveTexture( GLenum texture) {
+    GET_CTX_CM()
+    SET_ERROR_IF(!GLEScmValidate::textureEnum(texture,ctx->getMaxTexUnits()),GL_INVALID_ENUM);
+    ctx->setActiveTexture(texture);
+    ctx->dispatcher().glActiveTexture(texture);
+}
+
+GL_API void GL_APIENTRY  glAlphaFunc( GLenum func, GLclampf ref) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::alphaFunc(func),GL_INVALID_ENUM);
+    ctx->dispatcher().glAlphaFunc(func,ref);
+}
+
+
+GL_API void GL_APIENTRY  glAlphaFuncx( GLenum func, GLclampx ref) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::alphaFunc(func),GL_INVALID_ENUM);
+    ctx->dispatcher().glAlphaFunc(func,X2F(ref));
+}
+
+
+GL_API void GL_APIENTRY  glBindBuffer( GLenum target, GLuint buffer) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::bufferTarget(target),GL_INVALID_ENUM);
+
+    //if buffer wasn't generated before,generate one
+    if(thrd->shareGroup.Ptr() && !thrd->shareGroup->isObject(VERTEXBUFFER,buffer)){
+        thrd->shareGroup->genName(VERTEXBUFFER,buffer);
+        thrd->shareGroup->setObjectData(VERTEXBUFFER,buffer,ObjectDataPtr(new GLESbuffer()));
+    }
+    ctx->bindBuffer(target,buffer);
+    GLESbuffer* vbo = (GLESbuffer*)thrd->shareGroup->getObjectData(VERTEXBUFFER,buffer).Ptr();
+    vbo->wasBinded();
+}
+
+
+GL_API void GL_APIENTRY  glBindTexture( GLenum target, GLuint texture) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::textureTarget(target),GL_INVALID_ENUM)
+
+    GLuint globalTextureName = texture;
+    if(texture && thrd->shareGroup.Ptr()){
+        globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture);
+        //if texture wasn't generated before,generate one
+        if(!globalTextureName){
+            thrd->shareGroup->genName(TEXTURE,texture);
+            globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture);
+        }
+    }
+    ctx->setBindedTexture(texture);
+    ctx->dispatcher().glBindTexture(target,globalTextureName);
+}
+
+GL_API void GL_APIENTRY  glBlendFunc( GLenum sfactor, GLenum dfactor) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::blendSrc(sfactor) || !GLEScmValidate::blendDst(dfactor),GL_INVALID_ENUM)
+    ctx->dispatcher().glBlendFunc(sfactor,dfactor);
+}
+
+GL_API void GL_APIENTRY  glBufferData( GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::bufferTarget(target),GL_INVALID_ENUM);
+    SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
+    ctx->setBufferData(target,size,data,usage);
+}
+
+GL_API void GL_APIENTRY  glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) {
+    GET_CTX()
+    SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
+    SET_ERROR_IF(!GLEScmValidate::bufferTarget(target),GL_INVALID_ENUM);
+    SET_ERROR_IF(!ctx->setBufferSubData(target,offset,size,data),GL_INVALID_VALUE);
+}
+
+GL_API void GL_APIENTRY  glClear( GLbitfield mask) {
+    GET_CTX()
+    ctx->dispatcher().glClear(mask);
+}
+
+GL_API void GL_APIENTRY  glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
+    GET_CTX()
+    ctx->dispatcher().glClearColor(red,green,blue,alpha);
+}
+
+GL_API void GL_APIENTRY  glClearColorx( GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) {
+    GET_CTX()
+    ctx->dispatcher().glClearColor(X2F(red),X2F(green),X2F(blue),X2F(alpha));
+}
+
+
+GL_API void GL_APIENTRY  glClearDepthf( GLclampf depth) {
+    GET_CTX()
+    ctx->dispatcher().glClearDepth(depth);
+}
+
+GL_API void GL_APIENTRY  glClearDepthx( GLclampx depth) {
+    GET_CTX()
+    ctx->dispatcher().glClearDepth(X2F(depth));
+}
+
+GL_API void GL_APIENTRY  glClearStencil( GLint s) {
+    GET_CTX()
+    ctx->dispatcher().glClearStencil(s);
+}
+
+GL_API void GL_APIENTRY  glClientActiveTexture( GLenum texture) {
+    GET_CTX_CM()
+    SET_ERROR_IF(!GLEScmValidate::textureEnum(texture,ctx->getMaxTexUnits()),GL_INVALID_ENUM);
+    ctx->setClientActiveTexture(texture);
+    ctx->dispatcher().glClientActiveTexture(texture);
+
+}
+
+GL_API void GL_APIENTRY  glClipPlanef( GLenum plane, const GLfloat *equation) {
+    GET_CTX()
+    GLdouble tmpEquation[4];
+
+    for(int i = 0; i < 4; i++) {
+         tmpEquation[i] = static_cast<GLdouble>(equation[i]);
+    }
+    ctx->dispatcher().glClipPlane(plane,tmpEquation);
+}
+
+GL_API void GL_APIENTRY  glClipPlanex( GLenum plane, const GLfixed *equation) {
+    GET_CTX()
+    GLdouble tmpEquation[4];
+    for(int i = 0; i < 4; i++) {
+        tmpEquation[i] = X2D(equation[i]);
+    }
+    ctx->dispatcher().glClipPlane(plane,tmpEquation);
+}
+
+GL_API void GL_APIENTRY  glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
+    GET_CTX()
+    ctx->dispatcher().glColor4f(red,green,blue,alpha);
+}
+
+GL_API void GL_APIENTRY  glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) {
+    GET_CTX()
+    ctx->dispatcher().glColor4ub(red,green,blue,alpha);
+}
+
+GL_API void GL_APIENTRY  glColor4x( GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) {
+    GET_CTX()
+    ctx->dispatcher().glColor4f(X2F(red),X2F(green),X2F(blue),X2F(alpha));
+}
+
+GL_API void GL_APIENTRY  glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
+    GET_CTX()
+    ctx->dispatcher().glColorMask(red,green,blue,alpha);
+}
+
+GL_API void GL_APIENTRY  glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::colorPointerParams(size,stride),GL_INVALID_VALUE);
+
+    const GLvoid* data = ctx->setPointer(GL_COLOR_ARRAY,size,type,stride,pointer);
+    if(type != GL_FIXED) ctx->dispatcher().glColorPointer(size,type,stride,data);
+}
+
+GL_API void GL_APIENTRY  glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) {
+    GET_CTX_CM()
+    SET_ERROR_IF(!(GLEScmValidate::texCompImgFrmt(internalformat) && GLEScmValidate::textureTargetEx(target)),GL_INVALID_ENUM);
+    SET_ERROR_IF(level > log2(ctx->getMaxTexSize())|| border !=0 || level > 0 || !GLEScmValidate::texImgDim(width,height,ctx->getMaxTexSize()+2),GL_INVALID_VALUE)
+
+    int nMipmaps = -level + 1;
+    GLsizei tmpWidth  = width;
+    GLsizei tmpHeight = height;
+
+    for(int i = 0; i < nMipmaps ; i++)
+    {
+       GLenum uncompressedFrmt;
+       unsigned char* uncompressed = uncompressTexture(internalformat,uncompressedFrmt,width,height,imageSize,data,i);
+       ctx->dispatcher().glTexImage2D(target,i,uncompressedFrmt,width,height,border,uncompressedFrmt,GL_UNSIGNED_BYTE,uncompressed);
+       tmpWidth/=2;
+       tmpHeight/=2;
+       delete uncompressed;
+    }
+}
+
+GL_API void GL_APIENTRY  glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) {
+    GET_CTX_CM()
+    SET_ERROR_IF(!(GLEScmValidate::texCompImgFrmt(format) && GLEScmValidate::textureTargetEx(target)),GL_INVALID_ENUM);
+    SET_ERROR_IF(level < 0 || level > log2(ctx->getMaxTexSize()),GL_INVALID_VALUE)
+
+    GLenum uncompressedFrmt;
+    unsigned char* uncompressed = uncompressTexture(format,uncompressedFrmt,width,height,imageSize,data,level);
+    ctx->dispatcher().glTexSubImage2D(target,level,xoffset,yoffset,width,height,uncompressedFrmt,GL_UNSIGNED_BYTE,uncompressed);
+    delete uncompressed;
+}
+
+GL_API void GL_APIENTRY  glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
+    GET_CTX()
+    SET_ERROR_IF(!(GLEScmValidate::pixelFrmt(ctx,internalformat) && GLEScmValidate::textureTargetEx(target)),GL_INVALID_ENUM);
+    SET_ERROR_IF(border != 0,GL_INVALID_VALUE);
+    ctx->dispatcher().glCopyTexImage2D(target,level,internalformat,x,y,width,height,border);
+}
+
+GL_API void GL_APIENTRY  glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::textureTargetEx(target),GL_INVALID_ENUM);
+    ctx->dispatcher().glCopyTexSubImage2D(target,level,xoffset,yoffset,x,y,width,height);
+}
+
+GL_API void GL_APIENTRY  glCullFace( GLenum mode) {
+    GET_CTX()
+    ctx->dispatcher().glCullFace(mode);
+}
+
+GL_API void GL_APIENTRY  glDeleteBuffers( GLsizei n, const GLuint *buffers) {
+    GET_CTX()
+    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
+    if(thrd->shareGroup.Ptr()) {
+        for(int i=0; i < n; i++){
+           thrd->shareGroup->deleteName(VERTEXBUFFER,buffers[i]);
+           ctx->unbindBuffer(buffers[i]);
+        }
+    }
+}
+
+GL_API void GL_APIENTRY  glDeleteTextures( GLsizei n, const GLuint *textures) {
+    GET_CTX()
+    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
+    if(thrd->shareGroup.Ptr()) {
+        for(int i=0; i < n; i++){
+           thrd->shareGroup->deleteName(TEXTURE,textures[i]);
+           const GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,textures[i]);
+           ctx->dispatcher().glDeleteTextures(1,&globalTextureName);
+        }
+    }
+}
+
+GL_API void GL_APIENTRY  glDepthFunc( GLenum func) {
+    GET_CTX()
+    ctx->dispatcher().glDepthFunc(func);
+}
+
+GL_API void GL_APIENTRY  glDepthMask( GLboolean flag) {
+    GET_CTX()
+    ctx->dispatcher().glDepthMask(flag);
+}
+
+GL_API void GL_APIENTRY  glDepthRangef( GLclampf zNear, GLclampf zFar) {
+    GET_CTX()
+    ctx->dispatcher().glDepthRange(zNear,zFar);
+}
+
+GL_API void GL_APIENTRY  glDepthRangex( GLclampx zNear, GLclampx zFar) {
+    GET_CTX()
+    ctx->dispatcher().glDepthRange(X2F(zNear),X2F(zFar));
+}
+
+GL_API void GL_APIENTRY  glDisable( GLenum cap) {
+    GET_CTX()
+    if (cap==GL_TEXTURE_GEN_STR_OES) {
+        ctx->dispatcher().glDisable(GL_TEXTURE_GEN_S);
+        ctx->dispatcher().glDisable(GL_TEXTURE_GEN_T);
+        ctx->dispatcher().glDisable(GL_TEXTURE_GEN_R);
+    }
+    ctx->dispatcher().glDisable(cap);
+    if (cap==GL_TEXTURE_2D)
+        ctx->setTextureEnabled(TEXTURE_2D,false);
+    else if (cap==GL_TEXTURE_CUBE_MAP_OES)
+        ctx->setTextureEnabled(TEXTURE_CUBE_MAP,false);
+}
+
+GL_API void GL_APIENTRY  glDisableClientState( GLenum array) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::supportedArrays(array),GL_INVALID_ENUM)
+
+    ctx->enableArr(array,false);
+    if(array != GL_POINT_SIZE_ARRAY_OES) ctx->dispatcher().glDisableClientState(array);
+}
+
+
+GL_API void GL_APIENTRY  glDrawArrays( GLenum mode, GLint first, GLsizei count) {
+    GET_CTX_CM()
+    SET_ERROR_IF(count < 0,GL_INVALID_VALUE)
+    SET_ERROR_IF(!GLEScmValidate::drawMode(mode),GL_INVALID_ENUM)
+
+    if(!ctx->isArrEnabled(GL_VERTEX_ARRAY)) return;
+
+    GLESFloatArrays tmpArrs;
+    ctx->convertArrs(tmpArrs,first,count,0,NULL,true);
+    if(mode != GL_POINTS || !ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){
+        ctx->dispatcher().glDrawArrays(mode,first,count);
+    }
+    else{
+        ctx->drawPointsArrs(tmpArrs,first,count);
+    }
+}
+
+GL_API void GL_APIENTRY  glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *elementsIndices) {
+    GET_CTX_CM()
+    SET_ERROR_IF(count < 0,GL_INVALID_VALUE)
+    SET_ERROR_IF((!GLEScmValidate::drawMode(mode) || !GLEScmValidate::drawType(type)),GL_INVALID_ENUM)
+    if(!ctx->isArrEnabled(GL_VERTEX_ARRAY)) return;
+
+    const GLvoid* indices = elementsIndices;
+    GLESFloatArrays tmpArrs;
+    if(ctx->isBindedBuffer(GL_ELEMENT_ARRAY_BUFFER)) { // if vbo is binded take the indices from the vbo
+        const unsigned char* buf = static_cast<unsigned char *>(ctx->getBindedBuffer(GL_ELEMENT_ARRAY_BUFFER));
+        indices = buf+reinterpret_cast<unsigned int>(elementsIndices);
+    }
+
+    ctx->convertArrs(tmpArrs,0,count,type,indices,false);
+    if(mode != GL_POINTS || !ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){
+        ctx->dispatcher().glDrawElements(mode,count,type,indices);
+    }
+    else{
+        ctx->drawPointsElems(tmpArrs,count,type,indices);
+    }
+}
+
+GL_API void GL_APIENTRY  glEnable( GLenum cap) {
+    GET_CTX()
+    if (cap==GL_TEXTURE_GEN_STR_OES) {
+        ctx->dispatcher().glEnable(GL_TEXTURE_GEN_S);
+        ctx->dispatcher().glEnable(GL_TEXTURE_GEN_T);
+        ctx->dispatcher().glEnable(GL_TEXTURE_GEN_R);
+    }
+    else
+        ctx->dispatcher().glEnable(cap);
+    if (cap==GL_TEXTURE_2D)
+        ctx->setTextureEnabled(TEXTURE_2D,true);
+    else if (cap==GL_TEXTURE_CUBE_MAP_OES)
+        ctx->setTextureEnabled(TEXTURE_CUBE_MAP,true);
+}
+
+GL_API void GL_APIENTRY  glEnableClientState( GLenum array) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::supportedArrays(array),GL_INVALID_ENUM)
+
+    ctx->enableArr(array,true);
+    if(array != GL_POINT_SIZE_ARRAY_OES) ctx->dispatcher().glEnableClientState(array);
+}
+
+GL_API void GL_APIENTRY  glFinish( void) {
+    GET_CTX()
+    ctx->dispatcher().glFinish();
+}
+
+GL_API void GL_APIENTRY  glFlush( void) {
+    GET_CTX()
+    ctx->dispatcher().glFlush();
+}
+
+GL_API void GL_APIENTRY  glFogf( GLenum pname, GLfloat param) {
+    GET_CTX()
+    ctx->dispatcher().glFogf(pname,param);
+}
+
+GL_API void GL_APIENTRY  glFogfv( GLenum pname, const GLfloat *params) {
+    GET_CTX()
+    ctx->dispatcher().glFogfv(pname,params);
+}
+
+GL_API void GL_APIENTRY  glFogx( GLenum pname, GLfixed param) {
+    GET_CTX()
+    ctx->dispatcher().glFogf(pname,(pname == GL_FOG_MODE)? static_cast<GLfloat>(param):X2F(param));
+}
+
+GL_API void GL_APIENTRY  glFogxv( GLenum pname, const GLfixed *params) {
+    GET_CTX()
+    if(pname == GL_FOG_MODE) {
+        GLfloat tmpParam = static_cast<GLfloat>(params[0]);
+        ctx->dispatcher().glFogfv(pname,&tmpParam);
+    } else {
+        GLfloat tmpParams[4];
+        for(int i=0; i< 4; i++) {
+            tmpParams[i] = X2F(params[i]);
+        }
+        ctx->dispatcher().glFogfv(pname,tmpParams);
+    }
+
+}
+
+GL_API void GL_APIENTRY  glFrontFace( GLenum mode) {
+    GET_CTX()
+    ctx->dispatcher().glFrontFace(mode);
+}
+
+GL_API void GL_APIENTRY  glFrustumf( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
+    GET_CTX()
+    ctx->dispatcher().glFrustum(left,right,bottom,top,zNear,zFar);
+}
+
+GL_API void GL_APIENTRY  glFrustumx( GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
+    GET_CTX()
+    ctx->dispatcher().glFrustum(X2F(left),X2F(right),X2F(bottom),X2F(top),X2F(zNear),X2F(zFar));
+}
+
+GL_API void GL_APIENTRY  glGenBuffers( GLsizei n, GLuint *buffers) {
+    GET_CTX()
+    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
+    if(thrd->shareGroup.Ptr()) {
+        for(int i=0; i<n ;i++) {
+            buffers[i] = thrd->shareGroup->genName(VERTEXBUFFER);
+            //generating vbo object related to this buffer name
+            thrd->shareGroup->setObjectData(VERTEXBUFFER,buffers[i],ObjectDataPtr(new GLESbuffer()));
+        }
+    }
+}
+
+GL_API void GL_APIENTRY  glGenTextures( GLsizei n, GLuint *textures) {
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        for(int i=0; i<n ;i++) {
+            textures[i] = thrd->shareGroup->genName(TEXTURE);
+        }
+    }
+}
+
+GL_API void GL_APIENTRY  glGetBooleanv( GLenum pname, GLboolean *params) {
+    GET_CTX()
+    switch(pname)
+    {
+    case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
+    case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
+        GLint i;
+        glGetIntegerv(pname, &i);
+        *params = (i != 0) ? GL_TRUE : GL_FALSE;
+        break;
+
+    case GL_TEXTURE_GEN_STR_OES:
+        {
+            GLboolean state_s = GL_FALSE;
+            GLboolean state_t = GL_FALSE;
+            GLboolean state_r = GL_FALSE;
+            ctx->dispatcher().glGetBooleanv(GL_TEXTURE_GEN_S,&state_s);
+            ctx->dispatcher().glGetBooleanv(GL_TEXTURE_GEN_T,&state_t);
+            ctx->dispatcher().glGetBooleanv(GL_TEXTURE_GEN_R,&state_r);
+            *params = state_s && state_t && state_r ? GL_TRUE: GL_FALSE;
+        }
+        break;
+
+    default:
+        ctx->dispatcher().glGetBooleanv(pname,params);
+    }
+}
+
+GL_API void GL_APIENTRY  glGetBufferParameteriv( GLenum target, GLenum pname, GLint *params) {
+    GET_CTX()
+    SET_ERROR_IF(!(GLEScmValidate::bufferTarget(target) && GLEScmValidate::bufferParam(pname)),GL_INVALID_ENUM);
+    SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
+    bool ret = true;
+    switch(pname) {
+    case GL_BUFFER_SIZE:
+        ctx->getBufferSize(target,params);
+        break;
+    case GL_BUFFER_USAGE:
+        ctx->getBufferUsage(target,params);
+        break;
+    }
+
+}
+
+GL_API void GL_APIENTRY  glGetClipPlanef( GLenum pname, GLfloat eqn[4]) {
+    GET_CTX()
+    GLdouble tmpEqn[4];
+
+    ctx->dispatcher().glGetClipPlane(pname,tmpEqn);
+    for(int i =0 ;i < 4; i++){
+        eqn[i] = static_cast<GLfloat>(tmpEqn[i]);
+    }
+}
+
+GL_API void GL_APIENTRY  glGetClipPlanex( GLenum pname, GLfixed eqn[4]) {
+    GET_CTX()
+    GLdouble tmpEqn[4];
+
+    ctx->dispatcher().glGetClipPlane(pname,tmpEqn);
+    for(int i =0 ;i < 4; i++){
+        eqn[i] = F2X(tmpEqn[i]);
+    }
+}
+
+GL_API void GL_APIENTRY  glGetFixedv( GLenum pname, GLfixed *params) {
+    GET_CTX()
+
+    size_t nParams = glParamSize(pname);
+    GLfloat fParams[16];
+
+    switch(pname)
+    {
+    case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
+    case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
+        GLint i;
+        glGetIntegerv(pname, &i);
+        *params = I2X(i);
+        nParams = 0;
+        break;
+
+    case GL_TEXTURE_GEN_STR_OES:
+        ctx->dispatcher().glGetFloatv(GL_TEXTURE_GEN_S,&fParams[0]);
+        break;
+
+    default:
+        ctx->dispatcher().glGetFloatv(pname,fParams);
+    }
+
+    if (nParams)
+    {
+        for(size_t i =0 ; i < nParams;i++) {
+            params[i] = F2X(fParams[i]);
+        }
+    }
+}
+
+GL_API void GL_APIENTRY  glGetFloatv( GLenum pname, GLfloat *params) {
+    GET_CTX()
+    switch(pname)
+    {
+    case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
+    case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
+        GLint i;
+        glGetIntegerv(pname, &i);
+        *params = (GLfloat)i;
+        break;
+
+    case GL_TEXTURE_GEN_STR_OES:
+        ctx->dispatcher().glGetFloatv(GL_TEXTURE_GEN_S,&params[0]);
+        break;
+
+    default:
+        ctx->dispatcher().glGetFloatv(pname,params);
+    }
+}
+
+GL_API void GL_APIENTRY  glGetIntegerv( GLenum pname, GLint *params) {
+    GET_CTX()
+    switch(pname)
+    {
+    case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
+        *params = GL_UNSIGNED_BYTE;
+        break;
+
+    case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
+        *params = GL_RGBA;
+        break;
+
+    case GL_TEXTURE_GEN_STR_OES:
+        ctx->dispatcher().glGetIntegerv(GL_TEXTURE_GEN_S,&params[0]);
+        break;
+
+    default:
+        ctx->dispatcher().glGetIntegerv(pname,params);
+    }
+}
+
+GL_API void GL_APIENTRY  glGetLightfv( GLenum light, GLenum pname, GLfloat *params) {
+    GET_CTX()
+    ctx->dispatcher().glGetLightfv(light,pname,params);
+}
+
+GL_API void GL_APIENTRY  glGetLightxv( GLenum light, GLenum pname, GLfixed *params) {
+    GET_CTX()
+    GLfloat tmpParams[4];
+
+    ctx->dispatcher().glGetLightfv(light,pname,tmpParams);
+    switch (pname){
+        case GL_AMBIENT:
+        case GL_DIFFUSE:
+        case GL_SPECULAR:
+        case GL_POSITION:
+            params[3] = F2X(tmpParams[3]);
+        case GL_SPOT_DIRECTION:
+            params[2] = F2X(tmpParams[2]);
+        case GL_SPOT_EXPONENT:
+        case GL_SPOT_CUTOFF:
+        case GL_CONSTANT_ATTENUATION:
+        case GL_LINEAR_ATTENUATION:
+        case GL_QUADRATIC_ATTENUATION:
+            params[1] = F2X(tmpParams[1]);
+            break;
+        default:{
+            ctx->setGLerror(GL_INVALID_ENUM);
+            return;
+        }
+
+    }
+    params[0] = F2X(tmpParams[0]);
+}
+
+GL_API void GL_APIENTRY  glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params) {
+    GET_CTX()
+    ctx->dispatcher().glGetMaterialfv(face,pname,params);
+}
+
+GL_API void GL_APIENTRY  glGetMaterialxv( GLenum face, GLenum pname, GLfixed *params) {
+    GET_CTX()
+    GLfloat tmpParams[4];
+    ctx->dispatcher().glGetMaterialfv(face,pname,tmpParams);
+    switch(pname){
+    case GL_AMBIENT:
+    case GL_DIFFUSE:
+    case GL_SPECULAR:
+    case GL_EMISSION:
+    case GL_AMBIENT_AND_DIFFUSE:
+        params[3] = tmpParams[3];
+        params[2] = tmpParams[2];
+        params[1] = tmpParams[1];
+    case GL_SHININESS:
+        params[0] = tmpParams[0];
+        break;
+    default:{
+            ctx->setGLerror(GL_INVALID_ENUM);
+            return;
+        }
+    }
+}
+
+GL_API void GL_APIENTRY  glGetPointerv( GLenum pname, void **params) {
+    GET_CTX()
+    const GLESpointer* p = ctx->getPointer(pname);
+    if(p) {
+        *params = const_cast<void *>( p->getArrayData());
+    } else {
+        ctx->setGLerror(GL_INVALID_ENUM);
+    }
+
+}
+
+GL_API void GL_APIENTRY  glGetTexEnvfv( GLenum env, GLenum pname, GLfloat *params) {
+    GET_CTX()
+    ctx->dispatcher().glGetTexEnvfv(env,pname,params);
+}
+
+GL_API void GL_APIENTRY  glGetTexEnviv( GLenum env, GLenum pname, GLint *params) {
+    GET_CTX()
+    ctx->dispatcher().glGetTexEnviv(env,pname,params);
+}
+
+GL_API void GL_APIENTRY  glGetTexEnvxv( GLenum env, GLenum pname, GLfixed *params) {
+    GET_CTX()
+    GLfloat tmpParams[4];
+
+    ctx->dispatcher().glGetTexEnvfv(env,pname,tmpParams);
+    if(pname == GL_TEXTURE_ENV_MODE) {
+        params[0] = static_cast<GLfixed>(tmpParams[0]);
+    } else {
+        for(int i=0 ; i < 4 ; i++)
+            params[i] = F2X(tmpParams[i]);
+    }
+}
+
+GL_API void GL_APIENTRY  glGetTexParameterfv( GLenum target, GLenum pname, GLfloat *params) {
+    GET_CTX()
+   if (pname==GL_TEXTURE_CROP_RECT_OES) {
+      TextureData *texData = getTextureData();
+      SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
+      for (int i=0;i<4;++i)
+        params[i] = texData->crop_rect[i];
+    }
+    else {
+      ctx->dispatcher().glGetTexParameterfv(target,pname,params);
+    }
+}
+
+GL_API void GL_APIENTRY  glGetTexParameteriv( GLenum target, GLenum pname, GLint *params) {
+    GET_CTX()
+    if (pname==GL_TEXTURE_CROP_RECT_OES) {
+      TextureData *texData = getTextureData();
+      SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
+      for (int i=0;i<4;++i)
+        params[i] = texData->crop_rect[i];
+    }
+    else {
+      ctx->dispatcher().glGetTexParameteriv(target,pname,params);
+    }
+}
+
+GL_API void GL_APIENTRY  glGetTexParameterxv( GLenum target, GLenum pname, GLfixed *params) {
+    GET_CTX()
+    if (pname==GL_TEXTURE_CROP_RECT_OES) {
+      TextureData *texData = getTextureData();
+      SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
+      for (int i=0;i<4;++i)
+        params[i] = F2X(texData->crop_rect[i]);
+    }
+    else {
+      GLfloat tmpParam;
+      ctx->dispatcher().glGetTexParameterfv(target,pname,&tmpParam);
+      params[0] = static_cast<GLfixed>(tmpParam);
+    }
+}
+
+GL_API void GL_APIENTRY  glHint( GLenum target, GLenum mode) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::hintTargetMode(target,mode),GL_INVALID_ENUM);
+    ctx->dispatcher().glHint(target,mode);
+}
+
+GL_API void GL_APIENTRY  glLightModelf( GLenum pname, GLfloat param) {
+    GET_CTX()
+    ctx->dispatcher().glLightModelf(pname,param);
+}
+
+GL_API void GL_APIENTRY  glLightModelfv( GLenum pname, const GLfloat *params) {
+    GET_CTX()
+    ctx->dispatcher().glLightModelfv(pname,params);
+}
+
+GL_API void GL_APIENTRY  glLightModelx( GLenum pname, GLfixed param) {
+    GET_CTX()
+    GLfloat tmpParam = static_cast<GLfloat>(param);
+    ctx->dispatcher().glLightModelf(pname,tmpParam);
+}
+
+GL_API void GL_APIENTRY  glLightModelxv( GLenum pname, const GLfixed *params) {
+    GET_CTX()
+    GLfloat tmpParams[4];
+    if(pname == GL_LIGHT_MODEL_TWO_SIDE) {
+        tmpParams[0] = X2F(params[0]);
+    } else if (pname == GL_LIGHT_MODEL_AMBIENT) {
+        for(int i=0;i<4;i++) {
+            tmpParams[i] = X2F(params[i]);
+        }
+    }
+
+    ctx->dispatcher().glLightModelfv(pname,tmpParams);
+}
+
+GL_API void GL_APIENTRY  glLightf( GLenum light, GLenum pname, GLfloat param) {
+    GET_CTX()
+    ctx->dispatcher().glLightf(light,pname,param);
+}
+
+GL_API void GL_APIENTRY  glLightfv( GLenum light, GLenum pname, const GLfloat *params) {
+    GET_CTX()
+    ctx->dispatcher().glLightfv(light,pname,params);
+}
+
+GL_API void GL_APIENTRY  glLightx( GLenum light, GLenum pname, GLfixed param) {
+    GET_CTX()
+    ctx->dispatcher().glLightf(light,pname,X2F(param));
+}
+
+GL_API void GL_APIENTRY  glLightxv( GLenum light, GLenum pname, const GLfixed *params) {
+    GET_CTX()
+    GLfloat tmpParams[4];
+
+    switch (pname) {
+        case GL_AMBIENT:
+        case GL_DIFFUSE:
+        case GL_SPECULAR:
+        case GL_EMISSION:
+        case GL_POSITION:
+            tmpParams[3] = X2F(params[3]);
+        case GL_SPOT_DIRECTION:
+            tmpParams[2] = X2F(params[2]);
+            tmpParams[1] = X2F(params[1]);
+        case GL_SPOT_EXPONENT:
+        case GL_SPOT_CUTOFF:
+        case GL_CONSTANT_ATTENUATION:
+        case GL_LINEAR_ATTENUATION:
+        case GL_QUADRATIC_ATTENUATION:
+            tmpParams[0] = X2F(params[0]);
+            break;
+        default: {
+                ctx->setGLerror(GL_INVALID_ENUM);
+                return;
+            }
+    }
+    ctx->dispatcher().glLightfv(light,pname,tmpParams);
+}
+
+GL_API void GL_APIENTRY  glLineWidth( GLfloat width) {
+    GET_CTX()
+    ctx->dispatcher().glLineWidth(width);
+}
+
+GL_API void GL_APIENTRY  glLineWidthx( GLfixed width) {
+    GET_CTX()
+    ctx->dispatcher().glLineWidth(X2F(width));
+}
+
+GL_API void GL_APIENTRY  glLoadIdentity( void) {
+    GET_CTX()
+    ctx->dispatcher().glLoadIdentity();
+}
+
+GL_API void GL_APIENTRY  glLoadMatrixf( const GLfloat *m) {
+    GET_CTX()
+    ctx->dispatcher().glLoadMatrixf(m);
+}
+
+GL_API void GL_APIENTRY  glLoadMatrixx( const GLfixed *m) {
+    GET_CTX()
+    GLfloat mat[16];
+    for(int i=0; i< 16 ; i++) {
+        mat[i] = X2F(m[i]);
+    }
+    ctx->dispatcher().glLoadMatrixf(mat);
+}
+
+GL_API void GL_APIENTRY  glLogicOp( GLenum opcode) {
+    GET_CTX()
+    ctx->dispatcher().glLogicOp(opcode);
+}
+
+GL_API void GL_APIENTRY  glMaterialf( GLenum face, GLenum pname, GLfloat param) {
+    GET_CTX()
+    ctx->dispatcher().glMaterialf(face,pname,param);
+}
+
+GL_API void GL_APIENTRY  glMaterialfv( GLenum face, GLenum pname, const GLfloat *params) {
+    GET_CTX()
+    ctx->dispatcher().glMaterialfv(face,pname,params);
+}
+
+GL_API void GL_APIENTRY  glMaterialx( GLenum face, GLenum pname, GLfixed param) {
+    GET_CTX()
+    ctx->dispatcher().glMaterialf(face,pname,X2F(param));
+}
+
+GL_API void GL_APIENTRY  glMaterialxv( GLenum face, GLenum pname, const GLfixed *params) {
+    GET_CTX()
+    GLfloat tmpParams[4];
+
+    for(int i=0; i< 4; i++) {
+        tmpParams[i] = X2F(params[i]);
+    }
+    ctx->dispatcher().glMaterialfv(face,pname,tmpParams);
+}
+
+GL_API void GL_APIENTRY  glMatrixMode( GLenum mode) {
+    GET_CTX()
+    ctx->dispatcher().glMatrixMode(mode);
+}
+
+GL_API void GL_APIENTRY  glMultMatrixf( const GLfloat *m) {
+    GET_CTX()
+    ctx->dispatcher().glMultMatrixf(m);
+}
+
+GL_API void GL_APIENTRY  glMultMatrixx( const GLfixed *m) {
+    GET_CTX()
+    GLfloat mat[16];
+    for(int i=0; i< 16 ; i++) {
+        mat[i] = X2F(m[i]);
+    }
+    ctx->dispatcher().glMultMatrixf(mat);
+}
+
+GL_API void GL_APIENTRY  glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
+    GET_CTX_CM()
+    SET_ERROR_IF(!GLEScmValidate::textureEnum(target,ctx->getMaxTexUnits()),GL_INVALID_ENUM);
+    ctx->dispatcher().glMultiTexCoord4f(target,s,t,r,q);
+}
+
+GL_API void GL_APIENTRY  glMultiTexCoord4x( GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) {
+    GET_CTX_CM()
+    SET_ERROR_IF(!GLEScmValidate::textureEnum(target,ctx->getMaxTexUnits()),GL_INVALID_ENUM);
+    ctx->dispatcher().glMultiTexCoord4f(target,X2F(s),X2F(t),X2F(r),X2F(q));
+}
+
+GL_API void GL_APIENTRY  glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz) {
+    GET_CTX()
+    ctx->dispatcher().glNormal3f(nx,ny,nz);
+}
+
+GL_API void GL_APIENTRY  glNormal3x( GLfixed nx, GLfixed ny, GLfixed nz) {
+    GET_CTX()
+    ctx->dispatcher().glNormal3f(X2F(nx),X2F(ny),X2F(nz));
+}
+
+GL_API void GL_APIENTRY  glNormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer) {
+    GET_CTX()
+    SET_ERROR_IF(stride < 0,GL_INVALID_VALUE);
+    const GLvoid* data = ctx->setPointer(GL_NORMAL_ARRAY,3,type,stride,pointer);//3 normal verctor
+    if(type != GL_FIXED) ctx->dispatcher().glNormalPointer(type,stride,data);
+}
+
+GL_API void GL_APIENTRY  glOrthof( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
+    GET_CTX()
+    ctx->dispatcher().glOrtho(left,right,bottom,top,zNear,zFar);
+}
+
+GL_API void GL_APIENTRY  glOrthox( GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
+    GET_CTX()
+    ctx->dispatcher().glOrtho(X2F(left),X2F(right),X2F(bottom),X2F(top),X2F(zNear),X2F(zFar));
+}
+
+GL_API void GL_APIENTRY  glPixelStorei( GLenum pname, GLint param) {
+    GET_CTX()
+    ctx->dispatcher().glPixelStorei(pname,param);
+}
+
+GL_API void GL_APIENTRY  glPointParameterf( GLenum pname, GLfloat param) {
+    GET_CTX()
+    ctx->dispatcher().glPointParameterf(pname,param);
+}
+
+GL_API void GL_APIENTRY  glPointParameterfv( GLenum pname, const GLfloat *params) {
+    GET_CTX()
+    ctx->dispatcher().glPointParameterfv(pname,params);
+}
+
+GL_API void GL_APIENTRY  glPointParameterx( GLenum pname, GLfixed param)
+{
+    GET_CTX()
+    ctx->dispatcher().glPointParameterf(pname,X2F(param));
+}
+
+GL_API void GL_APIENTRY  glPointParameterxv( GLenum pname, const GLfixed *params) {
+    GET_CTX()
+
+    GLfloat tmpParam = X2F(*params) ;
+    ctx->dispatcher().glPointParameterfv(pname,&tmpParam);
+}
+
+GL_API void GL_APIENTRY  glPointSize( GLfloat size) {
+    GET_CTX()
+    ctx->dispatcher().glPointSize(size);
+}
+
+GL_API void GL_APIENTRY  glPointSizePointerOES( GLenum type, GLsizei stride, const GLvoid *pointer) {
+    GET_CTX()
+    SET_ERROR_IF(stride < 0,GL_INVALID_VALUE);
+    ctx->setPointer(GL_POINT_SIZE_ARRAY_OES,1,type,stride,pointer);
+}
+
+GL_API void GL_APIENTRY  glPointSizex( GLfixed size) {
+    GET_CTX()
+    ctx->dispatcher().glPointSize(X2F(size));
+}
+
+GL_API void GL_APIENTRY  glPolygonOffset( GLfloat factor, GLfloat units) {
+    GET_CTX()
+    ctx->dispatcher().glPolygonOffset(factor,units);
+}
+
+GL_API void GL_APIENTRY  glPolygonOffsetx( GLfixed factor, GLfixed units) {
+    GET_CTX()
+    ctx->dispatcher().glPolygonOffset(X2F(factor),X2F(units));
+}
+
+GL_API void GL_APIENTRY  glPopMatrix(void) {
+    GET_CTX()
+    ctx->dispatcher().glPopMatrix();
+}
+
+GL_API void GL_APIENTRY  glPushMatrix(void) {
+    GET_CTX()
+    ctx->dispatcher().glPushMatrix();
+}
+
+GL_API void GL_APIENTRY  glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {
+    GET_CTX()
+    SET_ERROR_IF(!(GLEScmValidate::pixelFrmt(ctx,format) && GLEScmValidate::pixelType(ctx,type)),GL_INVALID_ENUM);
+    SET_ERROR_IF(!(GLEScmValidate::pixelOp(format,type)),GL_INVALID_OPERATION);
+
+    ctx->dispatcher().glReadPixels(x,y,width,height,format,type,pixels);
+}
+
+GL_API void GL_APIENTRY  glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z) {
+    GET_CTX()
+    ctx->dispatcher().glRotatef(angle,x,y,z);
+}
+
+GL_API void GL_APIENTRY  glRotatex( GLfixed angle, GLfixed x, GLfixed y, GLfixed z) {
+    GET_CTX()
+    ctx->dispatcher().glRotatef(angle,X2F(x),X2F(y),X2F(z));
+}
+
+GL_API void GL_APIENTRY  glSampleCoverage( GLclampf value, GLboolean invert) {
+    GET_CTX()
+    ctx->dispatcher().glSampleCoverage(value,invert);
+}
+
+GL_API void GL_APIENTRY  glSampleCoveragex( GLclampx value, GLboolean invert) {
+    GET_CTX()
+    ctx->dispatcher().glSampleCoverage(X2F(value),invert);
+}
+
+GL_API void GL_APIENTRY  glScalef( GLfloat x, GLfloat y, GLfloat z) {
+    GET_CTX()
+    ctx->dispatcher().glScalef(x,y,z);
+}
+
+GL_API void GL_APIENTRY  glScalex( GLfixed x, GLfixed y, GLfixed z) {
+    GET_CTX()
+    ctx->dispatcher().glScalef(X2F(x),X2F(y),X2F(z));
+}
+
+GL_API void GL_APIENTRY  glScissor( GLint x, GLint y, GLsizei width, GLsizei height) {
+    GET_CTX()
+    ctx->dispatcher().glScissor(x,y,width,height);
+}
+
+GL_API void GL_APIENTRY  glShadeModel( GLenum mode) {
+    GET_CTX()
+    ctx->dispatcher().glShadeModel(mode);
+}
+
+GL_API void GL_APIENTRY  glStencilFunc( GLenum func, GLint ref, GLuint mask) {
+    GET_CTX()
+    ctx->dispatcher().glStencilFunc(func,ref,mask);
+}
+
+GL_API void GL_APIENTRY  glStencilMask( GLuint mask) {
+    GET_CTX()
+    ctx->dispatcher().glStencilMask(mask);
+}
+
+GL_API void GL_APIENTRY  glStencilOp( GLenum fail, GLenum zfail, GLenum zpass) {
+    GET_CTX()
+    SET_ERROR_IF(!(GLEScmValidate::stencilOp(fail) && GLEScmValidate::stencilOp(zfail) && GLEScmValidate::stencilOp(zpass)),GL_INVALID_ENUM);
+    ctx->dispatcher().glStencilOp(fail,zfail,zpass);
+}
+
+GL_API void GL_APIENTRY  glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texCoordPointerParams(size,stride),GL_INVALID_VALUE);
+
+    const GLvoid* data = ctx->setPointer(GL_TEXTURE_COORD_ARRAY,size,type,stride,pointer);
+    if(type != GL_FIXED) ctx->dispatcher().glTexCoordPointer(size,type,stride,data);
+}
+
+GL_API void GL_APIENTRY  glTexEnvf( GLenum target, GLenum pname, GLfloat param) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texEnv(target,pname),GL_INVALID_ENUM);
+    ctx->dispatcher().glTexEnvf(target,pname,param);
+}
+
+GL_API void GL_APIENTRY  glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texEnv(target,pname),GL_INVALID_ENUM);
+    ctx->dispatcher().glTexEnvfv(target,pname,params);
+}
+
+GL_API void GL_APIENTRY  glTexEnvi( GLenum target, GLenum pname, GLint param) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texEnv(target,pname),GL_INVALID_ENUM);
+    ctx->dispatcher().glTexEnvi(target,pname,param);
+}
+
+GL_API void GL_APIENTRY  glTexEnviv( GLenum target, GLenum pname, const GLint *params) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texEnv(target,pname),GL_INVALID_ENUM);
+    ctx->dispatcher().glTexEnviv(target,pname,params);
+}
+
+GL_API void GL_APIENTRY  glTexEnvx( GLenum target, GLenum pname, GLfixed param) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texEnv(target,pname),GL_INVALID_ENUM);
+    GLfloat tmpParam = static_cast<GLfloat>(param);
+    ctx->dispatcher().glTexEnvf(target,pname,tmpParam);
+}
+
+GL_API void GL_APIENTRY  glTexEnvxv( GLenum target, GLenum pname, const GLfixed *params) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texEnv(target,pname),GL_INVALID_ENUM);
+
+    GLfloat tmpParams[4];
+    if(pname == GL_TEXTURE_ENV_COLOR) {
+        for(int i =0;i<4;i++) {
+            tmpParams[i] = X2F(params[i]);
+        }
+    } else {
+        tmpParams[0] = static_cast<GLfloat>(params[0]);
+    }
+    ctx->dispatcher().glTexEnvfv(target,pname,tmpParams);
+}
+
+GL_API void GL_APIENTRY  glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {
+    GET_CTX()
+
+    SET_ERROR_IF(!(GLEScmValidate::textureTargetEx(target) &&
+                     GLEScmValidate::pixelFrmt(ctx,internalformat) &&
+                     GLEScmValidate::pixelFrmt(ctx,format) &&
+                     GLEScmValidate::pixelType(ctx,type)),GL_INVALID_ENUM);
+
+    SET_ERROR_IF(!(GLEScmValidate::pixelOp(format,type) && internalformat == ((GLint)format)),GL_INVALID_OPERATION);
+
+    if (thrd->shareGroup.Ptr()){
+        TextureData *texData = getTextureData();
+        SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
+        if(texData) {
+            texData->width = width;
+            texData->height = height;
+            texData->border = border;
+            texData->internalFormat = internalformat;
+        }
+    }
+    ctx->dispatcher().glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);
+}
+
+GL_API void GL_APIENTRY  glTexParameterf( GLenum target, GLenum pname, GLfloat param) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
+    ctx->dispatcher().glTexParameterf(target,pname,param);
+}
+
+GL_API void GL_APIENTRY  glTexParameterfv( GLenum target, GLenum pname, const GLfloat *params) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
+    if (pname==GL_TEXTURE_CROP_RECT_OES) {
+        TextureData *texData = getTextureData();
+        SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
+        for (int i=0;i<4;++i)
+            texData->crop_rect[i] = params[i];
+    }
+    else {
+        ctx->dispatcher().glTexParameterfv(target,pname,params);
+    }
+}
+
+GL_API void GL_APIENTRY  glTexParameteri( GLenum target, GLenum pname, GLint param) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
+    ctx->dispatcher().glTexParameteri(target,pname,param);
+}
+
+GL_API void GL_APIENTRY  glTexParameteriv( GLenum target, GLenum pname, const GLint *params) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
+    if (pname==GL_TEXTURE_CROP_RECT_OES) {
+        TextureData *texData = getTextureData();
+        SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
+        for (int i=0;i<4;++i)
+            texData->crop_rect[i] = params[i];
+    }
+    else {
+        ctx->dispatcher().glTexParameteriv(target,pname,params);
+    }
+}
+
+GL_API void GL_APIENTRY  glTexParameterx( GLenum target, GLenum pname, GLfixed param) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
+    ctx->dispatcher().glTexParameterf(target,pname,static_cast<GLfloat>(param));
+}
+
+GL_API void GL_APIENTRY  glTexParameterxv( GLenum target, GLenum pname, const GLfixed *params) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM);
+    if (pname==GL_TEXTURE_CROP_RECT_OES) {
+        TextureData *texData = getTextureData();
+        SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
+        for (int i=0;i<4;++i)
+            texData->crop_rect[i] = X2F(params[i]);
+    }
+    else {
+        GLfloat param = static_cast<GLfloat>(params[0]);
+        ctx->dispatcher().glTexParameterfv(target,pname,&param);
+    }
+}
+
+GL_API void GL_APIENTRY  glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) {
+    GET_CTX()
+    SET_ERROR_IF(!(GLEScmValidate::textureTargetEx(target) &&
+                   GLEScmValidate::pixelFrmt(ctx,format)&&
+                   GLEScmValidate::pixelType(ctx,type)),GL_INVALID_ENUM);
+    SET_ERROR_IF(!GLEScmValidate::pixelOp(format,type),GL_INVALID_OPERATION);
+
+    ctx->dispatcher().glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels);
+}
+
+GL_API void GL_APIENTRY  glTranslatef( GLfloat x, GLfloat y, GLfloat z) {
+    GET_CTX()
+    ctx->dispatcher().glTranslatef(x,y,z);
+}
+
+GL_API void GL_APIENTRY  glTranslatex( GLfixed x, GLfixed y, GLfixed z) {
+    GET_CTX()
+    ctx->dispatcher().glTranslatef(x,y,z);
+}
+
+GL_API void GL_APIENTRY  glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::vertexPointerParams(size,stride),GL_INVALID_VALUE);
+
+    const GLvoid* data = ctx->setPointer(GL_VERTEX_ARRAY,size,type,stride,pointer);
+    if(type != GL_FIXED) ctx->dispatcher().glVertexPointer(size,type,stride,data);
+}
+
+GL_API void GL_APIENTRY  glViewport( GLint x, GLint y, GLsizei width, GLsizei height) {
+    GET_CTX()
+    ctx->dispatcher().glViewport(x,y,width,height);
+}
+
+GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
+{
+    GET_CTX();
+    SET_ERROR_IF(!GLEScmValidate::textureTargetLimited(target),GL_INVALID_ENUM);
+    EglImage *img = s_eglIface->eglAttachEGLImage((unsigned int)image);
+    if (img) {
+        // Create the texture object in the underlying EGL implementation,
+        // flag to the OpenGL layer to skip the image creation and map the
+        // current binded texture object to the existing global object.
+        if (thrd->shareGroup.Ptr()) {
+            unsigned int tex = ctx->getBindedTexture();
+            unsigned int oldGlobal = thrd->shareGroup->getGlobalName(TEXTURE, tex);
+            // Delete old texture object
+            if (oldGlobal) {
+                ctx->dispatcher().glDeleteTextures(1, &oldGlobal);
+            }
+            // replace mapping and bind the new global object
+            thrd->shareGroup->replaceGlobalName(TEXTURE, tex,img->globalTexName);
+            ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName);
+            TextureData *texData = getTextureData();
+            SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
+            texData->sourceEGLImage = (unsigned int)image;
+            texData->eglImageDetach = s_eglIface->eglDetachEGLImage;
+        }
+    }
+}
+
+GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
+{
+    GET_CTX()
+    //not supported by EGL
+    SET_ERROR_IF(false,GL_INVALID_OPERATION); 
+}
+
+/* GL_OES_blend_subtract*/
+GL_API void GL_APIENTRY glBlendEquationOES(GLenum mode) {
+    GET_CTX()
+    SET_ERROR_IF(!(GLEScmValidate::blendEquationMode(mode)), GL_INVALID_ENUM);
+    ctx->dispatcher().glBlendEquation(mode);   
+}
+
+/* GL_OES_blend_equation_separate */
+GL_API void GL_APIENTRY glBlendEquationSeparateOES (GLenum modeRGB, GLenum modeAlpha) {
+    GET_CTX()
+    SET_ERROR_IF(!(GLEScmValidate::blendEquationMode(modeRGB) && GLEScmValidate::blendEquationMode(modeAlpha)), GL_INVALID_ENUM);
+    ctx->dispatcher().glBlendEquationSeparate(modeRGB,modeAlpha);   
+}
+
+/* GL_OES_blend_func_separate */
+GL_API void GL_APIENTRY glBlendFuncSeparateOES(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::blendSrc(srcRGB) || !GLEScmValidate::blendDst(dstRGB) ||
+                 !GLEScmValidate::blendSrc(srcAlpha) || ! GLEScmValidate::blendDst(dstAlpha) ,GL_INVALID_ENUM);
+    ctx->dispatcher().glBlendFuncSeparate(srcRGB,dstRGB,srcAlpha,dstAlpha);
+}
+
+/* GL_OES_framebuffer_object */
+GL_API GLboolean GL_APIENTRY glIsRenderbufferOES(GLuint renderbuffer) {
+    GET_CTX_RET(GL_FALSE)
+    RET_AND_SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION,GL_FALSE);
+    if(renderbuffer && thrd->shareGroup.Ptr()){
+        return thrd->shareGroup->isObject(RENDERBUFFER,renderbuffer) ? GL_TRUE :GL_FALSE;
+    }
+    return ctx->dispatcher().glIsRenderbufferEXT(renderbuffer);
+}
+
+GL_API void GLAPIENTRY glBindRenderbufferOES(GLenum target, GLuint renderbuffer) {
+    GET_CTX()
+    SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
+    SET_ERROR_IF(!GLEScmValidate::renderbufferTarget(target),GL_INVALID_ENUM);
+
+    //if buffer wasn't generated before,generate one
+    if(thrd->shareGroup.Ptr() && !thrd->shareGroup->isObject(RENDERBUFFER,renderbuffer)){
+        thrd->shareGroup->genName(RENDERBUFFER,renderbuffer);
+    }
+
+    int globalBufferName = thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffer);
+    ctx->dispatcher().glBindRenderbufferEXT(target,globalBufferName); 
+}
+
+GL_API void GLAPIENTRY glDeleteRenderbuffersOES(GLsizei n, const GLuint *renderbuffers) {
+    GET_CTX()
+    SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
+    for (int i=0;i<n;++i) {
+        GLuint globalBufferName = thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffers[i]);
+        ctx->dispatcher().glDeleteRenderbuffersEXT(1,&globalBufferName);
+    }
+}
+
+GL_API void GLAPIENTRY glGenRenderbuffersOES(GLsizei n, GLuint *renderbuffers) {
+    GET_CTX()
+    SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
+    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
+    if(thrd->shareGroup.Ptr()) {
+        for(int i=0; i<n ;i++) {
+            renderbuffers[i] = thrd->shareGroup->genName(RENDERBUFFER);
+        }
+    }
+}
+
+GL_API void GLAPIENTRY glRenderbufferStorageOES(GLenum target, GLenum internalformat, GLsizei width, GLsizei height){
+    GET_CTX()
+    SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
+    SET_ERROR_IF(!GLEScmValidate::renderbufferTarget(target) || !GLEScmValidate::renderbufferInternalFrmt(ctx,internalformat) ,GL_INVALID_ENUM);
+    if (internalformat==GL_RGB565_OES) //RGB565 not supported by GL
+        internalformat = GL_RGB8_OES;
+    ctx->dispatcher().glRenderbufferStorageEXT(target,internalformat,width,height);
+}
+
+GL_API void GLAPIENTRY glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint* params) {
+    GET_CTX() 
+    SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
+    SET_ERROR_IF(!GLEScmValidate::renderbufferTarget(target) || !GLEScmValidate::renderbufferParams(pname) ,GL_INVALID_ENUM);
+    ctx->dispatcher().glGetRenderbufferParameterivEXT(target,pname,params);
+}
+
+GL_API GLboolean GLAPIENTRY glIsFramebufferOES(GLuint framebuffer) {
+    GET_CTX_RET(GL_FALSE)
+    RET_AND_SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION,GL_FALSE);
+    if (framebuffer && thrd->shareGroup.Ptr()) {
+        return thrd->shareGroup->isObject(FRAMEBUFFER,framebuffer) ? GL_TRUE : GL_FALSE;
+    }
+    return ctx->dispatcher().glIsFramebufferEXT(framebuffer);
+}
+
+GL_API void GLAPIENTRY glBindFramebufferOES(GLenum target, GLuint framebuffer) {
+    GET_CTX() 
+    SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); 
+    SET_ERROR_IF(!GLEScmValidate::framebufferTarget(target) ,GL_INVALID_ENUM);
+    if (thrd->shareGroup.Ptr() && !thrd->shareGroup->isObject(FRAMEBUFFER,framebuffer)) {
+        thrd->shareGroup->genName(FRAMEBUFFER,framebuffer);
+    }
+    int globalBufferName = thrd->shareGroup->getGlobalName(FRAMEBUFFER,framebuffer);
+    ctx->dispatcher().glBindFramebufferEXT(target,globalBufferName);
+}
+
+GL_API void GLAPIENTRY glDeleteFramebuffersOES(GLsizei n, const GLuint *framebuffers) {
+    GET_CTX()
+    SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); 
+    for (int i=0;i<n;++i) {
+        GLuint globalBufferName = thrd->shareGroup->getGlobalName(FRAMEBUFFER,framebuffers[i]);
+        ctx->dispatcher().glDeleteFramebuffersEXT(1,&globalBufferName);
+    }
+}
+
+GL_API void GLAPIENTRY glGenFramebuffersOES(GLsizei n, GLuint *framebuffers) { 
+    GET_CTX()
+    SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); 
+    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
+    if (thrd->shareGroup.Ptr()) {
+        for (int i=0;i<n;i++) {
+            framebuffers[i] = thrd->shareGroup->genName(FRAMEBUFFER);
+        }
+    }
+}
+
+GL_API GLenum GLAPIENTRY glCheckFramebufferStatusOES(GLenum target) {
+    GET_CTX_RET(0) 
+    RET_AND_SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION,0); 
+    RET_AND_SET_ERROR_IF(!GLEScmValidate::framebufferTarget(target) ,GL_INVALID_ENUM,0);
+    return ctx->dispatcher().glCheckFramebufferStatusEXT(target);
+}
+
+GL_API void GLAPIENTRY glFramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
+    GET_CTX()
+    SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); 
+    SET_ERROR_IF(!GLEScmValidate::framebufferTarget(target) || !GLEScmValidate::framebufferAttachment(attachment) ||
+                 !GLEScmValidate::textureTargetEx(textarget),GL_INVALID_ENUM);
+    if (thrd->shareGroup.Ptr() && !thrd->shareGroup->isObject(TEXTURE,texture)) {
+        thrd->shareGroup->genName(TEXTURE,texture);
+    }
+    GLuint globalTexName = thrd->shareGroup->getGlobalName(TEXTURE,texture);
+    ctx->dispatcher().glFramebufferTexture2DEXT(target,attachment,textarget,globalTexName,level);
+}
+
+GL_API void GLAPIENTRY glFramebufferRenderbufferOES(GLenum target, GLenum attachment,GLenum renderbuffertarget, GLuint renderbuffer) {
+    GET_CTX()
+    SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
+    SET_ERROR_IF(!GLEScmValidate::framebufferTarget(target) || !GLEScmValidate::framebufferAttachment(attachment) ||
+                 !GLEScmValidate::renderbufferTarget(renderbuffertarget), GL_INVALID_ENUM);
+    if (thrd->shareGroup.Ptr() && !thrd->shareGroup->isObject(RENDERBUFFER,renderbuffer)) {
+        thrd->shareGroup->genName(RENDERBUFFER,renderbuffer);
+    }
+    GLuint globalBufferName = thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffer);
+    ctx->dispatcher().glFramebufferRenderbufferEXT(target,attachment,renderbuffertarget,globalBufferName);
+}
+
+GL_API void GLAPIENTRY glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint *params) {
+    GET_CTX()
+    SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
+    SET_ERROR_IF(!GLEScmValidate::framebufferTarget(target) || !GLEScmValidate::framebufferAttachment(attachment) ||
+                 !GLEScmValidate::framebufferAttachmentParams(pname), GL_INVALID_ENUM);
+    ctx->dispatcher().glGetFramebufferAttachmentParameterivEXT(target,attachment,pname,params);
+}
+
+GL_API void GL_APIENTRY glGenerateMipmapOES(GLenum target) {
+    GET_CTX()
+    SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); 
+    SET_ERROR_IF(!GLEScmValidate::textureTargetLimited(target),GL_INVALID_ENUM);
+    ctx->dispatcher().glGenerateMipmapEXT(target);
+}
+
+GL_API void GL_APIENTRY glCurrentPaletteMatrixOES(GLuint index) {
+    GET_CTX()
+    SET_ERROR_IF(!(ctx->getCaps()->GL_ARB_MATRIX_PALETTE && ctx->getCaps()->GL_ARB_VERTEX_BLEND),GL_INVALID_OPERATION); 
+    ctx->dispatcher().glCurrentPaletteMatrixARB(index);
+}
+
+GL_API void GL_APIENTRY glLoadPaletteFromModelViewMatrixOES() {
+    GET_CTX()
+    SET_ERROR_IF(!(ctx->getCaps()->GL_ARB_MATRIX_PALETTE && ctx->getCaps()->GL_ARB_VERTEX_BLEND),GL_INVALID_OPERATION);
+    GLint matrix[16];
+    ctx->dispatcher().glGetIntegerv(GL_MODELVIEW_MATRIX,matrix);
+    ctx->dispatcher().glMatrixIndexuivARB(1,(GLuint*)matrix);
+
+}
+
+GL_API void GL_APIENTRY glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+    GET_CTX()
+    SET_ERROR_IF(!(ctx->getCaps()->GL_ARB_MATRIX_PALETTE && ctx->getCaps()->GL_ARB_VERTEX_BLEND),GL_INVALID_OPERATION); 
+    ctx->dispatcher().glMatrixIndexPointerARB(size,type,stride,pointer);
+}
+
+GL_API void GL_APIENTRY glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
+    GET_CTX()
+    SET_ERROR_IF(!(ctx->getCaps()->GL_ARB_MATRIX_PALETTE && ctx->getCaps()->GL_ARB_VERTEX_BLEND),GL_INVALID_OPERATION); 
+    ctx->dispatcher().glWeightPointerARB(size,type,stride,pointer);
+
+}
+
+GL_API void GL_APIENTRY glTexGenfOES (GLenum coord, GLenum pname, GLfloat param) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texGen(coord,pname),GL_INVALID_ENUM);
+    if (coord == GL_TEXTURE_GEN_STR_OES) {
+        ctx->dispatcher().glTexGenf(GL_TEXTURE_GEN_S,pname,param);
+        ctx->dispatcher().glTexGenf(GL_TEXTURE_GEN_T,pname,param);
+        ctx->dispatcher().glTexGenf(GL_TEXTURE_GEN_R,pname,param); 
+    }
+    else
+        ctx->dispatcher().glTexGenf(coord,pname,param);
+}
+
+GL_API void GL_APIENTRY glTexGenfvOES (GLenum coord, GLenum pname, const GLfloat *params) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texGen(coord,pname),GL_INVALID_ENUM);
+    if (coord == GL_TEXTURE_GEN_STR_OES) {
+        ctx->dispatcher().glTexGenfv(GL_TEXTURE_GEN_S,pname,params);
+        ctx->dispatcher().glTexGenfv(GL_TEXTURE_GEN_T,pname,params);
+        ctx->dispatcher().glTexGenfv(GL_TEXTURE_GEN_R,pname,params);
+    }
+    else
+        ctx->dispatcher().glTexGenfv(coord,pname,params);
+}
+GL_API void GL_APIENTRY glTexGeniOES (GLenum coord, GLenum pname, GLint param) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texGen(coord,pname),GL_INVALID_ENUM);
+    if (coord == GL_TEXTURE_GEN_STR_OES) {
+        ctx->dispatcher().glTexGeni(GL_TEXTURE_GEN_S,pname,param);
+        ctx->dispatcher().glTexGeni(GL_TEXTURE_GEN_T,pname,param);
+        ctx->dispatcher().glTexGeni(GL_TEXTURE_GEN_R,pname,param); 
+    }
+    else
+        ctx->dispatcher().glTexGeni(coord,pname,param);
+}
+GL_API void GL_APIENTRY glTexGenivOES (GLenum coord, GLenum pname, const GLint *params) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texGen(coord,pname),GL_INVALID_ENUM);
+    if (coord == GL_TEXTURE_GEN_STR_OES) {
+        ctx->dispatcher().glTexGeniv(GL_TEXTURE_GEN_S,pname,params);
+        ctx->dispatcher().glTexGeniv(GL_TEXTURE_GEN_T,pname,params);
+        ctx->dispatcher().glTexGeniv(GL_TEXTURE_GEN_R,pname,params); 
+    }
+    else
+        ctx->dispatcher().glTexGeniv(coord,pname,params);
+}
+GL_API void GL_APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param) {
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texGen(coord,pname),GL_INVALID_ENUM);
+    if (coord == GL_TEXTURE_GEN_STR_OES) {
+        ctx->dispatcher().glTexGenf(GL_TEXTURE_GEN_S,pname,X2F(param));
+        ctx->dispatcher().glTexGenf(GL_TEXTURE_GEN_T,pname,X2F(param));
+        ctx->dispatcher().glTexGenf(GL_TEXTURE_GEN_R,pname,X2F(param)); 
+    }
+    else
+        ctx->dispatcher().glTexGenf(coord,pname,X2F(param));
+}
+GL_API void GL_APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params) {
+    GLfloat tmpParams[1];
+    GET_CTX()
+    SET_ERROR_IF(!GLEScmValidate::texGen(coord,pname),GL_INVALID_ENUM);
+    tmpParams[0] = X2F(params[0]);
+    if (coord == GL_TEXTURE_GEN_STR_OES) {
+        ctx->dispatcher().glTexGenfv(GL_TEXTURE_GEN_S,pname,tmpParams);
+        ctx->dispatcher().glTexGenfv(GL_TEXTURE_GEN_T,pname,tmpParams);
+        ctx->dispatcher().glTexGenfv(GL_TEXTURE_GEN_R,pname,tmpParams); 
+    }
+    else
+        ctx->dispatcher().glTexGenfv(coord,pname,tmpParams);
+}
+
+GL_API void GL_APIENTRY glGetTexGenfvOES (GLenum coord, GLenum pname, GLfloat *params) {
+    GET_CTX()
+    if (coord == GL_TEXTURE_GEN_STR_OES)
+    {
+        GLfloat state_s = GL_FALSE;
+        GLfloat state_t = GL_FALSE;
+        GLfloat state_r = GL_FALSE;
+        ctx->dispatcher().glGetTexGenfv(GL_TEXTURE_GEN_S,pname,&state_s);
+        ctx->dispatcher().glGetTexGenfv(GL_TEXTURE_GEN_T,pname,&state_t);
+        ctx->dispatcher().glGetTexGenfv(GL_TEXTURE_GEN_R,pname,&state_r);
+        *params = state_s && state_t && state_r ? GL_TRUE: GL_FALSE;
+    }
+    else
+        ctx->dispatcher().glGetTexGenfv(coord,pname,params);
+
+}
+GL_API void GL_APIENTRY glGetTexGenivOES (GLenum coord, GLenum pname, GLint *params) {
+    GET_CTX()
+    if (coord == GL_TEXTURE_GEN_STR_OES)
+    {
+        GLint state_s = GL_FALSE;
+        GLint state_t = GL_FALSE;
+        GLint state_r = GL_FALSE;
+        ctx->dispatcher().glGetTexGeniv(GL_TEXTURE_GEN_S,pname,&state_s);
+        ctx->dispatcher().glGetTexGeniv(GL_TEXTURE_GEN_T,pname,&state_t);
+        ctx->dispatcher().glGetTexGeniv(GL_TEXTURE_GEN_R,pname,&state_r);
+        *params = state_s && state_t && state_r ? GL_TRUE: GL_FALSE;
+    }
+    else
+        ctx->dispatcher().glGetTexGeniv(coord,pname,params);
+}
+
+GL_API void GL_APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params) {
+    GET_CTX()
+    GLfloat tmpParams[1];
+
+    if (coord == GL_TEXTURE_GEN_STR_OES)
+    {
+        GLfloat state_s = GL_FALSE;
+        GLfloat state_t = GL_FALSE;
+        GLfloat state_r = GL_FALSE;
+        ctx->dispatcher().glGetTexGenfv(GL_TEXTURE_GEN_S,pname,&state_s);
+        ctx->dispatcher().glGetTexGenfv(GL_TEXTURE_GEN_T,pname,&state_t);
+        ctx->dispatcher().glGetTexGenfv(GL_TEXTURE_GEN_R,pname,&state_r);
+        tmpParams[0] = state_s && state_t && state_r ? GL_TRUE: GL_FALSE;
+    }
+    else
+        ctx->dispatcher().glGetTexGenfv(coord,pname,tmpParams);
+
+    params[0] = F2X(tmpParams[1]);
+}
+
+template <class T, GLenum TypeName>
+void glDrawTexOES (T x, T y, T z, T width, T height) {
+    GET_CTX()
+    int numClipPlanes;
+
+    GLint viewport[4];
+    z = (z>1 ? 1 : (z<0 ?  0 : z));
+
+    T     vertices[4*3] = {x , y, z,
+                             x , y+height, z,
+                             x+width, y+height, z,
+                             x+width, y, z};
+    GLfloat texels[ctx->getMaxTexUnits()][4*2];
+
+    ctx->dispatcher().glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
+    ctx->dispatcher().glPushAttrib(GL_TRANSFORM_BIT);
+
+    //setup projection matrix to draw in viewport aligned coordinates
+    ctx->dispatcher().glMatrixMode(GL_PROJECTION);
+    ctx->dispatcher().glPushMatrix();
+    ctx->dispatcher().glLoadIdentity();
+    ctx->dispatcher().glGetIntegerv(GL_VIEWPORT,viewport);
+    ctx->dispatcher().glOrtho(viewport[0],viewport[0] + viewport[2],viewport[1],viewport[1]+viewport[3],0,-1);
+    //setup texture matrix
+    ctx->dispatcher().glMatrixMode(GL_TEXTURE);
+    ctx->dispatcher().glPushMatrix();
+    ctx->dispatcher().glLoadIdentity();
+    //setup modelview matrix
+    ctx->dispatcher().glMatrixMode(GL_MODELVIEW);
+    ctx->dispatcher().glPushMatrix();
+    ctx->dispatcher().glLoadIdentity();
+    //backup vbo's
+    int array_buffer,element_array_buffer;
+    glGetIntegerv(GL_ARRAY_BUFFER_BINDING,&array_buffer);
+    glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING,&element_array_buffer);
+    ctx->dispatcher().glBindBuffer(GL_ARRAY_BUFFER,0);
+    ctx->dispatcher().glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
+
+    //disable clip planes
+    ctx->dispatcher().glGetIntegerv(GL_MAX_CLIP_PLANES,&numClipPlanes);
+    for (int i=0;i<numClipPlanes;++i)
+        ctx->dispatcher().glDisable(GL_CLIP_PLANE0+i);
+
+    for (int i=0;i<ctx->getMaxTexUnits();++i) {
+        if (ctx->isTextureUnitEnabled(GL_TEXTURE0+i)) {
+            TextureData * texData = NULL;
+            int tex = ctx->getBindedTexture(GL_TEXTURE0+i);
+            ctx->dispatcher().glClientActiveTexture(GL_TEXTURE0+i);
+            ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex);
+            if (objData.Ptr()) {
+                texData = (TextureData*)objData.Ptr();
+                //calculate texels
+                texels[i][0] = (float)(texData->crop_rect[0])/(float)(texData->width);
+                texels[i][1] = (float)(texData->crop_rect[1])/(float)(texData->height);
+
+                texels[i][2] = (float)(texData->crop_rect[0])/(float)(texData->width);
+                texels[i][3] = (float)(texData->crop_rect[3]+texData->crop_rect[1])/(float)(texData->height);
+
+                texels[i][4] = (float)(texData->crop_rect[2]+texData->crop_rect[0])/(float)(texData->width);
+                texels[i][5] = (float)(texData->crop_rect[3]+texData->crop_rect[1])/(float)(texData->height);
+                
+                texels[i][6] = (float)(texData->crop_rect[2]+texData->crop_rect[0])/(float)(texData->width);
+                texels[i][7] = (float)(texData->crop_rect[1])/(float)(texData->height);
+
+                ctx->dispatcher().glTexCoordPointer(2,GL_FLOAT,0,texels[i]);
+             }
+        }
+    }
+
+    //draw rectangle
+    ctx->dispatcher().glEnableClientState(GL_VERTEX_ARRAY);
+    ctx->dispatcher().glVertexPointer(3,TypeName,0,vertices);
+    ctx->dispatcher().glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+    ctx->dispatcher().glDrawArrays(GL_TRIANGLE_FAN,0,4);
+
+    //restore vbo's
+    ctx->dispatcher().glBindBuffer(GL_ARRAY_BUFFER,array_buffer);
+    ctx->dispatcher().glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,element_array_buffer);
+
+    //restore matrix state
+
+    ctx->dispatcher().glMatrixMode(GL_MODELVIEW);
+    ctx->dispatcher().glPopMatrix();
+    ctx->dispatcher().glMatrixMode(GL_TEXTURE);
+    ctx->dispatcher().glPopMatrix();
+    ctx->dispatcher().glMatrixMode(GL_PROJECTION);
+    ctx->dispatcher().glPopMatrix();
+
+    ctx->dispatcher().glPopAttrib();
+    ctx->dispatcher().glPopClientAttrib();
+}
+
+GL_API void GL_APIENTRY glDrawTexsOES (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) {
+    glDrawTexOES<GLshort,GL_SHORT>(x,y,z,width,height);
+}
+
+GL_API void GL_APIENTRY glDrawTexiOES (GLint x, GLint y, GLint z, GLint width, GLint height) {
+    glDrawTexOES<GLint,GL_INT>(x,y,z,width,height);
+}
+
+GL_API void GL_APIENTRY glDrawTexfOES (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) {
+    glDrawTexOES<GLfloat,GL_FLOAT>(x,y,z,width,height);
+}
+
+GL_API void GL_APIENTRY glDrawTexxOES (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) {
+    glDrawTexOES<GLfloat,GL_FLOAT>(X2F(x),X2F(y),X2F(z),X2F(width),X2F(height));
+}
+
+GL_API void GL_APIENTRY glDrawTexsvOES (const GLshort * coords) { 
+    glDrawTexOES<GLshort,GL_SHORT>(coords[0],coords[1],coords[2],coords[3],coords[4]);
+}
+
+GL_API void GL_APIENTRY glDrawTexivOES (const GLint * coords) { 
+    glDrawTexOES<GLint,GL_INT>(coords[0],coords[1],coords[2],coords[3],coords[4]);
+}
+
+GL_API void GL_APIENTRY glDrawTexfvOES (const GLfloat * coords) { 
+    glDrawTexOES<GLfloat,GL_FLOAT>(coords[0],coords[1],coords[2],coords[3],coords[4]);
+}
+
+GL_API void GL_APIENTRY glDrawTexxvOES (const GLfixed * coords) { 
+    glDrawTexOES<GLfloat,GL_FLOAT>(X2F(coords[0]),X2F(coords[1]),X2F(coords[2]),X2F(coords[3]),X2F(coords[4]));
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESutils.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmUtils.cpp
similarity index 98%
rename from tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESutils.cpp
rename to tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmUtils.cpp
index 08c2d6a..891b4e3 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESutils.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmUtils.cpp
@@ -13,7 +13,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-#include "GLESutils.h"
+#include "GLEScmUtils.h"
 
 
 size_t glParamSize(GLenum param)
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESutils.h b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmUtils.h
similarity index 100%
rename from tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESutils.h
rename to tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmUtils.h
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESvalidate.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmValidate.cpp
similarity index 63%
rename from tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESvalidate.cpp
rename to tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmValidate.cpp
index 6bc211f..a2015db 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESvalidate.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmValidate.cpp
@@ -13,27 +13,23 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-#include "GLESvalidate.h"
+#include "GLEScmValidate.h"
 #include <GLcommon/GLutils.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+#include <GLcommon/GLEScontext.h>
+#include "GLEScmValidate.h"
 
-bool  GLESvalidate::textureEnum(GLenum e,unsigned int maxTex) {
-    return e >= GL_TEXTURE0 && e <= (GL_TEXTURE0 + maxTex);
-}
 
-bool GLESvalidate::lightEnum(GLenum e,unsigned int maxLights) {
+bool GLEScmValidate::lightEnum(GLenum e,unsigned int maxLights) {
     return  e >=GL_LIGHT0 && e <= (GL_LIGHT0+maxLights);
 }
 
-bool GLESvalidate::clipPlaneEnum(GLenum e,unsigned int maxClipPlanes) {
+bool GLEScmValidate::clipPlaneEnum(GLenum e,unsigned int maxClipPlanes) {
     return  e >=GL_CLIP_PLANE0 && e <= (GL_CLIP_PLANE0+maxClipPlanes);
 }
 
-bool GLESvalidate::textureTarget(GLenum target) {
-    return target == GL_TEXTURE_2D;
-}
-
-
-bool GLESvalidate::alphaFunc(GLenum f) {
+bool GLEScmValidate::alphaFunc(GLenum f) {
     switch(f) {
     case GL_NEVER:
     case GL_LESS:
@@ -48,7 +44,7 @@
     return false;
 }
 
-bool GLESvalidate::blendSrc(GLenum s) {
+bool GLEScmValidate::blendSrc(GLenum s) {
    switch(s) {
     case GL_ZERO:
     case GL_ONE:
@@ -58,39 +54,25 @@
     case GL_ONE_MINUS_SRC_ALPHA:
     case GL_DST_ALPHA:
     case GL_ONE_MINUS_DST_ALPHA:
+    case GL_SRC_ALPHA_SATURATE:
         return true;
   }
   return false;
 }
 
-bool GLESvalidate::blendDst(GLenum d) {
-   switch(d) {
-    case GL_ZERO:
-    case GL_ONE:
-    case GL_SRC_COLOR:
-    case GL_ONE_MINUS_SRC_COLOR:
-    case GL_SRC_ALPHA:
-    case GL_ONE_MINUS_SRC_ALPHA:
-    case GL_DST_ALPHA:
-    case GL_ONE_MINUS_DST_ALPHA:
-        return true;
-   }
-   return false;
-}
-
-bool GLESvalidate::vertexPointerParams(GLint size,GLsizei stride) {
+bool GLEScmValidate::vertexPointerParams(GLint size,GLsizei stride) {
     return ((size >=2) && (size <= 4)) && (stride >=0) ;
 }
 
-bool GLESvalidate::colorPointerParams(GLint size,GLsizei stride) {
+bool GLEScmValidate::colorPointerParams(GLint size,GLsizei stride) {
     return ((size >=3) && (size <= 4)) && (stride >=0) ;
 }
 
-bool GLESvalidate::texCoordPointerParams(GLint size,GLsizei stride) {
-    return ((size >=1) && (size <= 4)) && (stride >=0) ;
+bool GLEScmValidate::texCoordPointerParams(GLint size,GLsizei stride) {
+    return ((size >=2) && (size <= 4)) && (stride >=0) ;
 }
 
-bool GLESvalidate::supportedArrays(GLenum arr) {
+bool GLEScmValidate::supportedArrays(GLenum arr) {
     switch(arr) {
     case GL_COLOR_ARRAY:
     case GL_NORMAL_ARRAY:
@@ -102,25 +84,7 @@
     return false;
 }
 
-bool GLESvalidate::drawMode(GLenum mode) {
-    switch(mode) {
-    case GL_POINTS:
-    case GL_LINE_STRIP:
-    case GL_LINE_LOOP:
-    case GL_LINES:
-    case GL_TRIANGLE_STRIP:
-    case GL_TRIANGLE_FAN:
-    case GL_TRIANGLES:
-        return true;
-    }
-    return false;
-}
-
-bool GLESvalidate::drawType(GLenum mode) {
-    return mode == GL_UNSIGNED_BYTE || mode == GL_UNSIGNED_SHORT;
-}
-
-bool GLESvalidate::hintTargetMode(GLenum target,GLenum mode) {
+bool GLEScmValidate::hintTargetMode(GLenum target,GLenum mode) {
    switch(target) {
    case GL_FOG_HINT:
    case GL_GENERATE_MIPMAP_HINT:
@@ -140,12 +104,13 @@
    return true;
 }
 
-bool GLESvalidate::texParams(GLenum target,GLenum pname) {
+bool GLEScmValidate::texParams(GLenum target,GLenum pname) {
     switch(pname) {
     case GL_TEXTURE_MIN_FILTER:
     case GL_TEXTURE_MAG_FILTER:
     case GL_TEXTURE_WRAP_S:
     case GL_TEXTURE_WRAP_T:
+    case GL_TEXTURE_CROP_RECT_OES:
         break;
     default:
         return false;
@@ -153,9 +118,10 @@
     return target == GL_TEXTURE_2D;
 }
 
-bool GLESvalidate::texEnv(GLenum target,GLenum pname) {
+bool GLEScmValidate::texEnv(GLenum target,GLenum pname) {
     switch(pname) {
     case GL_TEXTURE_ENV_MODE:
+    case GL_TEXTURE_ENV_COLOR:
     case GL_COMBINE_RGB:
     case GL_COMBINE_ALPHA:
     case GL_SRC0_RGB:
@@ -180,7 +146,7 @@
     return (target == GL_TEXTURE_ENV || target == GL_POINT_SPRITE_OES);
 }
 
-bool GLESvalidate::capability(GLenum cap,int maxLights,int maxClipPlanes) {
+bool GLEScmValidate::capability(GLenum cap,int maxLights,int maxClipPlanes) {
     switch(cap) {
     case GL_ALPHA_TEST:
     case GL_BLEND:
@@ -211,33 +177,11 @@
     case GL_VERTEX_ARRAY:
         return true;
     }
-    return GLESvalidate::lightEnum(cap,maxLights) || GLESvalidate::clipPlaneEnum(cap,maxClipPlanes);
+    return GLEScmValidate::lightEnum(cap,maxLights) || GLEScmValidate::clipPlaneEnum(cap,maxClipPlanes);
 }
 
-bool GLESvalidate::pixelType(GLenum type) {
-    switch(type) {
-    case GL_UNSIGNED_BYTE:
-    case GL_UNSIGNED_SHORT_5_6_5:
-    case GL_UNSIGNED_SHORT_4_4_4_4:
-    case GL_UNSIGNED_SHORT_5_5_5_1:
-        return true;
-    }
-    return false;
-}
 
-bool GLESvalidate::pixelFrmt(GLenum format) {
-    switch(format) {
-    case GL_ALPHA:
-    case GL_RGB:
-    case GL_RGBA:
-    case GL_LUMINANCE:
-    case GL_LUMINANCE_ALPHA:
-        return true;
-    }
-    return false;
-}
-
-bool GLESvalidate::texCompImgFrmt(GLenum format) {
+bool GLEScmValidate::texCompImgFrmt(GLenum format) {
     switch(format) {
     case GL_PALETTE4_RGB8_OES:
     case GL_PALETTE4_RGBA8_OES:
@@ -254,28 +198,68 @@
     return false;
 }
 
-bool GLESvalidate::pixelOp(GLenum format,GLenum type) {
-     switch(type) {
-     case GL_UNSIGNED_SHORT_4_4_4_4:
-     case GL_UNSIGNED_SHORT_5_5_5_1:
-         return format == GL_RGBA;
-     case GL_UNSIGNED_SHORT_5_6_5:
-         return format == GL_RGB;
-     }
-     return true;
-}
 
-bool GLESvalidate::texImgDim(GLsizei width,GLsizei height,int maxTexSize) {
+bool GLEScmValidate::texImgDim(GLsizei width,GLsizei height,int maxTexSize) {
 
  if( width < 0 || height < 0 || width > maxTexSize || height > maxTexSize)
     return false;
  return isPowerOf2(width) && isPowerOf2(height);
 }
 
-bool GLESvalidate::bufferTarget(GLenum target) {
-    return target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER;
+
+bool GLEScmValidate::blendDst(GLenum d) {
+   switch(d) {
+    case GL_ZERO:
+    case GL_ONE:
+    case GL_SRC_COLOR:
+    case GL_ONE_MINUS_SRC_COLOR:
+    case GL_SRC_ALPHA:
+    case GL_ONE_MINUS_SRC_ALPHA:
+    case GL_DST_ALPHA:
+    case GL_ONE_MINUS_DST_ALPHA:
+        return true;
+   }
+   return false;
 }
 
-bool GLESvalidate::bufferParam(GLenum param) {
- return  (param == GL_BUFFER_SIZE) || (param == GL_BUFFER_USAGE);
+bool GLEScmValidate::renderbufferInternalFrmt(GLEScontext* ctx, GLenum internalformat)
+{
+    switch (internalformat) {
+    case GL_DEPTH_COMPONENT16_OES:
+    case GL_RGBA4_OES:
+    case GL_RGB5_A1_OES:
+    case GL_RGB565_OES:
+    case GL_STENCIL_INDEX1_OES:
+    case GL_STENCIL_INDEX4_OES:
+    case GL_STENCIL_INDEX8_OES:
+    case GL_RGB8_OES:
+    case GL_RGBA8_OES:
+    case GL_DEPTH_COMPONENT24_OES:
+    case GL_DEPTH_COMPONENT32_OES:
+        return true;
+    }
+    if (ctx->getCaps()->GL_NV_PACKED_DEPTH_STENCIL && internalformat==GL_DEPTH24_STENCIL8_OES)
+        return true;
+
+    return false;
 }
+
+bool GLEScmValidate::stencilOp(GLenum param) {
+    switch (param) {
+    case GL_KEEP:
+    case GL_ZERO:
+    case GL_REPLACE:
+    case GL_INCR:
+    case GL_DECR:
+    case GL_INVERT:
+    case GL_INCR_WRAP_OES:
+    case GL_DECR_WRAP_OES:
+      return true;
+    }
+    return false;
+}
+
+bool GLEScmValidate::texGen(GLenum coord, GLenum pname) {
+    return (coord == GL_TEXTURE_GEN_STR_OES && pname == GL_TEXTURE_GEN_MODE_OES);
+}
+
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESvalidate.h b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmValidate.h
similarity index 76%
rename from tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESvalidate.h
rename to tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmValidate.h
index a4f785b..58fe544 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESvalidate.h
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmValidate.h
@@ -13,38 +13,33 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-#ifndef GLES_VALIDATE_H
-#define GLES_VALIDATE_H
+#ifndef GLES_CM_VALIDATE_H
+#define GLES_CM_VALIDATE_H
 
 #include <GLES/gl.h>
-
-struct GLESvalidate
+#include <GLcommon/GLESvalidate.h>
+struct GLEScmValidate : public GLESvalidate
 {
-
+static bool blendSrc(GLenum s);
+static bool blendDst(GLenum d);
 static bool lightEnum(GLenum e,unsigned int maxLIghts);
 static bool clipPlaneEnum(GLenum e,unsigned int maxClipPlanes);
 static bool alphaFunc(GLenum f);
-static bool blendSrc(GLenum s);
-static bool blendDst(GLenum d);
 static bool vertexPointerParams(GLint size,GLsizei stride);
 static bool colorPointerParams(GLint size,GLsizei stride);
 static bool supportedArrays(GLenum arr);
-static bool drawMode(GLenum mode);
-static bool drawType(GLenum mode);
 static bool hintTargetMode(GLenum target,GLenum mode);
 static bool capability(GLenum cap,int maxLights,int maxClipPlanes);
 static bool texParams(GLenum target,GLenum pname);
 static bool texCoordPointerParams(GLint size,GLsizei stride);
-static bool textureTarget(GLenum target);
-static bool textureEnum(GLenum e,unsigned int maxTex);
+
 static bool texEnv(GLenum target,GLenum pname);
-static bool pixelFrmt(GLenum format);
-static bool pixelType(GLenum type);
-static bool pixelOp(GLenum format,GLenum type);
 static bool texCompImgFrmt(GLenum format);
 static bool texImgDim(GLsizei width,GLsizei height,int maxTexSize);
-static bool bufferTarget(GLenum target);
-static bool bufferParam(GLenum param);
+
+static bool renderbufferInternalFrmt(GLEScontext * ctx, GLenum internalformat);
+static bool stencilOp(GLenum param);
+static bool texGen(GLenum coord,GLenum pname);
 };
 
 #endif
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScontext.h b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScontext.h
deleted file mode 100644
index 5291a52..0000000
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScontext.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-* Copyright (C) 2011 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef GLES_CONTEX_H
-#define GLES_CONTEX_H
-
-#include "GLDispatch.h"
-#include "GLESpointer.h"
-#include "GLESbuffer.h"
-#include <map>
-#include <vector>
-#include <utils/threads.h>
-
-#define MAX_TEX_UNITS 8
-
-typedef std::map<GLenum,GLESpointer*>  ArraysMap;
-typedef std::map<GLfloat,std::vector<int> > PointSizeIndices;
-
-struct GLESFloatArrays
-{
-    GLESFloatArrays(){};
-    ~GLESFloatArrays();
-    std::map<GLenum,GLfloat*> arrays;
-};
-
-
-struct GLsupport {
-    GLsupport():maxLights(0),maxClipPlane(0),maxTexUnits(0),maxTexSize(0){};
-    int  maxLights;
-    int  maxClipPlane;
-    int  maxTexUnits;
-    int  maxTexSize;
-};
-
-class GLEScontext
-{
-public:
-    void init();
-    GLEScontext();
-    GLenum getGLerror();
-
-    bool  isArrEnabled(GLenum);
-    void  enableArr(GLenum arr,bool enable);
-    void  setGLerror(GLenum err);
-    void  setActiveTexture(GLenum tex);
-    const GLvoid* setPointer(GLenum arrType,GLint size,GLenum type,GLsizei stride,const GLvoid* data);
-    unsigned int getBindedTexture(){return m_tex2DBind[m_activeTexture];};
-    void setBindedTexture(unsigned int tex){ m_tex2DBind[m_activeTexture] = tex;};
-    const GLESpointer* getPointer(GLenum arrType);
-
-    void convertArrs(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct);
-    void drawPointsArrs(GLESFloatArrays& arrs,GLint first,GLsizei count);
-    void drawPointsElems(GLESFloatArrays& arrs,GLsizei count,GLenum type,const GLvoid* indices);
-
-    void bindBuffer(GLenum target,GLuint buffer);
-    bool isBuffer(GLuint buffer);
-    bool isBindedBuffer(GLenum target);
-    GLvoid* getBindedBuffer(GLenum target);
-    void getBufferSize(GLenum target,GLint* param);
-    void getBufferUsage(GLenum target,GLint* param);
-    bool setBufferData(GLenum target,GLsizeiptr size,const GLvoid* data,GLenum usage);
-    bool setBufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,const GLvoid* data);
-    void setShareGroup(ShareGroupPtr grp){m_shareGroup = grp;};
-
-    static GLDispatch& dispatcher();
-    static int getMaxLights(){return s_glSupport.maxLights;}
-    static int getMaxClipPlanes(){return s_glSupport.maxClipPlane;}
-    static int getMaxTexUnits(){return s_glSupport.maxTexUnits;}
-    static int getMaxTexSize(){return s_glSupport.maxTexSize;}
-
-
-    ~GLEScontext();
-private:
-
-    GLuint getBuffer(GLenum target);
-    void sendArr(GLvoid* arr,GLenum arrayType,GLint size,GLsizei stride,int pointsIndex = -1);
-    void drawPoints(PointSizeIndices* points);
-    void drawPointsData(GLESFloatArrays& arrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices_in,bool isElemsDraw);
-
-    void chooseConvertMethod(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id,unsigned int& index);
-    void convertDirect(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum array_id,GLESpointer* p,unsigned int& index);
-    void convertDirectVBO(GLint first,GLsizei count,GLenum array_id,GLESpointer* p);
-    void convertIndirect(GLESFloatArrays& fArrs,GLsizei count,GLenum type,const GLvoid* indices,GLenum array_id,GLESpointer* p,unsigned int& index);
-    void convertIndirectVBO(GLsizei count,GLenum indices_type,const GLvoid* indices,GLenum array_id,GLESpointer* p);
-
-    static GLDispatch     s_glDispatch;
-    static GLsupport      s_glSupport;
-    static android::Mutex s_lock;
-
-    ArraysMap             m_map;
-    GLESpointer*          m_texCoords;
-    GLenum                m_glError;
-    unsigned int          m_activeTexture;
-    unsigned int          m_tex2DBind[MAX_TEX_UNITS];
-    unsigned int          m_arrayBuffer;
-    unsigned int          m_elementBuffer;
-    int                   m_pointsIndex;
-    bool                  m_initialized;
-    ShareGroupPtr         m_shareGroup;
-};
-
-#endif
-
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESimp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESimp.cpp
deleted file mode 100644
index d37791f..0000000
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESimp.cpp
+++ /dev/null
@@ -1,1263 +0,0 @@
-/*
-* Copyright (C) 2011 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifdef _WIN32
-#undef GL_API
-#define GL_API __declspec(dllexport)
-#endif
-#include <stdio.h>
-#include "GLDispatch.h"
-#include "GLEScontext.h"
-#include "GLESvalidate.h"
-#include "GLESutils.h"
-#include "GLfixed_ops.h"
-#include "TextureUtils.h"
-
-#include <GLcommon/TranslatorIfaces.h>
-#include <GLcommon/ThreadInfo.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#include <cmath>
-
-extern "C" {
-
-//decleration
-static void initContext(GLEScontext* ctx);
-static void deleteGLESContext(GLEScontext* ctx);
-static void setShareGroup(GLEScontext* ctx,ShareGroupPtr grp);
-static GLEScontext* createGLESContext();
-static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName);
-
-}
-
-/************************************** GLES EXTENSIONS *********************************************************/
-#define GLES_EXTENTIONS 1
-//extensions decleration
-void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image);
-
-//extentions descriptor
-static ExtentionDescriptor s_glesExtentions[] = {
-                                                    {"glEGLImageTargetTexture2DOES",(__translatorMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES}
-                                                };
-/****************************************************************************************************************/
-typedef void(*FUNCPTR)();
-
-static EGLiface*  s_eglIface = NULL;
-static GLESiface  s_glesIface = {
-    createGLESContext:createGLESContext,
-    initContext      :initContext,
-    deleteGLESContext:deleteGLESContext,
-    flush            :(FUNCPTR)glFlush,
-    finish           :(FUNCPTR)glFinish,
-    setShareGroup    :setShareGroup,
-    getProcAddress   :getProcAddress
-};
-
-extern "C" {
-
-static void initContext(GLEScontext* ctx) {
-    ctx->init();
-}
-static GLEScontext* createGLESContext() {
-    GLEScontext* ctx = new GLEScontext();
-    return ctx;
-}
-
-static void deleteGLESContext(GLEScontext* ctx) {
-    if(ctx) delete ctx;
-}
-
-static void setShareGroup(GLEScontext* ctx,ShareGroupPtr grp) {
-    if(ctx) {
-        ctx->setShareGroup(grp);
-    }
-}
-
-static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName) {
-    for(int i=0;i<GLES_EXTENTIONS;i++){
-        if(strcmp(procName,s_glesExtentions[i].name) == 0){
-            return s_glesExtentions[i].address;
-        }
-    }
-    return NULL;
-}
-GL_API GLESiface* __translator_getIfaces(EGLiface* eglIface){
-    s_eglIface = eglIface;
-    return & s_glesIface;
-}
-
-}
-
-#define GET_THREAD()                                                         \
-            ThreadInfo* thrd = NULL;                                         \
-            if(s_eglIface) {                                                 \
-                thrd = s_eglIface->getThreadInfo();                          \
-            } else {                                                         \
-                fprintf(stderr,"Context wasn't initialized yet \n");         \
-            }
-
-
-#define GET_CTX()                                                            \
-            GET_THREAD();                                                    \
-            if(!thrd) return;                                                \
-            GLEScontext *ctx = static_cast<GLEScontext*>(thrd->glesContext); \
-            if(!ctx) return;
-
-#define GET_CTX_RET(failure_ret)                                             \
-            GET_THREAD();                                                    \
-            if(!thrd) return failure_ret;                                    \
-            GLEScontext *ctx = static_cast<GLEScontext*>(thrd->glesContext); \
-            if(!ctx) return failure_ret;
-
-
-#define SET_ERROR_IF(condition,err) if((condition)) {                        \
-                        ctx->setGLerror(err);                                \
-                        return;                                              \
-                    }
-
-
-#define RET_AND_SET_ERROR_IF(condition,err,ret) if((condition)) {            \
-                        ctx->setGLerror(err);                                \
-                        return ret;                                          \
-                    }
-
-
-GL_API GLboolean GL_APIENTRY glIsBuffer(GLuint buffer) {
-    GET_CTX_RET(GL_FALSE)
-
-    if(buffer && thrd->shareGroup.Ptr()) {
-       ObjectDataPtr objData = thrd->shareGroup->getObjectData(VERTEXBUFFER,buffer);
-       return objData.Ptr() ? ((GLESbuffer*)objData.Ptr())->wasBinded():GL_FALSE;
-    }
-    return GL_FALSE;
-}
-
-GL_API GLboolean GL_APIENTRY  glIsEnabled( GLenum cap) {
-    GET_CTX_RET(GL_FALSE)
-    RET_AND_SET_ERROR_IF(!GLESvalidate::capability(cap,ctx->getMaxLights(),ctx->getMaxClipPlanes()),GL_INVALID_ENUM,GL_FALSE);
-
-    if(cap == GL_POINT_SIZE_ARRAY_OES) return ctx->isArrEnabled(cap);
-    return ctx->dispatcher().glIsEnabled(cap);
-}
-
-GL_API GLboolean GL_APIENTRY  glIsTexture( GLuint texture) {
-    GET_CTX_RET(GL_FALSE)
-    if(texture && thrd->shareGroup.Ptr()){
-        return thrd->shareGroup->isObject(TEXTURE,texture) ? GL_TRUE :GL_FALSE;
-    }
-    return ctx->dispatcher().glIsTexture(texture);
-}
-
-GL_API GLenum GL_APIENTRY  glGetError(void) {
-    GET_CTX_RET(GL_NO_ERROR)
-    GLenum err = ctx->getGLerror();
-    if(err != GL_NO_ERROR) {
-        ctx->setGLerror(GL_NO_ERROR);
-        return err;
-    }
-
-    return ctx->dispatcher().glGetError();
-}
-
-GL_API const GLubyte * GL_APIENTRY  glGetString( GLenum name) {
-
-    GET_CTX_RET(NULL)
-    static GLubyte VENDOR[]     = "Google";
-    static GLubyte RENDERER[]   = "OpenGL ES-CM 1.1";
-    static GLubyte VERSION[]    = "OpenGL ES-CM 1.1";
-    static GLubyte EXTENSIONS[] = "GL_OES_compressed_paletted_texture "
-                                  "GL_OES_point_size_array";
-    switch(name) {
-        case GL_VENDOR:
-            return VENDOR;
-        case GL_RENDERER:
-            return RENDERER;
-        case GL_VERSION:
-            return VERSION;
-        case GL_EXTENSIONS:
-            return EXTENSIONS;
-        default:
-            RET_AND_SET_ERROR_IF(true,GL_INVALID_ENUM,NULL);
-    }
-}
-
-GL_API void GL_APIENTRY  glActiveTexture( GLenum texture) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::textureEnum(texture,ctx->getMaxTexUnits()),GL_INVALID_ENUM);
-    ctx->dispatcher().glActiveTexture(texture);
-}
-
-GL_API void GL_APIENTRY  glAlphaFunc( GLenum func, GLclampf ref) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::alphaFunc(func),GL_INVALID_ENUM);
-    ctx->dispatcher().glAlphaFunc(func,ref);
-}
-
-
-GL_API void GL_APIENTRY  glAlphaFuncx( GLenum func, GLclampx ref) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::alphaFunc(func),GL_INVALID_ENUM);
-    ctx->dispatcher().glAlphaFunc(func,X2F(ref));
-}
-
-
-GL_API void GL_APIENTRY  glBindBuffer( GLenum target, GLuint buffer) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::bufferTarget(target),GL_INVALID_ENUM);
-
-    //if buffer wasn't generated before,generate one
-    if(thrd->shareGroup.Ptr() && !thrd->shareGroup->isObject(VERTEXBUFFER,buffer)){
-        thrd->shareGroup->genName(VERTEXBUFFER,buffer);
-        thrd->shareGroup->setObjectData(VERTEXBUFFER,buffer,ObjectDataPtr(new GLESbuffer()));
-    }
-    ctx->bindBuffer(target,buffer);
-    GLESbuffer* vbo = (GLESbuffer*)thrd->shareGroup->getObjectData(VERTEXBUFFER,buffer).Ptr();
-    vbo->wasBinded();
-}
-
-
-GL_API void GL_APIENTRY  glBindTexture( GLenum target, GLuint texture) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::textureTarget(target),GL_INVALID_ENUM)
-
-    GLuint globalTextureName = texture;
-    if(texture && thrd->shareGroup.Ptr()){
-        globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture);
-        //if texture wasn't generated before,generate one
-        if(!globalTextureName){
-            thrd->shareGroup->genName(TEXTURE,texture);
-            globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture);
-        }
-    }
-    ctx->setBindedTexture(globalTextureName);
-    ctx->dispatcher().glBindTexture(target,globalTextureName);
-}
-
-GL_API void GL_APIENTRY  glBlendFunc( GLenum sfactor, GLenum dfactor) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::blendSrc(sfactor) || !GLESvalidate::blendDst(dfactor),GL_INVALID_ENUM)
-    ctx->dispatcher().glBlendFunc(sfactor,dfactor);
-}
-
-GL_API void GL_APIENTRY  glBufferData( GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::bufferTarget(target),GL_INVALID_ENUM);
-    SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
-    ctx->setBufferData(target,size,data,usage);
-}
-
-GL_API void GL_APIENTRY  glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) {
-    GET_CTX()
-    SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
-    SET_ERROR_IF(!GLESvalidate::bufferTarget(target),GL_INVALID_ENUM);
-    SET_ERROR_IF(!ctx->setBufferSubData(target,offset,size,data),GL_INVALID_VALUE);
-}
-
-GL_API void GL_APIENTRY  glClear( GLbitfield mask) {
-    GET_CTX()
-    ctx->dispatcher().glClear(mask);
-}
-
-GL_API void GL_APIENTRY  glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
-    GET_CTX()
-    ctx->dispatcher().glClearColor(red,green,blue,alpha);
-}
-
-GL_API void GL_APIENTRY  glClearColorx( GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) {
-    GET_CTX()
-    ctx->dispatcher().glClearColor(X2F(red),X2F(green),X2F(blue),X2F(alpha));
-}
-
-
-GL_API void GL_APIENTRY  glClearDepthf( GLclampf depth) {
-    GET_CTX()
-    ctx->dispatcher().glClearDepth(depth);
-}
-
-GL_API void GL_APIENTRY  glClearDepthx( GLclampx depth) {
-    GET_CTX()
-    ctx->dispatcher().glClearDepth(X2F(depth));
-}
-
-GL_API void GL_APIENTRY  glClearStencil( GLint s) {
-    GET_CTX()
-    ctx->dispatcher().glClearStencil(s);
-}
-
-GL_API void GL_APIENTRY  glClientActiveTexture( GLenum texture) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::textureEnum(texture,ctx->getMaxTexUnits()),GL_INVALID_ENUM);
-    ctx->setActiveTexture(texture);
-    ctx->dispatcher().glClientActiveTexture(texture);
-
-}
-
-GL_API void GL_APIENTRY  glClipPlanef( GLenum plane, const GLfloat *equation) {
-    GET_CTX()
-    GLdouble tmpEquation[4];
-
-    for(int i = 0; i < 4; i++) {
-         tmpEquation[i] = static_cast<GLdouble>(equation[i]);
-    }
-    ctx->dispatcher().glClipPlane(plane,tmpEquation);
-}
-
-GL_API void GL_APIENTRY  glClipPlanex( GLenum plane, const GLfixed *equation) {
-    GET_CTX()
-    GLdouble tmpEquation[4];
-    for(int i = 0; i < 4; i++) {
-        tmpEquation[i] = X2D(equation[i]);
-    }
-    ctx->dispatcher().glClipPlane(plane,tmpEquation);
-}
-
-GL_API void GL_APIENTRY  glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
-    GET_CTX()
-    ctx->dispatcher().glColor4f(red,green,blue,alpha);
-}
-
-GL_API void GL_APIENTRY  glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) {
-    GET_CTX()
-    ctx->dispatcher().glColor4ub(red,green,blue,alpha);
-}
-
-GL_API void GL_APIENTRY  glColor4x( GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) {
-    GET_CTX()
-    ctx->dispatcher().glColor4f(X2F(red),X2F(green),X2F(blue),X2F(alpha));
-}
-
-GL_API void GL_APIENTRY  glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
-    GET_CTX()
-    ctx->dispatcher().glColorMask(red,green,blue,alpha);
-}
-
-GL_API void GL_APIENTRY  glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::colorPointerParams(size,stride),GL_INVALID_VALUE);
-
-    const GLvoid* data = ctx->setPointer(GL_COLOR_ARRAY,size,type,stride,pointer);
-    if(type != GL_FIXED) ctx->dispatcher().glColorPointer(size,type,stride,data);
-}
-
-GL_API void GL_APIENTRY  glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) {
-    GET_CTX()
-    SET_ERROR_IF(!(GLESvalidate::texCompImgFrmt(internalformat) && GLESvalidate::textureTarget(target)),GL_INVALID_ENUM);
-    SET_ERROR_IF(level > log2(ctx->getMaxTexSize())|| border !=0 || level > 0 || !GLESvalidate::texImgDim(width,height,ctx->getMaxTexSize()+2),GL_INVALID_VALUE)
-
-    int nMipmaps = -level + 1;
-    GLsizei tmpWidth  = width;
-    GLsizei tmpHeight = height;
-
-    for(int i = 0; i < nMipmaps ; i++)
-    {
-       GLenum uncompressedFrmt;
-       unsigned char* uncompressed = uncompressTexture(internalformat,uncompressedFrmt,width,height,imageSize,data,i);
-       ctx->dispatcher().glTexImage2D(target,i,uncompressedFrmt,width,height,border,uncompressedFrmt,GL_UNSIGNED_BYTE,uncompressed);
-       tmpWidth/=2;
-       tmpHeight/=2;
-       delete uncompressed;
-    }
-    ctx->dispatcher().glCompressedTexImage2D(target,level,internalformat,width,height,border,imageSize,data);
-}
-
-GL_API void GL_APIENTRY  glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) {
-    GET_CTX()
-    SET_ERROR_IF(!(GLESvalidate::texCompImgFrmt(format) && GLESvalidate::textureTarget(target)),GL_INVALID_ENUM);
-    SET_ERROR_IF(level < 0 || level > log2(ctx->getMaxTexSize()),GL_INVALID_VALUE)
-
-    GLenum uncompressedFrmt;
-    unsigned char* uncompressed = uncompressTexture(format,uncompressedFrmt,width,height,imageSize,data,level);
-    ctx->dispatcher().glTexSubImage2D(target,level,xoffset,yoffset,width,height,uncompressedFrmt,GL_UNSIGNED_BYTE,uncompressed);
-    delete uncompressed;
-}
-
-GL_API void GL_APIENTRY  glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
-    GET_CTX()
-    SET_ERROR_IF(!(GLESvalidate::pixelFrmt(internalformat) && GLESvalidate::textureTarget(target)),GL_INVALID_ENUM);
-    SET_ERROR_IF(border != 0,GL_INVALID_VALUE);
-    ctx->dispatcher().glCopyTexImage2D(target,level,internalformat,x,y,width,height,border);
-}
-
-GL_API void GL_APIENTRY  glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::textureTarget(target),GL_INVALID_ENUM);
-    ctx->dispatcher().glCopyTexSubImage2D(target,level,xoffset,yoffset,x,y,width,height);
-}
-
-GL_API void GL_APIENTRY  glCullFace( GLenum mode) {
-    GET_CTX()
-    ctx->dispatcher().glCullFace(mode);
-}
-
-GL_API void GL_APIENTRY  glDeleteBuffers( GLsizei n, const GLuint *buffers) {
-    GET_CTX()
-    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
-    if(thrd->shareGroup.Ptr()) {
-        for(int i=0; i < n; i++){
-           thrd->shareGroup->deleteName(VERTEXBUFFER,buffers[i]);
-        }
-    }
-}
-
-GL_API void GL_APIENTRY  glDeleteTextures( GLsizei n, const GLuint *textures) {
-    GET_CTX()
-    if(thrd->shareGroup.Ptr()) {
-        for(int i=0; i < n; i++){
-           thrd->shareGroup->deleteName(TEXTURE,textures[i]);
-           const GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,textures[i]);
-           ctx->dispatcher().glDeleteTextures(1,&globalTextureName);
-        }
-    }
-}
-
-GL_API void GL_APIENTRY  glDepthFunc( GLenum func) {
-    GET_CTX()
-    ctx->dispatcher().glDepthFunc(func);
-}
-
-GL_API void GL_APIENTRY  glDepthMask( GLboolean flag) {
-    GET_CTX()
-    ctx->dispatcher().glDepthMask(flag);
-}
-
-GL_API void GL_APIENTRY  glDepthRangef( GLclampf zNear, GLclampf zFar) {
-    GET_CTX()
-    ctx->dispatcher().glDepthRange(zNear,zFar);
-}
-
-GL_API void GL_APIENTRY  glDepthRangex( GLclampx zNear, GLclampx zFar) {
-    GET_CTX()
-    ctx->dispatcher().glDepthRange(X2F(zNear),X2F(zFar));
-}
-
-GL_API void GL_APIENTRY  glDisable( GLenum cap) {
-    GET_CTX()
-    ctx->dispatcher().glDisable(cap);
-}
-
-GL_API void GL_APIENTRY  glDisableClientState( GLenum array) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::supportedArrays(array),GL_INVALID_ENUM)
-
-    ctx->enableArr(array,false);
-    if(array != GL_POINT_SIZE_ARRAY_OES) ctx->dispatcher().glDisableClientState(array);
-}
-
-
-GL_API void GL_APIENTRY  glDrawArrays( GLenum mode, GLint first, GLsizei count) {
-    GET_CTX()
-    SET_ERROR_IF(count < 0,GL_INVALID_VALUE)
-    SET_ERROR_IF(!GLESvalidate::drawMode(mode),GL_INVALID_ENUM)
-
-    if(!ctx->isArrEnabled(GL_VERTEX_ARRAY)) return;
-
-    GLESFloatArrays tmpArrs;
-    ctx->convertArrs(tmpArrs,first,count,0,NULL,true);
-    if(mode != GL_POINTS || !ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){
-        ctx->dispatcher().glDrawArrays(mode,first,count);
-    }
-    else{
-        ctx->drawPointsArrs(tmpArrs,first,count);
-    }
-}
-
-GL_API void GL_APIENTRY  glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *elementsIndices) {
-    GET_CTX()
-    SET_ERROR_IF(count < 0,GL_INVALID_VALUE)
-    SET_ERROR_IF((!GLESvalidate::drawMode(mode) || !GLESvalidate::drawType(type)),GL_INVALID_ENUM)
-    const GLvoid* indices = elementsIndices;
-    GLESFloatArrays tmpArrs;
-    if(ctx->isBindedBuffer(GL_ELEMENT_ARRAY_BUFFER)) { // if vbo is binded take the indices from the vbo
-        const unsigned char* buf = static_cast<unsigned char *>(ctx->getBindedBuffer(GL_ELEMENT_ARRAY_BUFFER));
-        indices = buf+reinterpret_cast<unsigned int>(elementsIndices);
-    }
-
-    ctx->convertArrs(tmpArrs,0,count,type,indices,false);
-    if(mode != GL_POINTS || !ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){
-        ctx->dispatcher().glDrawElements(mode,count,type,indices);
-    }
-    else{
-        ctx->drawPointsElems(tmpArrs,count,type,indices);
-    }
-}
-
-GL_API void GL_APIENTRY  glEnable( GLenum cap) {
-    GET_CTX()
-    ctx->dispatcher().glEnable(cap);
-}
-
-GL_API void GL_APIENTRY  glEnableClientState( GLenum array) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::supportedArrays(array),GL_INVALID_ENUM)
-
-    ctx->enableArr(array,true);
-    if(array != GL_POINT_SIZE_ARRAY_OES) ctx->dispatcher().glEnableClientState(array);
-}
-
-GL_API void GL_APIENTRY  glFinish( void) {
-    GET_CTX()
-    ctx->dispatcher().glFinish();
-}
-
-GL_API void GL_APIENTRY  glFlush( void) {
-    GET_CTX()
-    ctx->dispatcher().glFlush();
-}
-
-GL_API void GL_APIENTRY  glFogf( GLenum pname, GLfloat param) {
-    GET_CTX()
-    ctx->dispatcher().glFogf(pname,param);
-}
-
-GL_API void GL_APIENTRY  glFogfv( GLenum pname, const GLfloat *params) {
-    GET_CTX()
-    ctx->dispatcher().glFogfv(pname,params);
-}
-
-GL_API void GL_APIENTRY  glFogx( GLenum pname, GLfixed param) {
-    GET_CTX()
-    ctx->dispatcher().glFogf(pname,(pname == GL_FOG_MODE)? static_cast<GLfloat>(param):X2F(param));
-}
-
-GL_API void GL_APIENTRY  glFogxv( GLenum pname, const GLfixed *params) {
-    GET_CTX()
-    if(pname == GL_FOG_MODE) {
-        GLfloat tmpParam = static_cast<GLfloat>(params[0]);
-        ctx->dispatcher().glFogfv(pname,&tmpParam);
-    } else {
-        GLfloat tmpParams[4];
-        for(int i=0; i< 4; i++) {
-            tmpParams[i] = X2F(params[i]);
-        }
-        ctx->dispatcher().glFogfv(pname,tmpParams);
-    }
-
-}
-
-GL_API void GL_APIENTRY  glFrontFace( GLenum mode) {
-    GET_CTX()
-    ctx->dispatcher().glFrontFace(mode);
-}
-
-GL_API void GL_APIENTRY  glFrustumf( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
-    GET_CTX()
-    ctx->dispatcher().glFrustum(left,right,bottom,top,zNear,zFar);
-}
-
-GL_API void GL_APIENTRY  glFrustumx( GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
-    GET_CTX()
-    ctx->dispatcher().glFrustum(X2F(left),X2F(right),X2F(bottom),X2F(top),X2F(zNear),X2F(zFar));
-}
-
-GL_API void GL_APIENTRY  glGenBuffers( GLsizei n, GLuint *buffers) {
-    GET_CTX()
-    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
-    if(thrd->shareGroup.Ptr()) {
-        for(int i=0; i<n ;i++) {
-            buffers[i] = thrd->shareGroup->genName(VERTEXBUFFER);
-            //generating vbo object related to this buffer name
-            thrd->shareGroup->setObjectData(VERTEXBUFFER,buffers[i],ObjectDataPtr(new GLESbuffer()));
-        }
-    }
-}
-
-GL_API void GL_APIENTRY  glGenTextures( GLsizei n, GLuint *textures) {
-    GET_CTX();
-    if(thrd->shareGroup.Ptr()) {
-        for(int i=0; i<n ;i++) {
-            textures[i] = thrd->shareGroup->genName(TEXTURE);
-        }
-    }
-}
-
-GL_API void GL_APIENTRY  glGetBooleanv( GLenum pname, GLboolean *params) {
-    GET_CTX()
-    ctx->dispatcher().glGetBooleanv(pname,params);
-}
-
-GL_API void GL_APIENTRY  glGetBufferParameteriv( GLenum target, GLenum pname, GLint *params) {
-    GET_CTX()
-    SET_ERROR_IF(!(GLESvalidate::bufferTarget(target) && GLESvalidate::bufferParam(pname)),GL_INVALID_ENUM);
-    SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
-    bool ret = true;
-    switch(pname) {
-    case GL_BUFFER_SIZE:
-        ctx->getBufferSize(target,params);
-        break;
-    case GL_BUFFER_USAGE:
-        ctx->getBufferUsage(target,params);
-        break;
-    }
-
-}
-
-GL_API void GL_APIENTRY  glGetClipPlanef( GLenum pname, GLfloat eqn[4]) {
-    GET_CTX()
-    GLdouble tmpEqn[4];
-
-    ctx->dispatcher().glGetClipPlane(pname,tmpEqn);
-    for(int i =0 ;i < 4; i++){
-        eqn[i] = static_cast<GLfloat>(tmpEqn[i]);
-    }
-}
-
-GL_API void GL_APIENTRY  glGetClipPlanex( GLenum pname, GLfixed eqn[4]) {
-    GET_CTX()
-    GLdouble tmpEqn[4];
-
-    ctx->dispatcher().glGetClipPlane(pname,tmpEqn);
-    for(int i =0 ;i < 4; i++){
-        eqn[i] = F2X(tmpEqn[i]);
-    }
-}
-
-GL_API void GL_APIENTRY  glGetFixedv( GLenum pname, GLfixed *params) {
-    GET_CTX()
-    size_t nParams = glParamSize(pname);
-    GLfloat fParams[16];
-    ctx->dispatcher().glGetFloatv(pname,fParams);
-    for(size_t i =0 ; i < nParams;i++) {
-        params[i] = F2X(fParams[i]);
-    }
-}
-
-GL_API void GL_APIENTRY  glGetFloatv( GLenum pname, GLfloat *params) {
-    GET_CTX()
-    ctx->dispatcher().glGetFloatv(pname,params);
-}
-
-GL_API void GL_APIENTRY  glGetIntegerv( GLenum pname, GLint *params) {
-    GET_CTX()
-    ctx->dispatcher().glGetIntegerv(pname,params);
-}
-
-GL_API void GL_APIENTRY  glGetLightfv( GLenum light, GLenum pname, GLfloat *params) {
-    GET_CTX()
-    ctx->dispatcher().glGetLightfv(light,pname,params);
-}
-
-GL_API void GL_APIENTRY  glGetLightxv( GLenum light, GLenum pname, GLfixed *params) {
-    GET_CTX()
-    GLfloat tmpParams[4];
-
-    ctx->dispatcher().glGetLightfv(light,pname,tmpParams);
-    switch (pname){
-        case GL_AMBIENT:
-        case GL_DIFFUSE:
-        case GL_SPECULAR:
-        case GL_POSITION:
-            params[3] = F2X(tmpParams[3]);
-        case GL_SPOT_DIRECTION:
-            params[2] = F2X(tmpParams[2]);
-            params[1] = F2X(tmpParams[1]);
-            break;
-        default:{
-            ctx->setGLerror(GL_INVALID_ENUM);
-            return;
-        }
-
-    }
-    params[0] = F2X(tmpParams[0]);
-}
-
-GL_API void GL_APIENTRY  glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params) {
-    GET_CTX()
-    ctx->dispatcher().glGetMaterialfv(face,pname,params);
-}
-
-GL_API void GL_APIENTRY  glGetMaterialxv( GLenum face, GLenum pname, GLfixed *params) {
-    GET_CTX()
-    GLfloat tmpParams[4];
-    ctx->dispatcher().glGetMaterialfv(face,pname,tmpParams);
-    switch(pname){
-    case GL_AMBIENT:
-    case GL_DIFFUSE:
-    case GL_SPECULAR:
-    case GL_EMISSION:
-    case GL_AMBIENT_AND_DIFFUSE:
-        params[3] = tmpParams[3];
-        params[2] = tmpParams[2];
-        params[1] = tmpParams[1];
-    case GL_SHININESS:
-        params[0] = tmpParams[0];
-    default:{
-            ctx->setGLerror(GL_INVALID_ENUM);
-            return;
-        }
-    }
-}
-
-GL_API void GL_APIENTRY  glGetPointerv( GLenum pname, void **params) {
-    GET_CTX()
-    const GLESpointer* p = ctx->getPointer(pname);
-    if(p) {
-        *params = const_cast<void *>( p->getArrayData());
-    } else {
-        ctx->setGLerror(GL_INVALID_ENUM);
-    }
-
-}
-
-GL_API void GL_APIENTRY  glGetTexEnvfv( GLenum env, GLenum pname, GLfloat *params) {
-    GET_CTX()
-    ctx->dispatcher().glGetTexEnvfv(env,pname,params);
-}
-
-GL_API void GL_APIENTRY  glGetTexEnviv( GLenum env, GLenum pname, GLint *params) {
-    GET_CTX()
-    ctx->dispatcher().glGetTexEnviv(env,pname,params);
-}
-
-GL_API void GL_APIENTRY  glGetTexEnvxv( GLenum env, GLenum pname, GLfixed *params) {
-    GET_CTX()
-    GLfloat tmpParams[4];
-
-    ctx->dispatcher().glGetTexEnvfv(env,pname,tmpParams);
-    if(pname == GL_TEXTURE_ENV_MODE) {
-        params[0] = static_cast<GLfixed>(tmpParams[0]);
-    } else {
-        for(int i=0 ; i < 4 ; i++)
-            params[i] = F2X(tmpParams[i]);
-    }
-}
-
-GL_API void GL_APIENTRY  glGetTexParameterfv( GLenum target, GLenum pname, GLfloat *params) {
-    GET_CTX()
-    ctx->dispatcher().glGetTexParameterfv(target,pname,params);
-}
-
-GL_API void GL_APIENTRY  glGetTexParameteriv( GLenum target, GLenum pname, GLint *params) {
-    GET_CTX()
-    ctx->dispatcher().glGetTexParameteriv(target,pname,params);
-}
-
-GL_API void GL_APIENTRY  glGetTexParameterxv( GLenum target, GLenum pname, GLfixed *params) {
-    GET_CTX()
-    GLfloat tmpParam;
-    ctx->dispatcher().glGetTexParameterfv(target,pname,&tmpParam);
-    params[0] = static_cast<GLfixed>(tmpParam);
-}
-
-GL_API void GL_APIENTRY  glHint( GLenum target, GLenum mode) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::hintTargetMode(target,mode),GL_INVALID_ENUM);
-    ctx->dispatcher().glHint(target,mode);
-}
-
-GL_API void GL_APIENTRY  glLightModelf( GLenum pname, GLfloat param) {
-    GET_CTX()
-    ctx->dispatcher().glLightModelf(pname,param);
-}
-
-GL_API void GL_APIENTRY  glLightModelfv( GLenum pname, const GLfloat *params) {
-    GET_CTX()
-    ctx->dispatcher().glLightModelfv(pname,params);
-}
-
-GL_API void GL_APIENTRY  glLightModelx( GLenum pname, GLfixed param) {
-    GET_CTX()
-    GLfloat tmpParam = static_cast<GLfloat>(param);
-    ctx->dispatcher().glLightModelf(pname,tmpParam);
-}
-
-GL_API void GL_APIENTRY  glLightModelxv( GLenum pname, const GLfixed *params) {
-    GET_CTX()
-    GLfloat tmpParams[4];
-    if(pname == GL_LIGHT_MODEL_TWO_SIDE) {
-        tmpParams[0] = X2F(params[0]);
-    } else if (pname == GL_LIGHT_MODEL_AMBIENT) {
-        for(int i=0;i<4;i++) {
-            tmpParams[i] = X2F(params[i]);
-        }
-    }
-
-    ctx->dispatcher().glLightModelfv(pname,tmpParams);
-}
-
-GL_API void GL_APIENTRY  glLightf( GLenum light, GLenum pname, GLfloat param) {
-    GET_CTX()
-    ctx->dispatcher().glLightf(light,pname,param);
-}
-
-GL_API void GL_APIENTRY  glLightfv( GLenum light, GLenum pname, const GLfloat *params) {
-    GET_CTX()
-    ctx->dispatcher().glLightfv(light,pname,params);
-}
-
-GL_API void GL_APIENTRY  glLightx( GLenum light, GLenum pname, GLfixed param) {
-    GET_CTX()
-    ctx->dispatcher().glLightf(light,pname,X2F(param));
-}
-
-GL_API void GL_APIENTRY  glLightxv( GLenum light, GLenum pname, const GLfixed *params) {
-    GET_CTX()
-    GLfloat tmpParams[4];
-
-    switch (pname) {
-        case GL_AMBIENT:
-        case GL_DIFFUSE:
-        case GL_SPECULAR:
-        case GL_POSITION:
-            tmpParams[3] = X2F(params[3]);
-        case GL_SPOT_DIRECTION:
-            tmpParams[2] = X2F(params[2]);
-            tmpParams[1] = X2F(params[1]);
-            break;
-        default: {
-                ctx->setGLerror(GL_INVALID_ENUM);
-                return;
-            }
-    }
-    tmpParams[0] = X2F(params[0]);
-    ctx->dispatcher().glLightfv(light,pname,tmpParams);
-}
-
-GL_API void GL_APIENTRY  glLineWidth( GLfloat width) {
-    GET_CTX()
-    ctx->dispatcher().glLineWidth(width);
-}
-
-GL_API void GL_APIENTRY  glLineWidthx( GLfixed width) {
-    GET_CTX()
-    ctx->dispatcher().glLineWidth(X2F(width));
-}
-
-GL_API void GL_APIENTRY  glLoadIdentity( void) {
-    GET_CTX()
-    ctx->dispatcher().glLoadIdentity();
-}
-
-GL_API void GL_APIENTRY  glLoadMatrixf( const GLfloat *m) {
-    GET_CTX()
-    ctx->dispatcher().glLoadMatrixf(m);
-}
-
-GL_API void GL_APIENTRY  glLoadMatrixx( const GLfixed *m) {
-    GET_CTX()
-    GLfloat mat[16];
-    for(int i=0; i< 16 ; i++) {
-        mat[i] = X2F(m[i]);
-    }
-    ctx->dispatcher().glLoadMatrixf(mat);
-}
-
-GL_API void GL_APIENTRY  glLogicOp( GLenum opcode) {
-    GET_CTX()
-    ctx->dispatcher().glLogicOp(opcode);
-}
-
-GL_API void GL_APIENTRY  glMaterialf( GLenum face, GLenum pname, GLfloat param) {
-    GET_CTX()
-    ctx->dispatcher().glMaterialf(face,pname,param);
-}
-
-GL_API void GL_APIENTRY  glMaterialfv( GLenum face, GLenum pname, const GLfloat *params) {
-    GET_CTX()
-    ctx->dispatcher().glMaterialfv(face,pname,params);
-}
-
-GL_API void GL_APIENTRY  glMaterialx( GLenum face, GLenum pname, GLfixed param) {
-    GET_CTX()
-    ctx->dispatcher().glMaterialf(face,pname,X2F(param));
-}
-
-GL_API void GL_APIENTRY  glMaterialxv( GLenum face, GLenum pname, const GLfixed *params) {
-    GET_CTX()
-    GLfloat tmpParams[4];
-
-    for(int i=0; i< 4; i++) {
-        tmpParams[i] = X2F(params[i]);
-    }
-    ctx->dispatcher().glMaterialfv(face,pname,tmpParams);
-}
-
-GL_API void GL_APIENTRY  glMatrixMode( GLenum mode) {
-    GET_CTX()
-    ctx->dispatcher().glMatrixMode(mode);
-}
-
-GL_API void GL_APIENTRY  glMultMatrixf( const GLfloat *m) {
-    GET_CTX()
-    ctx->dispatcher().glMultMatrixf(m);
-}
-
-GL_API void GL_APIENTRY  glMultMatrixx( const GLfixed *m) {
-    GET_CTX()
-    GLfloat mat[16];
-    for(int i=0; i< 16 ; i++) {
-        mat[i] = X2F(m[i]);
-    }
-    ctx->dispatcher().glMultMatrixf(mat);
-}
-
-GL_API void GL_APIENTRY  glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::textureEnum(target,ctx->getMaxTexUnits()),GL_INVALID_ENUM);
-    ctx->dispatcher().glMultiTexCoord4f(target,s,t,r,q);
-}
-
-GL_API void GL_APIENTRY  glMultiTexCoord4x( GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::textureEnum(target,ctx->getMaxTexUnits()),GL_INVALID_ENUM);
-    ctx->dispatcher().glMultiTexCoord4f(target,X2F(s),X2F(t),X2F(r),X2F(q));
-}
-
-GL_API void GL_APIENTRY  glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz) {
-    GET_CTX()
-    ctx->dispatcher().glNormal3f(nx,ny,nz);
-}
-
-GL_API void GL_APIENTRY  glNormal3x( GLfixed nx, GLfixed ny, GLfixed nz) {
-    GET_CTX()
-    ctx->dispatcher().glNormal3f(X2F(nx),X2F(ny),X2F(nz));
-}
-
-GL_API void GL_APIENTRY  glNormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer) {
-    GET_CTX()
-    SET_ERROR_IF(stride < 0,GL_INVALID_VALUE);
-    const GLvoid* data = ctx->setPointer(GL_NORMAL_ARRAY,3,type,stride,pointer);//3 normal verctor
-    if(type != GL_FIXED) ctx->dispatcher().glNormalPointer(type,stride,data);
-}
-
-GL_API void GL_APIENTRY  glOrthof( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
-    GET_CTX()
-    ctx->dispatcher().glOrtho(left,right,bottom,top,zNear,zFar);
-}
-
-GL_API void GL_APIENTRY  glOrthox( GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
-    GET_CTX()
-    ctx->dispatcher().glOrtho(X2F(left),X2F(right),X2F(bottom),X2F(top),X2F(zNear),X2F(zFar));
-}
-
-GL_API void GL_APIENTRY  glPixelStorei( GLenum pname, GLint param) {
-    GET_CTX()
-    ctx->dispatcher().glPixelStorei(pname,param);
-}
-
-GL_API void GL_APIENTRY  glPointParameterf( GLenum pname, GLfloat param) {
-    GET_CTX()
-    ctx->dispatcher().glPointParameterf(pname,param);
-}
-
-GL_API void GL_APIENTRY  glPointParameterfv( GLenum pname, const GLfloat *params) {
-    GET_CTX()
-    ctx->dispatcher().glPointParameterfv(pname,params);
-}
-
-GL_API void GL_APIENTRY  glPointParameterx( GLenum pname, GLfixed param)
-{
-    GET_CTX()
-    ctx->dispatcher().glPointParameterf(pname,X2F(param));
-}
-
-GL_API void GL_APIENTRY  glPointParameterxv( GLenum pname, const GLfixed *params) {
-    GET_CTX()
-    GLfloat tmpParams[3];
-    int i = 0;
-
-    do {
-        tmpParams[i] = X2F(params[i]);
-        i++;
-    }while(pname != GL_POINT_DISTANCE_ATTENUATION);
-    ctx->dispatcher().glPointParameterfv(pname,tmpParams);
-}
-
-GL_API void GL_APIENTRY  glPointSize( GLfloat size) {
-    GET_CTX()
-    ctx->dispatcher().glPointSize(size);
-}
-
-GL_API void GL_APIENTRY  glPointSizePointerOES( GLenum type, GLsizei stride, const GLvoid *pointer) {
-    GET_CTX()
-    SET_ERROR_IF(stride < 0,GL_INVALID_VALUE);
-    ctx->setPointer(GL_POINT_SIZE_ARRAY_OES,1,type,stride,pointer);
-}
-
-GL_API void GL_APIENTRY  glPointSizex( GLfixed size) {
-    GET_CTX()
-    ctx->dispatcher().glPointSize(X2F(size));
-}
-
-GL_API void GL_APIENTRY  glPolygonOffset( GLfloat factor, GLfloat units) {
-    GET_CTX()
-    ctx->dispatcher().glPolygonOffset(factor,units);
-}
-
-GL_API void GL_APIENTRY  glPolygonOffsetx( GLfixed factor, GLfixed units) {
-    GET_CTX()
-    ctx->dispatcher().glPolygonOffset(X2F(factor),X2F(units));
-}
-
-GL_API void GL_APIENTRY  glPopMatrix(void) {
-    GET_CTX()
-    ctx->dispatcher().glPopMatrix();
-}
-
-GL_API void GL_APIENTRY  glPushMatrix(void) {
-    GET_CTX()
-    ctx->dispatcher().glPushMatrix();
-}
-
-GL_API void GL_APIENTRY  glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {
-    GET_CTX()
-    SET_ERROR_IF(!(GLESvalidate::pixelFrmt(format) && GLESvalidate::pixelType(type)),GL_INVALID_ENUM);
-    SET_ERROR_IF(!(GLESvalidate::pixelOp(format,type)),GL_INVALID_OPERATION);
-
-    ctx->dispatcher().glReadPixels(x,y,width,height,format,type,pixels);
-}
-
-GL_API void GL_APIENTRY  glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z) {
-    GET_CTX()
-    ctx->dispatcher().glRotatef(angle,x,y,z);
-}
-
-GL_API void GL_APIENTRY  glRotatex( GLfixed angle, GLfixed x, GLfixed y, GLfixed z) {
-    GET_CTX()
-    ctx->dispatcher().glRotatef(angle,X2F(x),X2F(y),X2F(z));
-}
-
-GL_API void GL_APIENTRY  glSampleCoverage( GLclampf value, GLboolean invert) {
-    GET_CTX()
-    ctx->dispatcher().glSampleCoverage(value,invert);
-}
-
-GL_API void GL_APIENTRY  glSampleCoveragex( GLclampx value, GLboolean invert) {
-    GET_CTX()
-    ctx->dispatcher().glSampleCoverage(X2F(value),invert);
-}
-
-GL_API void GL_APIENTRY  glScalef( GLfloat x, GLfloat y, GLfloat z) {
-    GET_CTX()
-    ctx->dispatcher().glScalef(x,y,z);
-}
-
-GL_API void GL_APIENTRY  glScalex( GLfixed x, GLfixed y, GLfixed z) {
-    GET_CTX()
-    ctx->dispatcher().glScalef(X2F(x),X2F(y),X2F(z));
-}
-
-GL_API void GL_APIENTRY  glScissor( GLint x, GLint y, GLsizei width, GLsizei height) {
-    GET_CTX()
-    ctx->dispatcher().glScissor(x,y,width,height);
-}
-
-GL_API void GL_APIENTRY  glShadeModel( GLenum mode) {
-    GET_CTX()
-    ctx->dispatcher().glShadeModel(mode);
-}
-
-GL_API void GL_APIENTRY  glStencilFunc( GLenum func, GLint ref, GLuint mask) {
-    GET_CTX()
-    ctx->dispatcher().glStencilFunc(func,ref,mask);
-}
-
-GL_API void GL_APIENTRY  glStencilMask( GLuint mask) {
-    GET_CTX()
-    ctx->dispatcher().glStencilMask(mask);
-}
-
-GL_API void GL_APIENTRY  glStencilOp( GLenum fail, GLenum zfail, GLenum zpass) {
-    GET_CTX()
-    ctx->dispatcher().glStencilOp(fail,zfail,zpass);
-}
-
-GL_API void GL_APIENTRY  glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::texCoordPointerParams(size,stride),GL_INVALID_VALUE);
-
-    const GLvoid* data = ctx->setPointer(GL_TEXTURE_COORD_ARRAY,size,type,stride,pointer);
-    if(type != GL_FIXED) ctx->dispatcher().glTexCoordPointer(size,type,stride,data);
-}
-
-GL_API void GL_APIENTRY  glTexEnvf( GLenum target, GLenum pname, GLfloat param) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::texEnv(target,pname),GL_INVALID_ENUM);
-    ctx->dispatcher().glTexEnvf(target,pname,param);
-}
-
-GL_API void GL_APIENTRY  glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::texEnv(target,pname),GL_INVALID_ENUM);
-    ctx->dispatcher().glTexEnvfv(target,pname,params);
-}
-
-GL_API void GL_APIENTRY  glTexEnvi( GLenum target, GLenum pname, GLint param) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::texEnv(target,pname),GL_INVALID_ENUM);
-    ctx->dispatcher().glTexEnvi(target,pname,param);
-}
-
-GL_API void GL_APIENTRY  glTexEnviv( GLenum target, GLenum pname, const GLint *params) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::texEnv(target,pname),GL_INVALID_ENUM);
-    ctx->dispatcher().glTexEnviv(target,pname,params);
-}
-
-GL_API void GL_APIENTRY  glTexEnvx( GLenum target, GLenum pname, GLfixed param) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::texEnv(target,pname),GL_INVALID_ENUM);
-    GLfloat tmpParam = static_cast<GLfloat>(param);
-    ctx->dispatcher().glTexEnvf(target,pname,tmpParam);
-}
-
-GL_API void GL_APIENTRY  glTexEnvxv( GLenum target, GLenum pname, const GLfixed *params) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::texEnv(target,pname),GL_INVALID_ENUM);
-
-    GLfloat tmpParams[4];
-    if(pname == GL_TEXTURE_ENV_COLOR) {
-        for(int i =0;i<4;i++) {
-            tmpParams[i] = X2F(params[i]);
-        }
-    } else {
-        tmpParams[0] = static_cast<GLfloat>(params[0]);
-    }
-    ctx->dispatcher().glTexEnvfv(target,pname,tmpParams);
-}
-
-static TextureData* getTextureData(){
-    GET_CTX_RET(NULL);
-    unsigned int tex = ctx->getBindedTexture();
-    TextureData *texData = NULL;
-    ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex);
-    if(!objData.Ptr()){
-        texData = new TextureData();
-        thrd->shareGroup->setObjectData(TEXTURE, tex, ObjectDataPtr(texData));
-    } else {
-        texData = (TextureData*)objData.Ptr();
-    }
-    return texData;
-}
-
-GL_API void GL_APIENTRY  glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {
-    GET_CTX()
-
-    SET_ERROR_IF(!(GLESvalidate::textureTarget(target) &&
-                   GLESvalidate::pixelFrmt(internalformat) &&
-                   GLESvalidate::pixelFrmt(format)&&
-                   GLESvalidate::pixelType(type)),GL_INVALID_ENUM);
-
-    //SET_ERROR_IF(level < 0 || border !=0 || level > log2(ctx->getMaxTexSize()) || !GLESvalidate::texImgDim(width,height,ctx->getMaxTexSize()),GL_INVALID_VALUE);
-    SET_ERROR_IF(!(GLESvalidate::pixelOp(format,type) && internalformat == ((GLint)format)),GL_INVALID_OPERATION);
-
-    if (thrd->shareGroup.Ptr()){
-        unsigned int tex = ctx->getBindedTexture();
-        TextureData *texData = getTextureData();
-        if(texData) {
-            texData->width = width;
-            texData->height = height;
-            texData->border = border;
-            texData->internalFormat = internalformat;
-        }
-    }
-    ctx->dispatcher().glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);
-}
-
-GL_API void GL_APIENTRY  glTexParameterf( GLenum target, GLenum pname, GLfloat param) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::texParams(target,pname),GL_INVALID_ENUM);
-    ctx->dispatcher().glTexParameterf(target,pname,param);
-}
-
-GL_API void GL_APIENTRY  glTexParameterfv( GLenum target, GLenum pname, const GLfloat *params) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::texParams(target,pname),GL_INVALID_ENUM);
-    ctx->dispatcher().glTexParameterfv(target,pname,params);
-}
-
-GL_API void GL_APIENTRY  glTexParameteri( GLenum target, GLenum pname, GLint param) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::texParams(target,pname),GL_INVALID_ENUM);
-    ctx->dispatcher().glTexParameteri(target,pname,param);
-}
-
-GL_API void GL_APIENTRY  glTexParameteriv( GLenum target, GLenum pname, const GLint *params) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::texParams(target,pname),GL_INVALID_ENUM);
-    ctx->dispatcher().glTexParameteriv(target,pname,params);
-}
-
-GL_API void GL_APIENTRY  glTexParameterx( GLenum target, GLenum pname, GLfixed param) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::texParams(target,pname),GL_INVALID_ENUM);
-    ctx->dispatcher().glTexParameterf(target,pname,static_cast<GLfloat>(param));
-}
-
-GL_API void GL_APIENTRY  glTexParameterxv( GLenum target, GLenum pname, const GLfixed *params) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::texParams(target,pname),GL_INVALID_ENUM);
-    GLfloat param = static_cast<GLfloat>(params[0]);
-    ctx->dispatcher().glTexParameterfv(target,pname,&param);
-}
-
-GL_API void GL_APIENTRY  glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) {
-    GET_CTX()
-    SET_ERROR_IF(!(GLESvalidate::textureTarget(target) &&
-                   GLESvalidate::pixelFrmt(format)&&
-                   GLESvalidate::pixelType(type)),GL_INVALID_ENUM);
-    SET_ERROR_IF(!GLESvalidate::pixelOp(format,type),GL_INVALID_OPERATION);
-
-    ctx->dispatcher().glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels);
-}
-
-GL_API void GL_APIENTRY  glTranslatef( GLfloat x, GLfloat y, GLfloat z) {
-    GET_CTX()
-    ctx->dispatcher().glTranslatef(x,y,z);
-}
-
-GL_API void GL_APIENTRY  glTranslatex( GLfixed x, GLfixed y, GLfixed z) {
-    GET_CTX()
-    ctx->dispatcher().glTranslatef(x,y,z);
-}
-
-GL_API void GL_APIENTRY  glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) {
-    GET_CTX()
-    SET_ERROR_IF(!GLESvalidate::vertexPointerParams(size,stride),GL_INVALID_VALUE);
-
-    const GLvoid* data = ctx->setPointer(GL_VERTEX_ARRAY,size,type,stride,pointer);
-    if(type != GL_FIXED) ctx->dispatcher().glVertexPointer(size,type,stride,data);
-}
-
-GL_API void GL_APIENTRY  glViewport( GLint x, GLint y, GLsizei width, GLsizei height) {
-    GET_CTX()
-    ctx->dispatcher().glViewport(x,y,width,height);
-}
-
-void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
-{
-    GET_CTX();
-    SET_ERROR_IF(!GLESvalidate::textureTarget(target),GL_INVALID_ENUM);
-    EglImage *img = s_eglIface->eglAttachEGLImage((unsigned int)image);
-    if (img) {
-        // Create the texture object in the underlying EGL implementation,
-        // flag to the OpenGL layer to skip the image creation and map the
-        // current binded texture object to the existing global object.
-        if (thrd->shareGroup) {
-            unsigned int tex = ctx->getBindedTexture();
-            unsigned int oldGlobal = thrd->shareGroup->getGlobalName(TEXTURE, tex);
-            // Delete old texture object
-            if (oldGlobal) {
-                ctx->dispatcher().glDeleteTextures(1, &oldGlobal);
-            }
-            // replace mapping and bind the new global object
-            thrd->shareGroup->replaceGlobalName(TEXTURE, tex,img->globalTexName);
-            ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName);
-            TextureData *texData = getTextureData();
-            texData->sourceEGLImage = (unsigned int)image;
-            texData->eglImageDetach = s_eglIface->eglDetachEGLImage;
-        }
-    }
-}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/TextureUtils.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/TextureUtils.cpp
index 28dff1c..b26b504 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/TextureUtils.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/TextureUtils.cpp
@@ -39,11 +39,12 @@
     case GL_PALETTE4_RGBA8_OES:
         indexSizeBits = 4;
         colorSizeBytes = 4;
-            colorFrmt = GL_RGBA;
+        colorFrmt = GL_RGBA;
         break;
 
     case GL_PALETTE4_RGBA4_OES:
-            colorFrmt = GL_RGBA;
+        colorFrmt = GL_RGBA;
+        /* fall-through */
     case GL_PALETTE4_R5_G6_B5_OES:
     case GL_PALETTE4_RGB5_A1_OES:
         indexSizeBits = 4;
@@ -58,9 +59,12 @@
     case GL_PALETTE8_RGBA8_OES:
         indexSizeBits = 8;
         colorSizeBytes = 4;
-            colorFrmt = GL_RGBA;
+        colorFrmt = GL_RGBA;
         break;
 
+    case GL_PALETTE8_RGBA4_OES:
+        colorFrmt = GL_RGBA;
+        /* fall-through */
     case GL_PALETTE8_R5_G6_B5_OES:
     case GL_PALETTE8_RGB5_A1_OES:
         indexSizeBits = 8;
@@ -104,9 +108,13 @@
     unsigned int indexSizeBits;  //the size of the color index in the pallete
     unsigned int colorSizeBytes; //the size of each color cell in the pallete
 
-    const unsigned char* palette = static_cast<const unsigned char *>(data);
-
     getPaletteInfo(internalformat,indexSizeBits,colorSizeBytes,formatOut);
+    if(!data)
+    {
+        return NULL;
+    }
+
+    const unsigned char* palette = static_cast<const unsigned char *>(data);
 
     //the pallete positioned in the begininng of the data
     // so we jump over it to get to the colos indices in the palette
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk b/tools/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk
new file mode 100644
index 0000000..723bd38
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk
@@ -0,0 +1,37 @@
+LOCAL_PATH := $(call my-dir)
+
+### GLES_CM host implementation (On top of OpenGL) ########################
+include $(CLEAR_VARS)
+
+translator_path := $(LOCAL_PATH)/..
+
+LOCAL_SRC_FILES :=                    \
+     GLESv2Imp.cpp                    \
+     GLESv2Context.cpp                \
+     GLESv2Validate.cpp               \
+     ShaderParser.cpp                 \
+
+LOCAL_C_INCLUDES += \
+                 $(translator_path)/include \
+
+LOCAL_STATIC_LIBRARIES := \
+    libGLcommon           \
+    libOpenglOsUtils      \
+    libutils              \
+    libcutils
+
+ifeq ($(HOST_OS),linux)
+    LOCAL_LDLIBS := -lGL -ldl
+endif
+
+ifeq ($(HOST_OS),windows)
+    LOCAL_LDLIBS := -lopengl32 -lgdi32
+endif
+
+LOCAL_CFLAGS := -g -O0
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := libGLES_V2_translator
+
+
+include $(BUILD_HOST_SHARED_LIBRARY)
+
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
new file mode 100644
index 0000000..ffd791a
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
@@ -0,0 +1,64 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include "GLESv2Context.h"
+
+
+
+void GLESv2Context::init() {
+    android::Mutex::Autolock mutex(s_lock);
+    if(!m_initialized) {
+        s_glDispatch.dispatchFuncs(GLES_2_0);
+        initCapsLocked(s_glDispatch.glGetString(GL_EXTENSIONS));
+        initExtensionString();
+
+        for(int i=0; i < s_glSupport.maxVertexAttribs;i++){
+            m_map[i] = new GLESpointer();
+        }
+    }
+    m_initialized = true;
+}
+
+GLESv2Context::GLESv2Context():GLEScontext(){};
+
+void GLESv2Context::convertArrs(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct) {
+    ArraysMap::iterator it;
+    unsigned int index = 0;
+
+    //going over all clients arrays Pointers
+    for ( it=m_map.begin() ; it != m_map.end(); it++ ) {
+        GLenum array_id   = (*it).first;
+        GLESpointer* p = (*it).second;
+
+        chooseConvertMethod(fArrs,first,count,type,indices,direct,p,array_id,index);
+    }
+}
+
+//sending data to server side
+void GLESv2Context::sendArr(GLvoid* arr,GLenum arrayType,GLint size,GLsizei stride,int index) {
+     s_glDispatch.glVertexAttribPointer(arrayType,size,GL_FLOAT,GL_FALSE,stride,arr);
+}
+
+void GLESv2Context::initExtensionString() {
+    *s_glExtensions = "GL_OES_EGL_image GL_OES_depth24 GL_OES_depth32 GL_OES_element_index_uint "
+                      "GL_OES_standard_derivatives GL_OES_texture_float GL_OES_texture_float_linear ";
+    if (s_glSupport.GL_ARB_HALF_FLOAT_PIXEL || s_glSupport.GL_NV_HALF_FLOAT)       
+        *s_glExtensions+="GL_OES_texture_half_float GL_OES_texture_half_float_linear ";
+    if (s_glSupport.GL_NV_PACKED_DEPTH_STENCIL)
+        *s_glExtensions+="GL_OES_packed_depth_stencil ";
+    if (s_glSupport.GL_ARB_HALF_FLOAT_VERTEX)
+        *s_glExtensions+="GL_OES_vertex_half_float ";
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
new file mode 100644
index 0000000..5bee079
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
@@ -0,0 +1,37 @@
+#ifndef GLES_V2_CONTEXT_H
+#define GLES_V2_CONTEXT_H
+
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <GLcommon/GLDispatch.h>
+#include <GLcommon/GLEScontext.h>
+#include <GLcommon/objectNameManager.h>
+#include <utils/threads.h>
+
+
+
+class GLESv2Context : public GLEScontext{
+public:
+    void init();
+    GLESv2Context();
+    void convertArrs(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct);
+private:
+    void sendArr(GLvoid* arr,GLenum arrayType,GLint size,GLsizei stride,int pointsIndex = -1);
+    void initExtensionString();
+};
+
+#endif
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
new file mode 100644
index 0000000..d708a25
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -0,0 +1,1294 @@
+/*
+* Copyright(C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0(the "License"){    GET_CTX();}
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifdef _WIN32
+#undef  GL_APICALL
+#define GL_APICALL __declspec(dllexport)
+#endif
+
+#define GL_GLEXT_PROTOTYPES
+#include <stdio.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <GLcommon/TranslatorIfaces.h>
+#include <GLcommon/ThreadInfo.h>
+#include "GLESv2Context.h"
+#include "GLESv2Validate.h"
+#include "ShaderParser.h"
+
+extern "C" {
+
+//decleration
+static void initContext(GLEScontext* ctx);
+static void deleteGLESContext(GLEScontext* ctx);
+static void setShareGroup(GLEScontext* ctx,ShareGroupPtr grp);
+static GLEScontext* createGLESContext();
+static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName);
+
+}
+
+/************************************** GLES EXTENSIONS *********************************************************/
+//extentions descriptor
+typedef std::map<std::string, __translatorMustCastToProperFunctionPointerType> ProcTableMap;
+ProcTableMap *s_glesExtensions = NULL;
+/****************************************************************************************************************/
+
+static EGLiface*  s_eglIface = NULL;
+static GLESiface  s_glesIface = {
+    createGLESContext:createGLESContext,
+    initContext      :initContext,
+    deleteGLESContext:deleteGLESContext,
+    flush            :(FUNCPTR)glFlush,
+    finish           :(FUNCPTR)glFinish,
+    setShareGroup    :setShareGroup,
+    getProcAddress   :getProcAddress
+};
+
+#include <GLcommon/GLESmacros.h>
+
+extern "C" {
+
+static void initContext(GLEScontext* ctx) {
+    ctx->init();
+}
+static GLEScontext* createGLESContext() {
+    return new GLESv2Context();
+}
+
+static void deleteGLESContext(GLEScontext* ctx) {
+    delete ctx;
+}
+
+static void setShareGroup(GLEScontext* ctx,ShareGroupPtr grp) {
+    if(ctx) {
+        ctx->setShareGroup(grp);
+    }
+}
+
+static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName) {
+    GET_CTX_RET(NULL)
+    ctx->getGlobalLock();
+    static bool proc_table_initialized = false;
+    if (!proc_table_initialized) {
+        proc_table_initialized = true;
+        if (!s_glesExtensions)
+            s_glesExtensions = new ProcTableMap();
+        else
+            s_glesExtensions->clear();
+        (*s_glesExtensions)["glEGLImageTargetTexture2DOES"] = (__translatorMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES;
+        (*s_glesExtensions)["glEGLImageTargetRenderbufferStorageOES"]=(__translatorMustCastToProperFunctionPointerType)glEGLImageTargetRenderbufferStorageOES;
+    }
+    __translatorMustCastToProperFunctionPointerType ret=NULL;
+    ProcTableMap::iterator val = s_glesExtensions->find(procName);
+    if (val!=s_glesExtensions->end())
+        ret = val->second;
+    ctx->releaseGlobalLock();
+
+    return ret;
+}
+
+GL_APICALL GLESiface* __translator_getIfaces(EGLiface* eglIface){
+    s_eglIface = eglIface;
+    return & s_glesIface;
+}
+
+}
+
+GL_APICALL void  GL_APIENTRY glActiveTexture(GLenum texture){
+    GET_CTX_V2();
+    SET_ERROR_IF (!GLESv2Validate::textureEnum(texture,ctx->getMaxTexUnits()),GL_INVALID_ENUM);
+    ctx->setActiveTexture(texture);
+    ctx->dispatcher().glActiveTexture(texture);
+}
+
+GL_APICALL void  GL_APIENTRY glAttachShader(GLuint program, GLuint shader){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        const GLuint globalShaderName  = thrd->shareGroup->getGlobalName(SHADER,shader);
+        ctx->dispatcher().glAttachShader(globalProgramName,globalShaderName);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        ctx->dispatcher().glBindAttribLocation(globalProgramName,index,name);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer){
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::bufferTarget(target),GL_INVALID_ENUM);
+    //if buffer wasn't generated before,generate one
+    if(thrd->shareGroup.Ptr() && !thrd->shareGroup->isObject(VERTEXBUFFER,buffer)){
+        thrd->shareGroup->genName(VERTEXBUFFER,buffer);
+        thrd->shareGroup->setObjectData(VERTEXBUFFER,buffer,ObjectDataPtr(new GLESbuffer()));
+    }
+    ctx->bindBuffer(target,buffer);
+    GLESbuffer* vbo = (GLESbuffer*)thrd->shareGroup->getObjectData(VERTEXBUFFER,buffer).Ptr();
+    vbo->wasBinded();
+}
+
+GL_APICALL void  GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer){
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::framebufferTarget(target),GL_INVALID_ENUM);
+
+    GLuint globalFrameBufferName = framebuffer;
+    if(framebuffer && thrd->shareGroup.Ptr()){
+        globalFrameBufferName = thrd->shareGroup->getGlobalName(FRAMEBUFFER,framebuffer);
+        //if framebuffer wasn't generated before,generate one
+        if(!globalFrameBufferName){
+            thrd->shareGroup->genName(FRAMEBUFFER,framebuffer);
+            globalFrameBufferName = thrd->shareGroup->getGlobalName(FRAMEBUFFER,framebuffer);
+        }
+    }
+    ctx->dispatcher().glBindFramebuffer(target,globalFrameBufferName);
+}
+
+GL_APICALL void  GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer){
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::renderbufferTarget(target),GL_INVALID_ENUM);
+
+    GLuint globalRenderBufferName = renderbuffer;
+    if(renderbuffer && thrd->shareGroup.Ptr()){
+        globalRenderBufferName = thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffer);
+        //if renderbuffer wasn't generated before,generate one
+        if(!globalRenderBufferName){
+            thrd->shareGroup->genName(RENDERBUFFER,renderbuffer);
+            globalRenderBufferName = thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffer);
+        }
+    }
+    ctx->dispatcher().glBindRenderbuffer(target,globalRenderBufferName);
+}
+
+GL_APICALL void  GL_APIENTRY glBindTexture(GLenum target, GLuint texture){
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::textureTarget(target),GL_INVALID_ENUM)
+
+    GLuint globalTextureName = texture;
+    if(texture && thrd->shareGroup.Ptr()){
+        globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture);
+        //if texture wasn't generated before,generate one
+        if(!globalTextureName){
+            thrd->shareGroup->genName(TEXTURE,texture);
+            globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture);
+        }
+    }
+    ctx->setBindedTexture(globalTextureName);
+    ctx->dispatcher().glBindTexture(target,globalTextureName);
+}
+
+GL_APICALL void  GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha){
+    GET_CTX();
+    ctx->dispatcher().glBlendColor(red,green,blue,alpha);
+}
+
+GL_APICALL void  GL_APIENTRY glBlendEquation( GLenum mode ){
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::blendEquationMode(mode),GL_INVALID_ENUM)
+    ctx->dispatcher().glBlendEquation(mode);
+}
+
+GL_APICALL void  GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::blendEquationMode(modeRGB) && GLESv2Validate::blendEquationMode(modeAlpha)),GL_INVALID_ENUM);
+    ctx->dispatcher().glBlendEquationSeparate(modeRGB,modeAlpha);
+}
+
+GL_APICALL void  GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor){
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::blendSrc(sfactor) || !GLESv2Validate::blendDst(dfactor),GL_INVALID_ENUM)
+    ctx->dispatcher().glBlendFunc(sfactor,dfactor);
+}
+
+GL_APICALL void  GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha){
+    GET_CTX();
+    SET_ERROR_IF(
+!(GLESv2Validate::blendSrc(srcRGB) && GLESv2Validate::blendDst(dstRGB) && GLESv2Validate::blendSrc(srcAlpha) && GLESv2Validate::blendDst(dstAlpha)),GL_INVALID_ENUM);
+    ctx->dispatcher().glBlendFuncSeparate(srcRGB,dstRGB,srcAlpha,dstAlpha);
+}
+
+GL_APICALL void  GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage){
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::bufferTarget(target),GL_INVALID_ENUM);
+    SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
+    ctx->setBufferData(target,size,data,usage);
+}
+
+GL_APICALL void  GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data){
+    GET_CTX();
+    SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
+    SET_ERROR_IF(!GLESv2Validate::bufferTarget(target),GL_INVALID_ENUM);
+    SET_ERROR_IF(!ctx->setBufferSubData(target,offset,size,data),GL_INVALID_VALUE);
+}
+
+
+GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target){
+    GET_CTX_RET(GL_FRAMEBUFFER_COMPLETE);
+    RET_AND_SET_ERROR_IF(!GLESv2Validate::framebufferTarget(target),GL_INVALID_ENUM,GL_FRAMEBUFFER_COMPLETE);
+    return ctx->dispatcher().glCheckFramebufferStatus(target);
+}
+
+GL_APICALL void  GL_APIENTRY glClear(GLbitfield mask){
+    GET_CTX();
+    ctx->dispatcher().glClear(mask);
+}
+GL_APICALL void  GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha){
+    GET_CTX();
+    ctx->dispatcher().glClearColor(red,green,blue,alpha);
+}
+GL_APICALL void  GL_APIENTRY glClearDepthf(GLclampf depth){
+    GET_CTX();
+    ctx->dispatcher().glClearDepth(depth);
+}
+GL_APICALL void  GL_APIENTRY glClearStencil(GLint s){
+    GET_CTX();
+    ctx->dispatcher().glClearStencil(s);
+}
+GL_APICALL void  GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha){
+    GET_CTX();
+    ctx->dispatcher().glColorMask(red,green,blue,alpha);
+}
+
+GL_APICALL void  GL_APIENTRY glCompileShader(GLuint shader){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+       const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+       ctx->dispatcher().glCompileShader(globalShaderName);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data){
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::textureTargetEx(target),GL_INVALID_ENUM);
+    SET_ERROR_IF(border != 0 , GL_INVALID_VALUE);
+    ctx->dispatcher().glCompressedTexImage2D(target,level,internalformat,width,height,border,imageSize,data);
+}
+
+GL_APICALL void  GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data){
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::textureTargetEx(target),GL_INVALID_ENUM);
+    ctx->dispatcher().glCompressedTexSubImage2D(target,level,xoffset,yoffset,width,height,format,imageSize,data);
+}
+
+GL_APICALL void  GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::pixelFrmt(ctx,internalformat) && GLESv2Validate::textureTargetEx(target)),GL_INVALID_ENUM);
+    SET_ERROR_IF(border != 0,GL_INVALID_VALUE);
+    ctx->dispatcher().glCopyTexImage2D(target,level,internalformat,x,y,width,height,border);
+}
+
+GL_APICALL void  GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height){
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::textureTargetEx(target),GL_INVALID_ENUM);
+    ctx->dispatcher().glCopyTexSubImage2D(target,level,xoffset,yoffset,x,y,width,height);
+}
+
+GL_APICALL GLuint GL_APIENTRY glCreateProgram(void){
+    GET_CTX_RET(0);
+    const GLuint globalProgramName = ctx->dispatcher().glCreateProgram();
+    if(thrd->shareGroup.Ptr() && globalProgramName) {
+            const GLuint localProgramName = thrd->shareGroup->genName(SHADER);
+            thrd->shareGroup->replaceGlobalName(SHADER,localProgramName,globalProgramName);
+            return localProgramName;
+    }
+    if(globalProgramName){
+        ctx->dispatcher().glDeleteProgram(globalProgramName);
+    }
+    return 0;
+}
+
+GL_APICALL GLuint GL_APIENTRY glCreateShader(GLenum type){
+    GET_CTX_V2_RET(0);
+    const GLuint globalShaderName = ctx->dispatcher().glCreateShader(type);
+    if(thrd->shareGroup.Ptr() && globalShaderName) {
+            const GLuint localShaderName = thrd->shareGroup->genName(SHADER);
+            ShaderParser* sp = new ShaderParser(type);
+            thrd->shareGroup->replaceGlobalName(SHADER,localShaderName,globalShaderName);
+            thrd->shareGroup->setObjectData(SHADER,localShaderName,ObjectDataPtr(sp));
+            return localShaderName;
+    }
+    if(globalShaderName){
+        ctx->dispatcher().glDeleteShader(globalShaderName);
+    }
+    return 0;
+}
+
+GL_APICALL void  GL_APIENTRY glCullFace(GLenum mode){
+    GET_CTX();
+    ctx->dispatcher().glCullFace(mode);
+}
+
+GL_APICALL void  GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers){
+    GET_CTX();
+    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
+    if(thrd->shareGroup.Ptr()) {
+        for(int i=0; i < n; i++){
+           thrd->shareGroup->deleteName(VERTEXBUFFER,buffers[i]);
+        }
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers){
+    GET_CTX();
+    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
+    if(thrd->shareGroup.Ptr()) {
+        for(int i=0; i < n; i++){
+           const GLuint globalFrameBufferName = thrd->shareGroup->getGlobalName(FRAMEBUFFER,framebuffers[i]);
+           thrd->shareGroup->deleteName(FRAMEBUFFER,framebuffers[i]);
+           ctx->dispatcher().glDeleteFramebuffers(1,&globalFrameBufferName);
+        }
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers){
+    GET_CTX();
+    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
+    if(thrd->shareGroup.Ptr()) {
+        for(int i=0; i < n; i++){
+           const GLuint globalRenderBufferName = thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffers[i]);
+           thrd->shareGroup->deleteName(RENDERBUFFER,renderbuffers[i]);
+           ctx->dispatcher().glDeleteRenderbuffers(1,&globalRenderBufferName);
+        }
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures){
+    GET_CTX();
+    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
+    if(thrd->shareGroup.Ptr()) {
+        for(int i=0; i < n; i++){
+           const GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,textures[i]);
+           thrd->shareGroup->deleteName(TEXTURE,textures[i]);
+           ctx->dispatcher().glDeleteTextures(1,&globalTextureName);
+        }
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glDeleteProgram(GLuint program){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        thrd->shareGroup->deleteName(SHADER,program);
+        ctx->dispatcher().glDeleteProgram(program);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glDeleteShader(GLuint shader){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+        thrd->shareGroup->deleteName(SHADER,shader);
+        ctx->dispatcher().glDeleteShader(shader);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glDepthFunc(GLenum func){
+    GET_CTX();
+    ctx->dispatcher().glDepthFunc(func);
+}
+GL_APICALL void  GL_APIENTRY glDepthMask(GLboolean flag){
+    GET_CTX();
+    ctx->dispatcher().glDepthMask(flag);
+}
+GL_APICALL void  GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar){
+    GET_CTX();
+    ctx->dispatcher().glDepthRange(zNear,zFar);
+}
+
+GL_APICALL void  GL_APIENTRY glDetachShader(GLuint program, GLuint shader){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        const GLuint globalShaderName  = thrd->shareGroup->getGlobalName(SHADER,shader);
+        ctx->dispatcher().glDetachShader(globalProgramName,globalShaderName);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glDisable(GLenum cap){
+    GET_CTX();
+    ctx->dispatcher().glDisable(cap);
+}
+
+GL_APICALL void  GL_APIENTRY glDisableVertexAttribArray(GLuint index){
+    GET_CTX();
+    ctx->enableArr(index,false);
+    ctx->dispatcher().glDisableVertexAttribArray(index);
+}
+
+
+GL_APICALL void  GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count){
+    GET_CTX();
+    SET_ERROR_IF(count < 0,GL_INVALID_VALUE)
+    SET_ERROR_IF(!GLESv2Validate::drawMode(mode),GL_INVALID_ENUM);
+
+    //if no vertex are enabled no need to convert anything
+    if(!ctx->isArrEnabled(0)) return;
+
+    GLESFloatArrays tmpArrs;
+    ctx->convertArrs(tmpArrs,first,count,0,NULL,true);
+    ctx->dispatcher().glDrawArrays(mode,first,count);
+}
+
+GL_APICALL void  GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* elementsIndices){
+    GET_CTX();
+    SET_ERROR_IF(count < 0,GL_INVALID_VALUE)
+    SET_ERROR_IF(!(GLESv2Validate::drawMode(mode) && GLESv2Validate::drawType(type)),GL_INVALID_ENUM);
+
+    const GLvoid* indices = elementsIndices;
+    if(ctx->isBindedBuffer(GL_ELEMENT_ARRAY_BUFFER)) { // if vbo is binded take the indices from the vbo
+        const unsigned char* buf = static_cast<unsigned char *>(ctx->getBindedBuffer(GL_ELEMENT_ARRAY_BUFFER));
+        indices = buf+reinterpret_cast<unsigned int>(elementsIndices);
+    }
+
+    //if no vertex are enabled no need to convert anything
+    if(!ctx->isArrEnabled(0)) return;
+
+    GLESFloatArrays tmpArrs;
+    ctx->convertArrs(tmpArrs,0,count,type,indices,false);
+    ctx->dispatcher().glDrawElements(mode,count,type,indices);
+}
+
+GL_APICALL void  GL_APIENTRY glEnable(GLenum cap){
+    GET_CTX();
+    ctx->dispatcher().glEnable(cap);
+}
+
+GL_APICALL void  GL_APIENTRY glEnableVertexAttribArray(GLuint index){
+    GET_CTX();
+    ctx->enableArr(index,true);
+    ctx->dispatcher().glEnableVertexAttribArray(index);
+}
+
+GL_APICALL void  GL_APIENTRY glFinish(void){
+    GET_CTX();
+    ctx->dispatcher().glFinish();
+}
+GL_APICALL void  GL_APIENTRY glFlush(void){
+    GET_CTX();
+    ctx->dispatcher().glFlush();
+}
+
+
+GL_APICALL void  GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::framebufferTarget(target)              &&
+                   GLESv2Validate::renderbufferTarget(renderbuffertarget) &&
+                   GLESv2Validate::framebufferAttachment(attachment)),GL_INVALID_ENUM);
+
+    if(thrd->shareGroup.Ptr()) {
+            GLuint globalRenderbufferName = thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffer);
+            ctx->dispatcher().glFramebufferRenderbuffer(target,attachment,renderbuffertarget,globalRenderbufferName);
+    }
+
+}
+
+GL_APICALL void  GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::framebufferTarget(target) &&
+                   GLESv2Validate::textureTargetEx(textarget)  &&
+                   GLESv2Validate::framebufferAttachment(attachment)),GL_INVALID_ENUM);
+    SET_ERROR_IF(level != 0, GL_INVALID_VALUE);
+
+    if(thrd->shareGroup.Ptr()) {
+            GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texture);
+            ctx->dispatcher().glFramebufferTexture2D(target,attachment,textarget,globalTextureName,level);
+    }
+}
+
+
+GL_APICALL void  GL_APIENTRY glFrontFace(GLenum mode){
+    GET_CTX();
+    ctx->dispatcher().glFrontFace(mode);
+}
+
+GL_APICALL void  GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers){
+    GET_CTX();
+    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
+    if(thrd->shareGroup.Ptr()) {
+        for(int i=0; i<n ;i++) {
+            buffers[i] = thrd->shareGroup->genName(VERTEXBUFFER);
+            //generating vbo object related to this buffer name
+            thrd->shareGroup->setObjectData(VERTEXBUFFER,buffers[i],ObjectDataPtr(new GLESbuffer()));
+        }
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGenerateMipmap(GLenum target){
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::textureTargetEx(target),GL_INVALID_ENUM);
+    ctx->dispatcher().glGenerateMipmap(target);
+}
+
+GL_APICALL void  GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers){
+    GET_CTX();
+    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
+    if(thrd->shareGroup.Ptr()) {
+        for(int i=0; i<n ;i++) {
+            framebuffers[i] = thrd->shareGroup->genName(FRAMEBUFFER);
+        }
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers){
+    GET_CTX();
+    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
+    if(thrd->shareGroup.Ptr()) {
+        for(int i=0; i<n ;i++) {
+            renderbuffers[i] = thrd->shareGroup->genName(RENDERBUFFER);
+        }
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures){
+    GET_CTX();
+    SET_ERROR_IF(n<0,GL_INVALID_VALUE);
+    if(thrd->shareGroup.Ptr()) {
+        for(int i=0; i<n ;i++) {
+            textures[i] = thrd->shareGroup->genName(TEXTURE);
+        }
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        ctx->dispatcher().glGetActiveAttrib(globalProgramName,index,bufsize,length,size,type,name);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        ctx->dispatcher().glGetActiveUniform(globalProgramName,index,bufsize,length,size,type,name);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        ctx->dispatcher().glGetAttachedShaders(globalProgramName,maxcount,count,shaders);
+        for(int i=0 ; i < *count ;i++){
+           shaders[i] = thrd->shareGroup->getLocalName(SHADER,shaders[i]);
+        }
+    }
+}
+
+GL_APICALL int GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name){
+     GET_CTX_RET(-1);
+     if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        return ctx->dispatcher().glGetAttribLocation(globalProgramName,name);
+     }
+     return -1;
+}
+
+GL_APICALL void  GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params){
+    GET_CTX();
+    ctx->dispatcher().glGetBooleanv(pname,params);
+}
+
+GL_APICALL void  GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::bufferTarget(target) && GLESv2Validate::bufferParam(pname)),GL_INVALID_ENUM);
+    SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
+    bool ret = true;
+    switch(pname) {
+    case GL_BUFFER_SIZE:
+        ctx->getBufferSize(target,params);
+        break;
+    case GL_BUFFER_USAGE:
+        ctx->getBufferUsage(target,params);
+        break;
+    }
+}
+
+
+GL_APICALL GLenum GL_APIENTRY glGetError(void){
+    GET_CTX_RET(GL_NO_ERROR)
+    GLenum err = ctx->getGLerror();
+    if(err != GL_NO_ERROR) {
+        ctx->setGLerror(GL_NO_ERROR);
+        return err;
+    }
+    return ctx->dispatcher().glGetError();
+}
+
+GL_APICALL void  GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params){
+    GET_CTX();
+    ctx->dispatcher().glGetFloatv(pname,params);
+}
+
+GL_APICALL void  GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params){
+    GET_CTX();
+    ctx->dispatcher().glGetIntegerv(pname,params);
+}
+
+GL_APICALL void  GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::framebufferTarget(target)         &&
+                   GLESv2Validate::framebufferAttachment(attachment) &&
+                   GLESv2Validate::framebufferAttachmentParams(pname)),GL_INVALID_ENUM);
+    ctx->dispatcher().glGetFramebufferAttachmentParameteriv(target,attachment,pname,params);
+}
+
+GL_APICALL void  GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::renderbufferTarget(target) && GLESv2Validate::renderbufferParams(pname)),GL_INVALID_ENUM);
+    ctx->dispatcher().glGetRenderbufferParameteriv(target,pname,params);
+}
+
+
+GL_APICALL void  GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        ctx->dispatcher().glGetProgramiv(globalProgramName,pname,params);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        ctx->dispatcher().glGetProgramInfoLog(globalProgramName,bufsize,length,infolog);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+        ctx->dispatcher().glGetShaderiv(globalShaderName,pname,params);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+        ctx->dispatcher().glGetShaderInfoLog(globalShaderName,bufsize,length,infolog);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision){
+    GET_CTX_V2();
+    SET_ERROR_IF(!(GLESv2Validate::shaderType(shadertype) && GLESv2Validate::precisionType(precisiontype)),GL_INVALID_ENUM);
+    if(ctx->glslVersion() < Version(1,30,10)){ //version 1.30.10 is the first version of GLSL Language containing precision qualifiers
+        range[0] = range[1] = 0;
+        precision = 0;
+    } else {
+        ctx->dispatcher().glGetShaderPrecisionFormat(shadertype,precisiontype,range,precision);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+       const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+       SET_ERROR_IF(globalShaderName == 0,GL_INVALID_VALUE);
+       ObjectDataPtr objData = thrd->shareGroup->getObjectData(SHADER,shader);
+       SET_ERROR_IF(!objData.Ptr(),GL_INVALID_OPERATION);
+       const char* src = ((ShaderParser*)objData.Ptr())->getOriginalSrc();
+       int srcLength = strlen(src);
+       SET_ERROR_IF(bufsize < 0 || srcLength > bufsize,GL_INVALID_VALUE);
+       *length = srcLength;
+       strncpy(source,src,srcLength);
+    }
+}
+
+
+GL_APICALL const GLubyte* GL_APIENTRY glGetString(GLenum name){
+    GET_CTX_RET(NULL)
+    static GLubyte VENDOR[]     = "Google";
+    static GLubyte RENDERER[]   = "OpenGL ES 2.0";
+    static GLubyte VERSION[]    = "OpenGL ES 2.0";
+    static GLubyte EXTENSIONS[] = "";
+    static GLubyte SHADING[]    = "OpenGL ES GLSL ES 1.0.17";
+    switch(name) {
+        case GL_VENDOR:
+            return VENDOR;
+        case GL_RENDERER:
+            return RENDERER;
+        case GL_VERSION:
+            return VERSION;
+        case GL_SHADING_LANGUAGE_VERSION:
+            return SHADING;
+        case GL_EXTENSIONS:
+            return EXTENSIONS;
+        default:
+            RET_AND_SET_ERROR_IF(true,GL_INVALID_ENUM,NULL);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::textureTarget(target) && GLESv2Validate::textureParams(pname)),GL_INVALID_ENUM);
+    ctx->dispatcher().glGetTexParameterfv(target,pname,params);
+
+}
+GL_APICALL void  GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::textureTarget(target) && GLESv2Validate::textureParams(pname)),GL_INVALID_ENUM);
+    ctx->dispatcher().glGetTexParameteriv(target,pname,params);
+}
+
+GL_APICALL void  GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        ctx->dispatcher().glGetUniformfv(globalProgramName,location,params);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        ctx->dispatcher().glGetUniformiv(globalProgramName,location,params);
+    }
+}
+
+GL_APICALL int GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name){
+    GET_CTX_RET(-1);
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        return ctx->dispatcher().glGetUniformLocation(globalProgramName,name);
+    }
+    return -1;
+}
+
+
+
+GL_APICALL void  GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params){
+    GET_CTX();
+    const GLESpointer* p = ctx->getPointer(pname);
+    if(p) {
+        switch(pname){
+        case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
+            *params = 0;
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
+            *params = p->isEnable();
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_SIZE:
+            *params = p->getSize();
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
+            *params = p->getStride();
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_TYPE:
+            *params = p->getType();
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
+            *params = p->isNormalize();
+            break;
+        case GL_CURRENT_VERTEX_ATTRIB:
+            ctx->dispatcher().glGetVertexAttribfv(index,pname,params);
+            break;
+        default:
+            ctx->setGLerror(GL_INVALID_ENUM);
+        }
+    } else {
+        ctx->setGLerror(GL_INVALID_ENUM);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params){
+    GET_CTX();
+    const GLESpointer* p = ctx->getPointer(pname);
+    if(p) {
+        switch(pname){
+        case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
+            *params = 0;
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
+            *params = p->isEnable();
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_SIZE:
+            *params = p->getSize();
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
+            *params = p->getStride();
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_TYPE:
+            *params = p->getType();
+            break;
+        case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
+            *params = p->isNormalize();
+            break;
+        case GL_CURRENT_VERTEX_ATTRIB:
+            ctx->dispatcher().glGetVertexAttribiv(index,pname,params);
+            break;
+        default:
+            ctx->setGLerror(GL_INVALID_ENUM);
+        }
+    } else {
+        ctx->setGLerror(GL_INVALID_ENUM);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer){
+    GET_CTX();
+    SET_ERROR_IF(pname != GL_VERTEX_ATTRIB_ARRAY_POINTER,GL_INVALID_ENUM); 
+    
+    const GLESpointer* p = ctx->getPointer(pname);
+    if(p) {
+        *pointer = const_cast<void *>( p->getBufferData());
+    } else {
+        ctx->setGLerror(GL_INVALID_ENUM);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glHint(GLenum target, GLenum mode){
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::hintTargetMode(target,mode),GL_INVALID_ENUM);
+    ctx->dispatcher().glHint(target,mode);
+}
+
+GL_APICALL GLboolean    GL_APIENTRY glIsEnabled(GLenum cap){
+    GET_CTX_RET(GL_FALSE);
+    RET_AND_SET_ERROR_IF(!GLESv2Validate::capability(cap),GL_INVALID_ENUM,GL_FALSE);
+    return ctx->dispatcher().glIsEnabled(cap);
+}
+
+GL_APICALL GLboolean    GL_APIENTRY glIsBuffer(GLuint buffer){
+    GET_CTX_RET(GL_FALSE)
+    if(buffer && thrd->shareGroup.Ptr()) {
+       ObjectDataPtr objData = thrd->shareGroup->getObjectData(VERTEXBUFFER,buffer);
+       return objData.Ptr() ? ((GLESbuffer*)objData.Ptr())->wasBinded():GL_FALSE;
+    }
+    return GL_FALSE;
+}
+
+GL_APICALL GLboolean    GL_APIENTRY glIsFramebuffer(GLuint framebuffer){
+    GET_CTX_RET(GL_FALSE)
+    if(framebuffer && thrd->shareGroup.Ptr()){
+        return thrd->shareGroup->isObject(FRAMEBUFFER,framebuffer) ? GL_TRUE :GL_FALSE;
+    }
+    return GL_FALSE;
+}
+
+GL_APICALL GLboolean    GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer){
+    GET_CTX_RET(GL_FALSE)
+    if(renderbuffer && thrd->shareGroup.Ptr()){
+        return thrd->shareGroup->isObject(RENDERBUFFER,renderbuffer) ? GL_TRUE :GL_FALSE;
+    }
+    return GL_FALSE;
+}
+
+GL_APICALL GLboolean    GL_APIENTRY glIsTexture(GLuint texture){
+    GET_CTX_RET(GL_FALSE)
+    if(texture && thrd->shareGroup.Ptr()){
+        return thrd->shareGroup->isObject(TEXTURE,texture) ? GL_TRUE :GL_FALSE;
+    }
+    return GL_FALSE;
+}
+
+GL_APICALL GLboolean    GL_APIENTRY glIsProgram(GLuint program){
+    GET_CTX_RET(GL_FALSE)
+    if(program && thrd->shareGroup.Ptr() &&
+       thrd->shareGroup->isObject(SHADER,program)) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        return ctx->dispatcher().glIsProgram(globalProgramName);
+    }
+    return GL_FALSE;
+}
+
+GL_APICALL GLboolean    GL_APIENTRY glIsShader(GLuint shader){
+    GET_CTX_RET(GL_FALSE)
+    if(shader && thrd->shareGroup.Ptr() &&
+       thrd->shareGroup->isObject(SHADER,shader)) {
+        const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+        return ctx->dispatcher().glIsShader(globalShaderName);
+    }
+    return GL_FALSE;
+}
+
+GL_APICALL void  GL_APIENTRY glLineWidth(GLfloat width){
+    GET_CTX();
+    ctx->dispatcher().glLineWidth(width);
+}
+
+GL_APICALL void  GL_APIENTRY glLinkProgram(GLuint program){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        ctx->dispatcher().glLinkProgram(globalProgramName);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glPixelStorei(GLenum pname, GLint param){
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::pixelStoreParam(pname),GL_INVALID_ENUM);
+    ctx->dispatcher().glPixelStorei(pname,param);
+}
+
+GL_APICALL void  GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units){
+    GET_CTX();
+    ctx->dispatcher().glPolygonOffset(factor,units);
+}
+
+GL_APICALL void  GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::readPixelFrmt(format) && GLESv2Validate::pixelType(ctx,type)),GL_INVALID_ENUM);
+    SET_ERROR_IF(!(GLESv2Validate::pixelOp(format,type)),GL_INVALID_OPERATION);
+    ctx->dispatcher().glReadPixels(x,y,width,height,format,type,pixels);
+}
+
+
+GL_APICALL void  GL_APIENTRY glReleaseShaderCompiler(void){
+    GET_CTX();
+    ctx->dispatcher().glReleaseShaderCompiler();
+}
+
+GL_APICALL void  GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height){
+    GET_CTX();
+    ctx->dispatcher().glRenderbufferStorage(target,internalformat,width,height);
+}
+
+GL_APICALL void  GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert){
+    GET_CTX();
+    ctx->dispatcher().glSampleCoverage(value,invert);
+}
+
+GL_APICALL void  GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height){
+    GET_CTX();
+    ctx->dispatcher().glScissor(x,y,width,height);
+}
+
+GL_APICALL void  GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()){
+        for(int i=0; i < n ; i++){
+            const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shaders[i]);
+            ctx->dispatcher().glShaderBinary(1,&globalShaderName,binaryformat,binary,length);
+        }
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length){
+    GET_CTX_V2();
+    SET_ERROR_IF(count < 0,GL_INVALID_VALUE);
+    if(thrd->shareGroup.Ptr()){
+            const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+            SET_ERROR_IF(globalShaderName == 0,GL_INVALID_VALUE);
+            ObjectDataPtr objData = thrd->shareGroup->getObjectData(SHADER,shader);
+            SET_ERROR_IF(!objData.Ptr(),GL_INVALID_OPERATION);
+            ShaderParser* sp = (ShaderParser*)objData.Ptr();
+            sp->setSrc(ctx->glslVersion(),count,string,length);
+            ctx->dispatcher().glShaderSource(globalShaderName,1,sp->parsedLines(),NULL);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask){
+    GET_CTX();
+    ctx->dispatcher().glStencilFunc(func,ref,mask);
+}
+GL_APICALL void  GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask){
+    GET_CTX();
+    ctx->dispatcher().glStencilFuncSeparate(face,func,ref,mask);
+}
+GL_APICALL void  GL_APIENTRY glStencilMask(GLuint mask){
+    GET_CTX();
+    ctx->dispatcher().glStencilMask(mask);
+}
+
+GL_APICALL void  GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask){
+    GET_CTX();
+    ctx->dispatcher().glStencilMaskSeparate(face,mask);
+}
+
+GL_APICALL void  GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass){
+    GET_CTX();
+    ctx->dispatcher().glStencilOp(fail,zfail,zpass);
+}
+
+GL_APICALL void  GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass){
+    GET_CTX();
+    ctx->dispatcher().glStencilOp(fail,zfail,zpass);
+}
+
+static TextureData* getTextureData(){
+    GET_CTX_RET(NULL);
+    unsigned int tex = ctx->getBindedTexture();
+    TextureData *texData = NULL;
+    ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex);
+    if(!objData.Ptr()){
+        texData = new TextureData();
+        thrd->shareGroup->setObjectData(TEXTURE, tex, ObjectDataPtr(texData));
+    } else {
+        texData = (TextureData*)objData.Ptr();
+    }
+    return texData;
+}
+
+GL_APICALL void  GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::textureTargetEx(target) &&
+                   GLESv2Validate::pixelFrmt(ctx,internalformat) &&
+                   GLESv2Validate::pixelFrmt(ctx,format)&&
+                   GLESv2Validate::pixelType(ctx,type)),GL_INVALID_ENUM);
+
+    SET_ERROR_IF(!(GLESv2Validate::pixelOp(format,type) && internalformat == ((GLint)format)),GL_INVALID_OPERATION);
+    SET_ERROR_IF(border != 0,GL_INVALID_VALUE);
+
+    if (thrd->shareGroup.Ptr()){
+        unsigned int tex = ctx->getBindedTexture();
+        TextureData *texData = getTextureData();
+        if(texData) {
+            texData->width = width;
+            texData->height = height;
+            texData->border = border;
+            texData->internalFormat = internalformat;
+        }
+    }
+    if (type==GL_HALF_FLOAT_OES)
+        type = GL_HALF_FLOAT_NV;
+    ctx->dispatcher().glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);
+}
+
+
+GL_APICALL void  GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::textureTarget(target) && GLESv2Validate::textureParams(pname)),GL_INVALID_ENUM);
+    ctx->dispatcher().glTexParameterf(target,pname,param);
+}
+GL_APICALL void  GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::textureTarget(target) && GLESv2Validate::textureParams(pname)),GL_INVALID_ENUM);
+    ctx->dispatcher().glTexParameterfv(target,pname,params);
+}
+GL_APICALL void  GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::textureTarget(target) && GLESv2Validate::textureParams(pname)),GL_INVALID_ENUM);
+    ctx->dispatcher().glTexParameteri(target,pname,param);
+}
+GL_APICALL void  GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::textureTarget(target) && GLESv2Validate::textureParams(pname)),GL_INVALID_ENUM);
+    ctx->dispatcher().glTexParameteriv(target,pname,params);
+}
+
+GL_APICALL void  GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels){
+    GET_CTX();
+    SET_ERROR_IF(!(GLESv2Validate::textureTargetEx(target) &&
+                   GLESv2Validate::pixelFrmt(ctx,format)&&
+                   GLESv2Validate::pixelType(ctx,type)),GL_INVALID_ENUM);
+    SET_ERROR_IF(!GLESv2Validate::pixelOp(format,type),GL_INVALID_OPERATION);
+    if (type==GL_HALF_FLOAT_OES)
+        type = GL_HALF_FLOAT_NV;
+
+    ctx->dispatcher().glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels);
+
+}
+
+GL_APICALL void  GL_APIENTRY glUniform1f(GLint location, GLfloat x){
+    GET_CTX();
+    ctx->dispatcher().glUniform1f(location,x);
+}
+GL_APICALL void  GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v){
+    GET_CTX();
+    ctx->dispatcher().glUniform1fv(location,count,v);
+}
+
+GL_APICALL void  GL_APIENTRY glUniform1i(GLint location, GLint x){
+    GET_CTX();
+    ctx->dispatcher().glUniform1i(location,x);
+}
+GL_APICALL void  GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v){
+    GET_CTX();
+    ctx->dispatcher().glUniform1iv(location,count,v);
+}
+GL_APICALL void  GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y){
+    GET_CTX();
+    ctx->dispatcher().glUniform2f(location,x,y);
+}
+GL_APICALL void  GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v){
+    GET_CTX();
+    ctx->dispatcher().glUniform2fv(location,count,v);
+}
+GL_APICALL void  GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y){
+    GET_CTX();
+    ctx->dispatcher().glUniform2i(location,x,y);
+}
+GL_APICALL void  GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v){
+    GET_CTX();
+    ctx->dispatcher().glUniform2iv(location,count,v);
+}
+GL_APICALL void  GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z){
+    GET_CTX();
+    ctx->dispatcher().glUniform3f(location,x,y,z);
+}
+GL_APICALL void  GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v){
+    GET_CTX();
+    ctx->dispatcher().glUniform3fv(location,count,v);
+}
+GL_APICALL void  GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z){
+    GET_CTX();
+    ctx->dispatcher().glUniform3i(location,x,y,z);
+}
+
+GL_APICALL void  GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v){
+    GET_CTX();
+    ctx->dispatcher().glUniform3iv(location,count,v);
+}
+
+GL_APICALL void  GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w){
+    GET_CTX();
+    ctx->dispatcher().glUniform4f(location,x,y,z,w);
+}
+
+GL_APICALL void  GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v){
+    GET_CTX();
+    ctx->dispatcher().glUniform4fv(location,count,v);
+}
+
+GL_APICALL void  GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w){
+    GET_CTX();
+    ctx->dispatcher().glUniform4i(location,x,y,z,w);
+}
+
+GL_APICALL void  GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v){
+    GET_CTX();
+    ctx->dispatcher().glUniform4iv(location,count,v);
+}
+
+GL_APICALL void  GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value){
+    GET_CTX();
+    SET_ERROR_IF(transpose != GL_FALSE,GL_INVALID_VALUE);
+    ctx->dispatcher().glUniformMatrix2fv(location,count,transpose,value);
+}
+
+GL_APICALL void  GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value){
+    GET_CTX();
+    SET_ERROR_IF(transpose != GL_FALSE,GL_INVALID_VALUE);
+    ctx->dispatcher().glUniformMatrix3fv(location,count,transpose,value);
+}
+
+GL_APICALL void  GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value){
+    GET_CTX();
+    SET_ERROR_IF(transpose != GL_FALSE,GL_INVALID_VALUE);
+    ctx->dispatcher().glUniformMatrix4fv(location,count,transpose,value);
+}
+
+GL_APICALL void  GL_APIENTRY glUseProgram(GLuint program){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        ctx->dispatcher().glUseProgram(globalProgramName);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glValidateProgram(GLuint program){
+    GET_CTX();
+    if(thrd->shareGroup.Ptr()) {
+        const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+        ctx->dispatcher().glValidateProgram(globalProgramName);
+    }
+}
+
+GL_APICALL void  GL_APIENTRY glVertexAttrib1f(GLuint indx, GLfloat x){
+    GET_CTX();
+    ctx->dispatcher().glVertexAttrib1f(indx,x);
+}
+
+GL_APICALL void  GL_APIENTRY glVertexAttrib1fv(GLuint indx, const GLfloat* values){
+    GET_CTX();
+    ctx->dispatcher().glVertexAttrib1fv(indx,values);
+}
+
+GL_APICALL void  GL_APIENTRY glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y){
+    GET_CTX();
+    ctx->dispatcher().glVertexAttrib2f(indx,x,y);
+}
+
+GL_APICALL void  GL_APIENTRY glVertexAttrib2fv(GLuint indx, const GLfloat* values){
+    GET_CTX();
+    ctx->dispatcher().glVertexAttrib2fv(indx,values);
+}
+
+GL_APICALL void  GL_APIENTRY glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z){
+    GET_CTX();
+    ctx->dispatcher().glVertexAttrib3f(indx,x,y,z);
+}
+
+GL_APICALL void  GL_APIENTRY glVertexAttrib3fv(GLuint indx, const GLfloat* values){
+    GET_CTX();
+    ctx->dispatcher().glVertexAttrib3fv(indx,values);
+}
+
+GL_APICALL void  GL_APIENTRY glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w){
+    GET_CTX();
+    ctx->dispatcher().glVertexAttrib4f(indx,x,y,z,w);
+}
+
+GL_APICALL void  GL_APIENTRY glVertexAttrib4fv(GLuint indx, const GLfloat* values){
+    GET_CTX();
+    ctx->dispatcher().glVertexAttrib4fv(indx,values);
+}
+
+GL_APICALL void  GL_APIENTRY glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr){
+    GET_CTX();
+    if (type==GL_HALF_FLOAT_OES)
+        type = GL_HALF_FLOAT;
+    const GLvoid* data = ctx->setPointer(indx,size,type,stride,ptr);
+    if(type != GL_FIXED) ctx->dispatcher().glVertexAttribPointer(indx,size,type,normalized,stride,ptr);
+}
+
+GL_APICALL void  GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height){
+    GET_CTX();
+    ctx->dispatcher().glViewport(x,y,width,height);
+}
+
+GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
+{
+    GET_CTX();
+    SET_ERROR_IF(!GLESv2Validate::textureTargetLimited(target),GL_INVALID_ENUM);
+    EglImage *img = s_eglIface->eglAttachEGLImage((unsigned int)image);
+    if (img) {
+        // Create the texture object in the underlying EGL implementation,
+        // flag to the OpenGL layer to skip the image creation and map the
+        // current binded texture object to the existing global object.
+        if (thrd->shareGroup.Ptr()) {
+            unsigned int tex = ctx->getBindedTexture();
+            unsigned int oldGlobal = thrd->shareGroup->getGlobalName(TEXTURE, tex);
+            // Delete old texture object
+            if (oldGlobal) {
+                ctx->dispatcher().glDeleteTextures(1, &oldGlobal);
+            }
+            // replace mapping and bind the new global object
+            thrd->shareGroup->replaceGlobalName(TEXTURE, tex,img->globalTexName);
+            ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName);
+            TextureData *texData = getTextureData();
+            SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
+            texData->sourceEGLImage = (unsigned int)image;
+            texData->eglImageDetach = s_eglIface->eglDetachEGLImage;
+        }
+    }
+}
+
+GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
+{
+    GET_CTX()
+    //not supported by EGL
+    SET_ERROR_IF(false,GL_INVALID_OPERATION);
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
new file mode 100644
index 0000000..ea8cbfd
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
@@ -0,0 +1,138 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#include "GLESv2Validate.h"
+
+bool GLESv2Validate::blendEquationMode(GLenum mode){
+    return mode == GL_FUNC_ADD             ||
+           mode == GL_FUNC_SUBTRACT        ||
+           mode == GL_FUNC_REVERSE_SUBTRACT;
+}
+
+bool GLESv2Validate::blendSrc(GLenum s) {
+   switch(s) {
+   case GL_ZERO:
+   case GL_ONE:
+   case GL_SRC_COLOR:
+   case GL_ONE_MINUS_SRC_COLOR:
+   case GL_DST_COLOR:
+   case GL_ONE_MINUS_DST_COLOR:
+   case GL_SRC_ALPHA:
+   case GL_ONE_MINUS_SRC_ALPHA:
+   case GL_DST_ALPHA:
+   case GL_ONE_MINUS_DST_ALPHA:
+   case GL_CONSTANT_COLOR:
+   case GL_ONE_MINUS_CONSTANT_COLOR:
+   case GL_CONSTANT_ALPHA:
+   case GL_ONE_MINUS_CONSTANT_ALPHA:
+   case GL_SRC_ALPHA_SATURATE:
+        return true;
+  }
+  return false;
+}
+
+
+bool GLESv2Validate::blendDst(GLenum d) {
+   switch(d) {
+   case GL_ZERO:
+   case GL_ONE:
+   case GL_SRC_COLOR:
+   case GL_ONE_MINUS_SRC_COLOR:
+   case GL_DST_COLOR:
+   case GL_ONE_MINUS_DST_COLOR:
+   case GL_SRC_ALPHA:
+   case GL_ONE_MINUS_SRC_ALPHA:
+   case GL_DST_ALPHA:
+   case GL_ONE_MINUS_DST_ALPHA:
+   case GL_CONSTANT_COLOR:
+   case GL_ONE_MINUS_CONSTANT_COLOR:
+   case GL_CONSTANT_ALPHA:
+   case GL_ONE_MINUS_CONSTANT_ALPHA:
+        return true;
+   }
+   return false;
+}
+
+bool GLESv2Validate::textureParams(GLenum param){
+    switch(param) {
+    case GL_TEXTURE_MIN_FILTER:
+    case GL_TEXTURE_MAG_FILTER:
+    case GL_TEXTURE_WRAP_S:
+    case GL_TEXTURE_WRAP_T:
+        return true;
+    default:
+        return false;
+    }
+}
+
+bool GLESv2Validate::hintTargetMode(GLenum target,GLenum mode){
+
+   switch(mode) {
+   case GL_FASTEST:
+   case GL_NICEST:
+   case GL_DONT_CARE:
+       break;
+   default: return false;
+   }
+   return target == GL_GENERATE_MIPMAP_HINT || target == GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES;
+}
+
+bool GLESv2Validate::capability(GLenum cap){
+    switch(cap){
+    case GL_BLEND:
+    case GL_CULL_FACE:
+    case GL_DEPTH_TEST:
+    case GL_DITHER:
+    case GL_POLYGON_OFFSET_FILL:
+    case GL_SAMPLE_ALPHA_TO_COVERAGE:
+    case GL_SAMPLE_COVERAGE:
+    case GL_SCISSOR_TEST:
+    case GL_STENCIL_TEST:
+        return true;
+    }
+    return false;
+}
+
+bool GLESv2Validate::pixelStoreParam(GLenum param){
+    return param == GL_PACK_ALIGNMENT || param == GL_UNPACK_ALIGNMENT;
+}
+
+bool GLESv2Validate::readPixelFrmt(GLenum format){
+    switch(format) {
+    case GL_ALPHA:
+    case GL_RGB:
+    case GL_RGBA:
+        return true;
+    }
+    return false;
+}
+
+
+bool GLESv2Validate::shaderType(GLenum type){
+    return type == GL_VERTEX_SHADER || type == GL_FRAGMENT_SHADER;
+}
+
+bool GLESv2Validate::precisionType(GLenum type){
+    switch(type){
+    case GL_LOW_FLOAT:
+    case GL_MEDIUM_FLOAT:
+    case GL_HIGH_FLOAT:
+    case GL_LOW_INT:
+    case GL_MEDIUM_INT:
+    case GL_HIGH_INT:
+        return true;
+    }
+    return false;
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h
new file mode 100644
index 0000000..6338914
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h
@@ -0,0 +1,37 @@
+#ifndef GLES_V2_VALIDATE_H
+#define GLES_V2_VALIDATE_H
+
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <GLcommon/GLESvalidate.h>
+
+struct GLESv2Validate:public GLESvalidate{
+static bool blendEquationMode(GLenum mode);
+static bool blendSrc(GLenum s);
+static bool blendDst(GLenum d);
+static bool textureParams(GLenum param);
+static bool hintTargetMode(GLenum target,GLenum mode);
+static bool capability(GLenum cap);
+static bool pixelStoreParam(GLenum param);
+static bool readPixelFrmt(GLenum format);
+static bool shaderType(GLenum type);
+static bool precisionType(GLenum type);
+};
+
+#endif
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
new file mode 100644
index 0000000..00d6ab0
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
@@ -0,0 +1,83 @@
+#include "ShaderParser.h"
+#include <string.h>
+
+ShaderParser::ShaderParser():m_type(0),
+                             m_src(NULL),
+                             m_parsedLines(NULL){};
+
+ShaderParser::ShaderParser(GLenum type):m_type(type),
+                                                    m_parsedLines(NULL){};
+
+void ShaderParser::setSrc(const Version& ver,GLsizei count,const GLchar** strings,const GLint* length){
+    for(int i = 0;i<count;i++){
+        m_src.append(strings[i]);
+    }
+    clearParsedSrc();
+    /*
+      version 1.30.10 is the first version of GLSL Language containing precision qualifiers
+      if the glsl version is less than 1.30.10 than we will use a shader parser which omits
+      all precision qualifiers from the shader source , otherwise we will use a shader parser
+      which set the default precisions to be the same as the default precisions of GLSL ES
+    */
+    if(ver < Version(1,30,10)){
+        parseOmitPrecision();
+     } else {
+        parseExtendDefaultPrecision();
+     }
+}
+
+const char* ShaderParser::getOriginalSrc(){
+    return m_src.c_str();
+}
+
+void ShaderParser::parseOmitPrecision(){
+
+    //defines we need to add in order to Omit precisions qualifiers
+    static const GLchar defines[] = {
+                                         "#define GLES 1\n"
+                                         "#define lowp \n"
+                                         "#define mediump \n"
+                                         "#define highp \n"
+                                         "#define precision \n"
+                                     };
+
+    //the lengths of defines we need to add in order to Omit precisions qualifiers
+    static GLuint definesLength   = strlen(defines);
+
+    const GLchar* origSrc = m_src.c_str();
+    unsigned int origLength = strlen(origSrc);
+
+    m_parsedLines = new GLchar[origLength + definesLength + 1];
+    strncpy(m_parsedLines,defines,definesLength);
+    strcpy(m_parsedLines+definesLength,origSrc);
+}
+
+void ShaderParser::parseExtendDefaultPrecision(){
+
+    //the precision lines which we need to add to the shader
+    static const GLchar extend[] = {
+                                      "#define GLES 1\n"
+                                      "precision lowp sampler2D;\n"
+                                      "precision lowp samplerCube;\n"
+                                   };
+
+    //the length of the precision lines which we need to add to the shader
+    static GLint extendLength = strlen(extend);
+
+    const GLchar* origSrc = m_src.c_str();
+    unsigned int origLength = strlen(origSrc);
+
+    m_parsedLines = new GLchar[origLength + extendLength + 1];
+    strncpy(m_parsedLines,extend,extendLength);
+    strcpy(m_parsedLines+extendLength,origSrc);
+}
+
+void ShaderParser::clearParsedSrc(){
+    if(m_parsedLines){
+        delete[] m_parsedLines;
+    }
+}
+
+ShaderParser::~ShaderParser(){
+    clearParsedSrc();
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h b/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h
new file mode 100644
index 0000000..f7c91fc
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h
@@ -0,0 +1,27 @@
+#ifndef SHADER_PARSER_H
+#define SHADER_PARSER_H
+
+#include "GLESv2Context.h"
+#include <string>
+#include <GLES2/gl2.h>
+#include <GLcommon/objectNameManager.h>
+
+class ShaderParser:public ObjectData{
+public:
+    ShaderParser();
+    ShaderParser(GLenum type);
+    void           setSrc(const Version& ver,GLsizei count,const GLchar** strings,const GLint* length);
+    const char*    getOriginalSrc();
+    const GLchar** parsedLines(){return const_cast<const GLchar**>(&m_parsedLines);};
+    ~ShaderParser();
+
+private:
+    void parseOmitPrecision();
+    void parseExtendDefaultPrecision();
+    void clearParsedSrc();
+
+    GLenum      m_type;
+    std::string m_src;
+    GLchar*     m_parsedLines;
+};
+#endif
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/Android.mk b/tools/emulator/opengl/host/libs/Translator/GLcommon/Android.mk
index d1869b5..0e9cb97 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLcommon/Android.mk
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/Android.mk
@@ -7,14 +7,23 @@
 translator_path := $(LOCAL_PATH)/..
 
 LOCAL_SRC_FILES :=           \
+     GLDispatch.cpp          \
      GLutils.cpp             \
+     GLEScontext.cpp         \
+     GLESvalidate.cpp        \
+     GLESpointer.cpp         \
+     GLESbuffer.cpp          \
+     DummyGLfuncs.cpp        \
+     RangeManip.cpp          \
      objectNameManager.cpp
 
 
 LOCAL_C_INCLUDES += \
-                 $(translator_path)/include
+                 $(translator_path)/include \
+                 $(translator_path)/../../../shared
 
 LOCAL_STATIC_LIBRARIES := \
+    libOpenglOsUtils      \
     libutils              \
     libcutils
 
@@ -23,6 +32,11 @@
 LOCAL_MODULE := libGLcommon
 ifeq ($(HOST_OS),linux)
     LOCAL_LDFLAGS := -Wl,--whole-archive
+    LOCAL_LDLIBS := -lGL -ldl
 endif
 
-include $(BUILD_HOST_SHARED_LIBRARY)
+ifeq ($(HOST_OS),windows)
+    LOCAL_LDLIBS := -lopengl32 -lgdi32
+endif
+
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp
new file mode 100644
index 0000000..6bf087e
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp
@@ -0,0 +1,255 @@
+#include "DummyGLfuncs.h"
+
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+    void GLAPIENTRY dummy_glActiveTexture ( GLenum texture ){}
+    void GLAPIENTRY dummy_glBindBuffer (GLenum target, GLuint buffer){}
+    void GLAPIENTRY dummy_glBindTexture (GLenum target, GLuint texture){}
+    void GLAPIENTRY dummy_glBlendFunc (GLenum sfactor, GLenum dfactor){}
+    void GLAPIENTRY dummy_glBlendEquation( GLenum mode ){}
+    void GLAPIENTRY dummy_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha){}
+    void GLAPIENTRY dummy_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha){}
+    void GLAPIENTRY dummy_glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage){}
+    void GLAPIENTRY dummy_glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data){}
+    void GLAPIENTRY dummy_glClear(GLbitfield mask){}
+    void GLAPIENTRY dummy_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha){}
+    void GLAPIENTRY dummy_glClearStencil(GLint s){}
+    void GLAPIENTRY dummy_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha){}
+    void GLAPIENTRY dummy_glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ){}
+    void GLAPIENTRY dummy_glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ){}
+    void GLAPIENTRY dummy_glCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border){}
+    void GLAPIENTRY dummy_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height){}
+    void GLAPIENTRY dummy_glCullFace(GLenum mode){}
+    void GLAPIENTRY dummy_glDeleteBuffers(GLsizei n, const GLuint *buffers){}
+    void GLAPIENTRY dummy_glDeleteTextures(GLsizei n, const GLuint *textures){}
+    void GLAPIENTRY dummy_glDepthFunc(GLenum func){}
+    void GLAPIENTRY dummy_glDepthMask(GLboolean flag){}
+    void GLAPIENTRY dummy_glDepthRange(GLclampd zNear, GLclampd zFar){}
+    void GLAPIENTRY dummy_glDisable(GLenum cap){}
+    void GLAPIENTRY dummy_glDrawArrays(GLenum mode, GLint first, GLsizei count){}
+    void GLAPIENTRY dummy_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices){}
+    void GLAPIENTRY dummy_glEnable(GLenum cap){}
+    void GLAPIENTRY dummy_glFinish(void){}
+    void GLAPIENTRY dummy_glFlush(void){}
+    void GLAPIENTRY dummy_glFrontFace(GLenum mode){}
+    void GLAPIENTRY dummy_glGenBuffers(GLsizei n, GLuint *buffers){}
+    void GLAPIENTRY dummy_glGenTextures(GLsizei n, GLuint *textures){}
+    void GLAPIENTRY dummy_glGetBooleanv(GLenum pname, GLboolean *params){}
+    void GLAPIENTRY dummy_glGetBufferParameteriv(GLenum, GLenum, GLint *){}
+    GLenum GLAPIENTRY dummy_glGetError(void){ return 0;}
+    void GLAPIENTRY dummy_glGetFloatv(GLenum pname, GLfloat *params){}
+    void GLAPIENTRY dummy_glGetIntegerv(GLenum pname, GLint *params){}
+    const GLubyte * GLAPIENTRY dummy_glGetString(GLenum name){ return 0;}
+    void GLAPIENTRY dummy_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params){}
+    void GLAPIENTRY dummy_glGetTexParameteriv(GLenum target, GLenum pname, GLint *params){}
+    void GLAPIENTRY dummy_glHint(GLenum target, GLenum mode){}
+    GLboolean GLAPIENTRY dummy_glIsBuffer(GLuint){ return false;}
+    GLboolean GLAPIENTRY dummy_glIsEnabled(GLenum cap){ return false;}
+    GLboolean GLAPIENTRY dummy_glIsTexture(GLuint texture){return false;}
+    void GLAPIENTRY dummy_glLineWidth(GLfloat width){}
+    void GLAPIENTRY dummy_glPolygonOffset(GLfloat factor, GLfloat units){}
+    void GLAPIENTRY dummy_glPixelStorei(GLenum pname, GLint param){}
+    void GLAPIENTRY dummy_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels){}
+    void GLAPIENTRY dummy_glSampleCoverage(GLclampf value, GLboolean invert ){}
+    void GLAPIENTRY dummy_glScissor(GLint x, GLint y, GLsizei width, GLsizei height){}
+    void GLAPIENTRY dummy_glStencilFunc(GLenum func, GLint ref, GLuint mask){}
+    void GLAPIENTRY dummy_glStencilMask(GLuint mask){}
+    void GLAPIENTRY dummy_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass){}
+    void GLAPIENTRY dummy_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels){}
+    void GLAPIENTRY dummy_glTexParameteri(GLenum target, GLenum pname, GLint param){}
+    void GLAPIENTRY dummy_glTexParameteriv(GLenum target, GLenum pname, const GLint *params){}
+    void GLAPIENTRY dummy_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels){}
+    void GLAPIENTRY dummy_glViewport(GLint x, GLint y, GLsizei width, GLsizei height){}
+    void GLAPIENTRY dummy_glPushAttrib( GLbitfield mask ){}
+    void GLAPIENTRY dummy_glPopAttrib( void ){}
+    void GLAPIENTRY dummy_glPushClientAttrib( GLbitfield mask ){}
+    void GLAPIENTRY dummy_glPopClientAttrib( void ){}
+
+    /* OpenGL functions which are needed ONLY for implementing GLES 1.1*/
+    void GLAPIENTRY dummy_glAlphaFunc(GLenum func, GLclampf ref){}
+    void GLAPIENTRY dummy_glBegin( GLenum mode ){}
+    void GLAPIENTRY dummy_glClearDepth(GLclampd depth){}
+    void GLAPIENTRY dummy_glClientActiveTexture( GLenum texture ){}
+    void GLAPIENTRY dummy_glClipPlane(GLenum plane, const GLdouble *equation){}
+    void GLAPIENTRY dummy_glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha){}
+    void GLAPIENTRY dummy_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha){}
+    void GLAPIENTRY dummy_glColor4fv( const GLfloat *v ){}
+    void GLAPIENTRY dummy_glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha){}
+    void GLAPIENTRY dummy_glColor4ubv( const GLubyte *v ){}
+    void GLAPIENTRY dummy_glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer){}
+    void GLAPIENTRY dummy_glDisableClientState(GLenum array){}
+    void GLAPIENTRY dummy_glEnableClientState(GLenum array){}
+    void GLAPIENTRY dummy_glEnd(void){}
+    void GLAPIENTRY dummy_glFogf(GLenum pname, GLfloat param){}
+    void GLAPIENTRY dummy_glFogfv(GLenum pname, const GLfloat *params){}
+    void GLAPIENTRY dummy_glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar){}
+    void GLAPIENTRY dummy_glGetClipPlane(GLenum plane, GLdouble *equation){}
+    void GLAPIENTRY dummy_glGetDoublev( GLenum pname, GLdouble *params ){}
+    void GLAPIENTRY dummy_glGetLightfv(GLenum light, GLenum pname, GLfloat *params){}
+    void GLAPIENTRY dummy_glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params){}
+    void GLAPIENTRY dummy_glGetPointerv(GLenum pname, GLvoid* *params){}
+    void GLAPIENTRY dummy_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params){}
+    void GLAPIENTRY dummy_glGetTexEnviv(GLenum target, GLenum pname, GLint *params){}
+    void GLAPIENTRY dummy_glLightf(GLenum light, GLenum pname, GLfloat param){}
+    void GLAPIENTRY dummy_glLightfv(GLenum light, GLenum pname, const GLfloat *params){}
+    void GLAPIENTRY dummy_glLightModelf(GLenum pname, GLfloat param){}
+    void GLAPIENTRY dummy_glLightModelfv(GLenum pname, const GLfloat *params){}
+    void GLAPIENTRY dummy_glLoadIdentity(void){}
+    void GLAPIENTRY dummy_glLoadMatrixf(const GLfloat *m){}
+    void GLAPIENTRY dummy_glLogicOp(GLenum opcode){}
+    void GLAPIENTRY dummy_glMaterialf(GLenum face, GLenum pname, GLfloat param){}
+    void GLAPIENTRY dummy_glMaterialfv(GLenum face, GLenum pname, const GLfloat *params){}
+    void GLAPIENTRY dummy_glMultiTexCoord2fv( GLenum target, const GLfloat *v ){}
+    void GLAPIENTRY dummy_glMultiTexCoord2sv( GLenum target, const GLshort *v ){}
+    void GLAPIENTRY dummy_glMultiTexCoord3fv( GLenum target, const GLfloat *v ){}
+    void GLAPIENTRY dummy_glMultiTexCoord3sv( GLenum target, const GLshort *v ){}
+    void GLAPIENTRY dummy_glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ){}
+    void GLAPIENTRY dummy_glMultiTexCoord4fv( GLenum target, const GLfloat *v ){}
+    void GLAPIENTRY dummy_glMultiTexCoord4sv( GLenum target, const GLshort *v ){}
+    void GLAPIENTRY dummy_glMultMatrixf(const GLfloat *m){}
+    void GLAPIENTRY dummy_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz){}
+    void GLAPIENTRY dummy_glNormal3fv( const GLfloat *v ){}
+    void GLAPIENTRY dummy_glNormal3sv(const GLshort *v ){}
+    void GLAPIENTRY dummy_glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar){}
+    void GLAPIENTRY dummy_glPointParameterf(GLenum, GLfloat){}
+    void GLAPIENTRY dummy_glPointParameterfv(GLenum, const GLfloat *){}
+    void GLAPIENTRY dummy_glPointSize(GLfloat size){}
+    void GLAPIENTRY dummy_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z){}
+    void GLAPIENTRY dummy_glScalef(GLfloat x, GLfloat y, GLfloat z){}
+    void GLAPIENTRY dummy_glTexEnvf(GLenum target, GLenum pname, GLfloat param){}
+    void GLAPIENTRY dummy_glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params){}
+    void GLAPIENTRY dummy_glTexParameterf(GLenum target, GLenum pname, GLfloat param){}
+    void GLAPIENTRY dummy_glTexParameterfv(GLenum target, GLenum pname, const GLfloat *params){}
+    void GLAPIENTRY dummy_glMatrixMode(GLenum mode){}
+    void GLAPIENTRY dummy_glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer){}
+    void GLAPIENTRY dummy_glPopMatrix(void){}
+    void GLAPIENTRY dummy_glPushMatrix(void){}
+    void GLAPIENTRY dummy_glShadeModel(GLenum mode){}
+    void GLAPIENTRY dummy_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer){}
+    void GLAPIENTRY dummy_glTexEnvi(GLenum target, GLenum pname, GLint param){}
+    void GLAPIENTRY dummy_glTexEnviv(GLenum target, GLenum pname, const GLint *params){}
+    void GLAPIENTRY dummy_glTranslatef(GLfloat x, GLfloat y, GLfloat z){}
+    void GLAPIENTRY dummy_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer){}
+
+    /* OpenGL functions which are needed ONLY for implementing GLES 1.1 EXTENSIONS*/
+    GLboolean GLAPIENTRY dummy_glIsRenderbufferEXT(GLuint renderbuffer){ return false;}
+    void GLAPIENTRY dummy_glBindRenderbufferEXT(GLenum target, GLuint renderbuffer){}
+    void GLAPIENTRY dummy_glDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers){}
+    void GLAPIENTRY dummy_glGenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers){}
+    void GLAPIENTRY dummy_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height){}
+    void GLAPIENTRY dummy_glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params){}
+    GLboolean GLAPIENTRY dummy_glIsFramebufferEXT(GLuint framebuffer){ return false;}
+    void GLAPIENTRY dummy_glBindFramebufferEXT(GLenum target, GLuint framebuffer){}
+    void GLAPIENTRY dummy_glDeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers){}
+    void GLAPIENTRY dummy_glGenFramebuffersEXT(GLsizei n, GLuint *framebuffers){}
+    GLenum GLAPIENTRY dummy_glCheckFramebufferStatusEXT(GLenum target){ return 0;}
+    void GLAPIENTRY dummy_glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level){}
+    void GLAPIENTRY dummy_glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level){}
+    void GLAPIENTRY dummy_glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset){}
+    void GLAPIENTRY dummy_glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer){}
+    void GLAPIENTRY dummy_glGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint *params){}
+    void GLAPIENTRY dummy_glGenerateMipmapEXT(GLenum target){}
+    void GLAPIENTRY dummy_glCurrentPaletteMatrixARB(GLint index){}
+    void GLAPIENTRY dummy_glMatrixIndexuivARB(GLint size, GLuint * indices){}
+    void GLAPIENTRY dummy_glMatrixIndexPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer){}
+    void GLAPIENTRY dummy_glWeightPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer){}
+    void GLAPIENTRY dummy_glTexGenf(GLenum coord, GLenum pname, GLfloat param ){}
+    void GLAPIENTRY dummy_glTexGeni(GLenum coord, GLenum pname, GLint param ){}
+    void GLAPIENTRY dummy_glTexGenf(GLenum coord, GLenum pname, const GLfloat *params ){}
+    void GLAPIENTRY dummy_glTexGeniv(GLenum coord, GLenum pname, const GLint *params ){}
+    void GLAPIENTRY dummy_glGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params ){}
+    void GLAPIENTRY dummy_glGetTexGeniv(GLenum coord, GLenum pname, GLint *params ){}
+
+    /* Loading OpenGL functions which are needed ONLY for implementing GLES 2.0*/
+    void GL_APIENTRY dummy_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha){}
+    void GL_APIENTRY dummy_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask){}
+    void GL_APIENTRY dummy_glStencilMaskSeparate(GLenum face, GLuint mask){}
+    void GL_APIENTRY dummy_glGenerateMipmap(GLenum target){}
+    void GL_APIENTRY dummy_glBindFramebuffer(GLenum target, GLuint framebuffer){}
+    void GL_APIENTRY dummy_glBindRenderbuffer(GLenum target, GLuint renderbuffer){}
+    void GL_APIENTRY dummy_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers){}
+    void GL_APIENTRY dummy_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers){}
+    GLboolean GL_APIENTRY dummy_glIsProgram(GLuint program){ return false;}
+    GLboolean GL_APIENTRY dummy_glIsShader(GLuint shader){ return false;}
+    void GL_APIENTRY dummy_glVertexAttrib1f(GLuint indx, GLfloat x){}
+    void GL_APIENTRY dummy_glVertexAttrib1fv(GLuint indx, const GLfloat* values){}
+    void GL_APIENTRY dummy_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y){}
+    void GL_APIENTRY dummy_glVertexAttrib2fv(GLuint indx, const GLfloat* values){}
+    void GL_APIENTRY dummy_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z){}
+    void GL_APIENTRY dummy_glVertexAttrib3fv(GLuint indx, const GLfloat* values){}
+    void GL_APIENTRY dummy_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w){}
+    void GL_APIENTRY dummy_glVertexAttrib4fv(GLuint indx, const GLfloat* values){}
+    void GL_APIENTRY dummy_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr){}
+    void GL_APIENTRY dummy_glDisableVertexAttribArray(GLuint index){}
+    void GL_APIENTRY dummy_glEnableVertexAttribArray(GLuint index){}
+    void GL_APIENTRY dummy_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params){}
+    void GL_APIENTRY dummy_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params){}
+    void GL_APIENTRY dummy_glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer){}
+    void GL_APIENTRY dummy_glUniform1f(GLint location, GLfloat x){}
+    void GL_APIENTRY dummy_glUniform1fv(GLint location, GLsizei count, const GLfloat* v){}
+    void GL_APIENTRY dummy_glUniform1i(GLint location, GLint x){}
+    void GL_APIENTRY dummy_glUniform1iv(GLint location, GLsizei count, const GLint* v){}
+    void GL_APIENTRY dummy_glUniform2f(GLint location, GLfloat x, GLfloat y){}
+    void GL_APIENTRY dummy_glUniform2fv(GLint location, GLsizei count, const GLfloat* v){}
+    void GL_APIENTRY dummy_glUniform2i(GLint location, GLint x, GLint y){}
+    void GL_APIENTRY dummy_glUniform2iv(GLint location, GLsizei count, const GLint* v){}
+    void GL_APIENTRY dummy_glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z){}
+    void GL_APIENTRY dummy_glUniform3fv(GLint location, GLsizei count, const GLfloat* v){}
+    void GL_APIENTRY dummy_glUniform3i(GLint location, GLint x, GLint y, GLint z){}
+    void GL_APIENTRY dummy_glUniform3iv(GLint location, GLsizei count, const GLint* v){}
+    void GL_APIENTRY dummy_glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w){}
+    void GL_APIENTRY dummy_glUniform4fv(GLint location, GLsizei count, const GLfloat* v){}
+    void GL_APIENTRY dummy_glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w){}
+    void GL_APIENTRY dummy_glUniform4iv(GLint location, GLsizei count, const GLint* v){}
+    void GL_APIENTRY dummy_glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value){}
+    void GL_APIENTRY dummy_glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value){}
+    void GL_APIENTRY dummy_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value){}
+    void GL_APIENTRY dummy_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params){}
+    void GL_APIENTRY dummy_glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params){}
+    GLboolean GL_APIENTRY dummy_glIsFramebuffer(GLuint framebuffer){ return false;}
+    GLboolean GL_APIENTRY dummy_glIsRenderbuffer(GLuint renderbuffer){ return false;}
+    GLenum GL_APIENTRY dummy_glCheckFramebufferStatus(GLenum target){ return 0;}
+    void GL_APIENTRY dummy_glAttachShader(GLuint program, GLuint shader){}
+    void GL_APIENTRY dummy_glBindAttribLocation(GLuint program, GLuint index, const GLchar* name){}
+    void GL_APIENTRY dummy_glCompileShader(GLuint shader){}
+    GLuint GL_APIENTRY dummy_glCreateProgram(void){ return 0;}
+    GLuint GL_APIENTRY dummy_glCreateShader(GLenum type){ return 0;}
+    void GL_APIENTRY dummy_glDeleteProgram(GLuint program){}
+    void GL_APIENTRY dummy_glDeleteShader(GLuint shader){}
+    void GL_APIENTRY dummy_glDetachShader(GLuint program, GLuint shader){}
+    void GL_APIENTRY dummy_glLinkProgram(GLuint program){}
+    void GL_APIENTRY dummy_glUseProgram(GLuint program){}
+    void GL_APIENTRY dummy_glValidateProgram(GLuint program){}
+    void GL_APIENTRY dummy_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name){}
+    void GL_APIENTRY dummy_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name){}
+    void GL_APIENTRY dummy_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders){}
+    int  GL_APIENTRY dummy_glGetAttribLocation(GLuint program, const GLchar* name){ return 0;}
+    void GL_APIENTRY dummy_glGetProgramiv(GLuint program, GLenum pname, GLint* params){}
+    void GL_APIENTRY dummy_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog){}
+    void GL_APIENTRY dummy_glGetShaderiv(GLuint shader, GLenum pname, GLint* params){}
+    void GL_APIENTRY dummy_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog){}
+    void GL_APIENTRY dummy_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision){}
+    void GL_APIENTRY dummy_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source){}
+    void GL_APIENTRY dummy_glGetUniformfv(GLuint program, GLint location, GLfloat* params){}
+    void GL_APIENTRY dummy_glGetUniformiv(GLuint program, GLint location, GLint* params){}
+    int  GL_APIENTRY dummy_glGetUniformLocation(GLuint program, const GLchar* name){ return 0;}
+    void GL_APIENTRY dummy_glReleaseShaderCompiler(void){}
+    void GL_APIENTRY dummy_glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height){}
+    void GL_APIENTRY dummy_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length){}
+    void GL_APIENTRY dummy_glShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length){}
+    void GL_APIENTRY dummy_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer){}
+    void GL_APIENTRY dummy_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level){}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h b/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h
new file mode 100644
index 0000000..7dc803a
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h
@@ -0,0 +1,264 @@
+#ifndef DUMMY_GL_FUNCS_H
+#define DUMMY_GL_FUNCS_H
+
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <GLES/gl.h>
+#include <GLES2/gl2.h>
+
+#include <GLcommon/gldefs.h>
+#define GLAPIENTRY GL_APIENTRY
+
+    void GLAPIENTRY dummy_glActiveTexture ( GLenum texture );
+    void GLAPIENTRY dummy_glBindBuffer (GLenum target, GLuint buffer);
+    void GLAPIENTRY dummy_glBindTexture (GLenum target, GLuint texture);
+    void GLAPIENTRY dummy_glBlendFunc (GLenum sfactor, GLenum dfactor);
+    void GLAPIENTRY dummy_glBlendEquation( GLenum mode );
+    void GLAPIENTRY dummy_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
+    void GLAPIENTRY dummy_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+    void GLAPIENTRY dummy_glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
+    void GLAPIENTRY dummy_glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+    void GLAPIENTRY dummy_glClear(GLbitfield mask);
+    void GLAPIENTRY dummy_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+    void GLAPIENTRY dummy_glClearStencil(GLint s);
+    void GLAPIENTRY dummy_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+    void GLAPIENTRY dummy_glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data );
+    void GLAPIENTRY dummy_glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data );
+    void GLAPIENTRY dummy_glCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+    void GLAPIENTRY dummy_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+    void GLAPIENTRY dummy_glCullFace(GLenum mode);
+    void GLAPIENTRY dummy_glDeleteBuffers(GLsizei n, const GLuint *buffers);
+    void GLAPIENTRY dummy_glDeleteTextures(GLsizei n, const GLuint *textures);
+    void GLAPIENTRY dummy_glDepthFunc(GLenum func);
+    void GLAPIENTRY dummy_glDepthMask(GLboolean flag);
+    void GLAPIENTRY dummy_glDepthRange(GLclampd zNear, GLclampd zFar);
+    void GLAPIENTRY dummy_glDisable(GLenum cap);
+    void GLAPIENTRY dummy_glDrawArrays(GLenum mode, GLint first, GLsizei count);
+    void GLAPIENTRY dummy_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+    void GLAPIENTRY dummy_glEnable(GLenum cap);
+    void GLAPIENTRY dummy_glFinish(void);
+    void GLAPIENTRY dummy_glFlush(void);
+    void GLAPIENTRY dummy_glFrontFace(GLenum mode);
+    void GLAPIENTRY dummy_glGenBuffers(GLsizei n, GLuint *buffers);
+    void GLAPIENTRY dummy_glGenTextures(GLsizei n, GLuint *textures);
+    void GLAPIENTRY dummy_glGetBooleanv(GLenum pname, GLboolean *params);
+    void GLAPIENTRY dummy_glGetBufferParameteriv(GLenum, GLenum, GLint *);
+    GLenum GLAPIENTRY dummy_glGetError(void);
+    void GLAPIENTRY dummy_glGetFloatv(GLenum pname, GLfloat *params);
+    void GLAPIENTRY dummy_glGetIntegerv(GLenum pname, GLint *params);
+    const GLubyte * GLAPIENTRY dummy_glGetString(GLenum name);
+    void GLAPIENTRY dummy_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params);
+    void GLAPIENTRY dummy_glGetTexParameteriv(GLenum target, GLenum pname, GLint *params);
+    void GLAPIENTRY dummy_glHint(GLenum target, GLenum mode);
+    GLboolean GLAPIENTRY dummy_glIsBuffer(GLuint);
+    GLboolean GLAPIENTRY dummy_glIsEnabled(GLenum cap);
+    GLboolean GLAPIENTRY dummy_glIsTexture(GLuint texture);
+    void GLAPIENTRY dummy_glLineWidth(GLfloat width);
+    void GLAPIENTRY dummy_glPolygonOffset(GLfloat factor, GLfloat units);
+    void GLAPIENTRY dummy_glPixelStorei(GLenum pname, GLint param);
+    void GLAPIENTRY dummy_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
+    void GLAPIENTRY dummy_glSampleCoverage(GLclampf value, GLboolean invert );
+    void GLAPIENTRY dummy_glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
+    void GLAPIENTRY dummy_glStencilFunc(GLenum func, GLint ref, GLuint mask);
+    void GLAPIENTRY dummy_glStencilMask(GLuint mask);
+    void GLAPIENTRY dummy_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass);
+    void GLAPIENTRY dummy_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+    void GLAPIENTRY dummy_glTexParameteri(GLenum target, GLenum pname, GLint param);
+    void GLAPIENTRY dummy_glTexParameteriv(GLenum target, GLenum pname, const GLint *params);
+    void GLAPIENTRY dummy_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+    void GLAPIENTRY dummy_glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
+    void GLAPIENTRY dummy_glPushAttrib( GLbitfield mask );
+    void GLAPIENTRY dummy_glPopAttrib( void );
+    void GLAPIENTRY dummy_glPushClientAttrib( GLbitfield mask );
+    void GLAPIENTRY dummy_glPopClientAttrib( void );
+
+    /* OpenGL functions which are needed ONLY for implementing GLES 1.1*/
+    void GLAPIENTRY dummy_glAlphaFunc(GLenum func, GLclampf ref);
+    void GLAPIENTRY dummy_glBegin( GLenum mode );
+    void GLAPIENTRY dummy_glClearDepth(GLclampd depth);
+    void GLAPIENTRY dummy_glClientActiveTexture( GLenum texture );
+    void GLAPIENTRY dummy_glClipPlane(GLenum plane, const GLdouble *equation);
+    void GLAPIENTRY dummy_glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
+    void GLAPIENTRY dummy_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+    void GLAPIENTRY dummy_glColor4fv( const GLfloat *v );
+    void GLAPIENTRY dummy_glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+    void GLAPIENTRY dummy_glColor4ubv( const GLubyte *v );
+    void GLAPIENTRY dummy_glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+    void GLAPIENTRY dummy_glDisableClientState(GLenum array);
+    void GLAPIENTRY dummy_glEnableClientState(GLenum array);
+    void GLAPIENTRY dummy_glEnd(void);
+    void GLAPIENTRY dummy_glFogf(GLenum pname, GLfloat param);
+    void GLAPIENTRY dummy_glFogfv(GLenum pname, const GLfloat *params);
+    void GLAPIENTRY dummy_glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+    void GLAPIENTRY dummy_glGetClipPlane(GLenum plane, GLdouble *equation);
+    void GLAPIENTRY dummy_glGetDoublev( GLenum pname, GLdouble *params );
+    void GLAPIENTRY dummy_glGetLightfv(GLenum light, GLenum pname, GLfloat *params);
+    void GLAPIENTRY dummy_glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params);
+    void GLAPIENTRY dummy_glGetPointerv(GLenum pname, GLvoid* *params);
+    void GLAPIENTRY dummy_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params);
+    void GLAPIENTRY dummy_glGetTexEnviv(GLenum target, GLenum pname, GLint *params);
+    void GLAPIENTRY dummy_glLightf(GLenum light, GLenum pname, GLfloat param);
+    void GLAPIENTRY dummy_glLightfv(GLenum light, GLenum pname, const GLfloat *params);
+    void GLAPIENTRY dummy_glLightModelf(GLenum pname, GLfloat param);
+    void GLAPIENTRY dummy_glLightModelfv(GLenum pname, const GLfloat *params);
+    void GLAPIENTRY dummy_glLoadIdentity(void);
+    void GLAPIENTRY dummy_glLoadMatrixf(const GLfloat *m);
+    void GLAPIENTRY dummy_glLogicOp(GLenum opcode);
+    void GLAPIENTRY dummy_glMaterialf(GLenum face, GLenum pname, GLfloat param);
+    void GLAPIENTRY dummy_glMaterialfv(GLenum face, GLenum pname, const GLfloat *params);
+    void GLAPIENTRY dummy_glMultiTexCoord2fv( GLenum target, const GLfloat *v );
+    void GLAPIENTRY dummy_glMultiTexCoord2sv( GLenum target, const GLshort *v );
+    void GLAPIENTRY dummy_glMultiTexCoord3fv( GLenum target, const GLfloat *v );
+    void GLAPIENTRY dummy_glMultiTexCoord3sv( GLenum target, const GLshort *v );
+    void GLAPIENTRY dummy_glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q );
+    void GLAPIENTRY dummy_glMultiTexCoord4fv( GLenum target, const GLfloat *v );
+    void GLAPIENTRY dummy_glMultiTexCoord4sv( GLenum target, const GLshort *v );
+    void GLAPIENTRY dummy_glMultMatrixf(const GLfloat *m);
+    void GLAPIENTRY dummy_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz);
+    void GLAPIENTRY dummy_glNormal3fv( const GLfloat *v );
+    void GLAPIENTRY dummy_glNormal3sv(const GLshort *v );
+    void GLAPIENTRY dummy_glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+    void GLAPIENTRY dummy_glPointParameterf(GLenum, GLfloat);
+    void GLAPIENTRY dummy_glPointParameterfv(GLenum, const GLfloat *);
+    void GLAPIENTRY dummy_glPointSize(GLfloat size);
+    void GLAPIENTRY dummy_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+    void GLAPIENTRY dummy_glScalef(GLfloat x, GLfloat y, GLfloat z);
+    void GLAPIENTRY dummy_glTexEnvf(GLenum target, GLenum pname, GLfloat param);
+    void GLAPIENTRY dummy_glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params);
+    void GLAPIENTRY dummy_glTexParameterf(GLenum target, GLenum pname, GLfloat param);
+    void GLAPIENTRY dummy_glTexParameterfv(GLenum target, GLenum pname, const GLfloat *params);
+    void GLAPIENTRY dummy_glMatrixMode(GLenum mode);
+    void GLAPIENTRY dummy_glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer);
+    void GLAPIENTRY dummy_glPopMatrix(void);
+    void GLAPIENTRY dummy_glPushMatrix(void);
+    void GLAPIENTRY dummy_glShadeModel(GLenum mode);
+    void GLAPIENTRY dummy_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+    void GLAPIENTRY dummy_glTexEnvi(GLenum target, GLenum pname, GLint param);
+    void GLAPIENTRY dummy_glTexEnviv(GLenum target, GLenum pname, const GLint *params);
+    void GLAPIENTRY dummy_glTranslatef(GLfloat x, GLfloat y, GLfloat z);
+    void GLAPIENTRY dummy_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+
+    /* OpenGL functions which are needed ONLY for implementing GLES 1.1 EXTENSIONS*/
+    GLboolean GLAPIENTRY dummy_glIsRenderbufferEXT(GLuint renderbuffer);
+    void GLAPIENTRY dummy_glBindRenderbufferEXT(GLenum target, GLuint renderbuffer);
+    void GLAPIENTRY dummy_glDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers);
+    void GLAPIENTRY dummy_glGenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers);
+    void GLAPIENTRY dummy_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+    void GLAPIENTRY dummy_glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params);
+    GLboolean GLAPIENTRY dummy_glIsFramebufferEXT(GLuint framebuffer);
+    void GLAPIENTRY dummy_glBindFramebufferEXT(GLenum target, GLuint framebuffer);
+    void GLAPIENTRY dummy_glDeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers);
+    void GLAPIENTRY dummy_glGenFramebuffersEXT(GLsizei n, GLuint *framebuffers);
+    GLenum GLAPIENTRY dummy_glCheckFramebufferStatusEXT(GLenum target);
+    void GLAPIENTRY dummy_glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+    void GLAPIENTRY dummy_glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+    void GLAPIENTRY dummy_glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+    void GLAPIENTRY dummy_glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+    void GLAPIENTRY dummy_glGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint *params);
+    void GLAPIENTRY dummy_glGenerateMipmapEXT(GLenum target);
+    void GLAPIENTRY dummy_glCurrentPaletteMatrixARB(GLint index);
+    void GLAPIENTRY dummy_glMatrixIndexuivARB(GLint size, GLuint * indices);
+    void GLAPIENTRY dummy_glMatrixIndexPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+    void GLAPIENTRY dummy_glWeightPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+    void GLAPIENTRY dummy_glTexGenf(GLenum coord, GLenum pname, GLfloat param );
+    void GLAPIENTRY dummy_glTexGeni(GLenum coord, GLenum pname, GLint param );
+    void GLAPIENTRY dummy_glTexGenf(GLenum coord, GLenum pname, const GLfloat *params );
+    void GLAPIENTRY dummy_glTexGeniv(GLenum coord, GLenum pname, const GLint *params );
+    void GLAPIENTRY dummy_glGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params );
+    void GLAPIENTRY dummy_glGetTexGeniv(GLenum coord, GLenum pname, GLint *params );
+
+    /* Loading OpenGL functions which are needed ONLY for implementing GLES 2.0*/
+    void GL_APIENTRY dummy_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+    void GL_APIENTRY dummy_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
+    void GL_APIENTRY dummy_glStencilMaskSeparate(GLenum face, GLuint mask);
+    void GL_APIENTRY dummy_glGenerateMipmap(GLenum target);
+    void GL_APIENTRY dummy_glBindFramebuffer(GLenum target, GLuint framebuffer);
+    void GL_APIENTRY dummy_glBindRenderbuffer(GLenum target, GLuint renderbuffer);
+    void GL_APIENTRY dummy_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers);
+    void GL_APIENTRY dummy_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers);
+    GLboolean GL_APIENTRY dummy_glIsProgram(GLuint program);
+    GLboolean GL_APIENTRY dummy_glIsShader(GLuint shader);
+    void GL_APIENTRY dummy_glVertexAttrib1f(GLuint indx, GLfloat x);
+    void GL_APIENTRY dummy_glVertexAttrib1fv(GLuint indx, const GLfloat* values);
+    void GL_APIENTRY dummy_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
+    void GL_APIENTRY dummy_glVertexAttrib2fv(GLuint indx, const GLfloat* values);
+    void GL_APIENTRY dummy_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+    void GL_APIENTRY dummy_glVertexAttrib3fv(GLuint indx, const GLfloat* values);
+    void GL_APIENTRY dummy_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+    void GL_APIENTRY dummy_glVertexAttrib4fv(GLuint indx, const GLfloat* values);
+    void GL_APIENTRY dummy_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
+    void GL_APIENTRY dummy_glDisableVertexAttribArray(GLuint index);
+    void GL_APIENTRY dummy_glEnableVertexAttribArray(GLuint index);
+    void GL_APIENTRY dummy_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params);
+    void GL_APIENTRY dummy_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params);
+    void GL_APIENTRY dummy_glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer);
+    void GL_APIENTRY dummy_glUniform1f(GLint location, GLfloat x);
+    void GL_APIENTRY dummy_glUniform1fv(GLint location, GLsizei count, const GLfloat* v);
+    void GL_APIENTRY dummy_glUniform1i(GLint location, GLint x);
+    void GL_APIENTRY dummy_glUniform1iv(GLint location, GLsizei count, const GLint* v);
+    void GL_APIENTRY dummy_glUniform2f(GLint location, GLfloat x, GLfloat y);
+    void GL_APIENTRY dummy_glUniform2fv(GLint location, GLsizei count, const GLfloat* v);
+    void GL_APIENTRY dummy_glUniform2i(GLint location, GLint x, GLint y);
+    void GL_APIENTRY dummy_glUniform2iv(GLint location, GLsizei count, const GLint* v);
+    void GL_APIENTRY dummy_glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z);
+    void GL_APIENTRY dummy_glUniform3fv(GLint location, GLsizei count, const GLfloat* v);
+    void GL_APIENTRY dummy_glUniform3i(GLint location, GLint x, GLint y, GLint z);
+    void GL_APIENTRY dummy_glUniform3iv(GLint location, GLsizei count, const GLint* v);
+    void GL_APIENTRY dummy_glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+    void GL_APIENTRY dummy_glUniform4fv(GLint location, GLsizei count, const GLfloat* v);
+    void GL_APIENTRY dummy_glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w);
+    void GL_APIENTRY dummy_glUniform4iv(GLint location, GLsizei count, const GLint* v);
+    void GL_APIENTRY dummy_glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+    void GL_APIENTRY dummy_glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+    void GL_APIENTRY dummy_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+    void GL_APIENTRY dummy_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params);
+    void GL_APIENTRY dummy_glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params);
+    GLboolean GL_APIENTRY dummy_glIsFramebuffer(GLuint framebuffer);
+    GLboolean GL_APIENTRY dummy_glIsRenderbuffer(GLuint renderbuffer);
+    GLenum GL_APIENTRY dummy_glCheckFramebufferStatus(GLenum target);
+    void GL_APIENTRY dummy_glAttachShader(GLuint program, GLuint shader);
+    void GL_APIENTRY dummy_glBindAttribLocation(GLuint program, GLuint index, const GLchar* name);
+    void GL_APIENTRY dummy_glCompileShader(GLuint shader);
+    GLuint GL_APIENTRY dummy_glCreateProgram(void);
+    GLuint GL_APIENTRY dummy_glCreateShader(GLenum type);
+    void GL_APIENTRY dummy_glDeleteProgram(GLuint program);
+    void GL_APIENTRY dummy_glDeleteShader(GLuint shader);
+    void GL_APIENTRY dummy_glDetachShader(GLuint program, GLuint shader);
+    void GL_APIENTRY dummy_glLinkProgram(GLuint program);
+    void GL_APIENTRY dummy_glUseProgram(GLuint program);
+    void GL_APIENTRY dummy_glValidateProgram(GLuint program);
+    void GL_APIENTRY dummy_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+    void GL_APIENTRY dummy_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+    void GL_APIENTRY dummy_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+    int  GL_APIENTRY dummy_glGetAttribLocation(GLuint program, const GLchar* name);
+    void GL_APIENTRY dummy_glGetProgramiv(GLuint program, GLenum pname, GLint* params);
+    void GL_APIENTRY dummy_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+    void GL_APIENTRY dummy_glGetShaderiv(GLuint shader, GLenum pname, GLint* params);
+    void GL_APIENTRY dummy_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+    void GL_APIENTRY dummy_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+    void GL_APIENTRY dummy_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
+    void GL_APIENTRY dummy_glGetUniformfv(GLuint program, GLint location, GLfloat* params);
+    void GL_APIENTRY dummy_glGetUniformiv(GLuint program, GLint location, GLint* params);
+    int  GL_APIENTRY dummy_glGetUniformLocation(GLuint program, const GLchar* name);
+    void GL_APIENTRY dummy_glReleaseShaderCompiler(void);
+    void GL_APIENTRY dummy_glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+    void GL_APIENTRY dummy_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
+    void GL_APIENTRY dummy_glShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
+    void GL_APIENTRY dummy_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+    void GL_APIENTRY dummy_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+
+#endif
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
new file mode 100644
index 0000000..f8c293a
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
@@ -0,0 +1,561 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <GLcommon/GLDispatch.h>
+#include <stdio.h>
+#include <OpenglOsUtils/osDynLibrary.h>
+
+#ifdef __linux__
+#include <GL/glx.h>
+#elif defined(WIN32)
+#include <windows.h>
+#endif
+
+#include "DummyGLfuncs.h"
+
+typedef void (*GL_FUNC_PTR)();
+
+static GL_FUNC_PTR getGLFuncAddress(const char *funcName) {
+    GL_FUNC_PTR ret = NULL;
+#ifdef __linux__
+    static osUtils::dynLibrary* libGL = osUtils::dynLibrary::open("libGL.so");
+    ret = (GL_FUNC_PTR)glXGetProcAddress((const GLubyte*)funcName);
+#elif defined(WIN32)
+    static osUtils::dynLibrary* libGL = osUtils::dynLibrary::open("opengl32");
+    ret = (GL_FUNC_PTR)wglGetProcAddress(funcName);
+#elif defined(__APPLE__)
+    static osUtils::dynLibrary* libGL = osUtils::dynLibrary::open("libGL.dylib");
+#endif
+    if(!ret && libGL){
+        ret = libGL->findSymbol(funcName);
+    }
+    return ret;
+}
+
+#define LOAD_GL_FUNC(name)  {   void * funcAddrs = NULL;                                    \
+                                if(name == NULL){                                           \
+                                    funcAddrs = (void *)getGLFuncAddress(#name);            \
+                                    if(funcAddrs){                                          \
+                                        *(void**)(&name) = funcAddrs;                       \
+                                    } else {                                                \
+                                        fprintf(stderr,"could not load func %s\n",#name);   \
+                                        *(void**)(&name) = (void *)dummy_##name;            \
+                                    }                                                       \
+                                }                                                           \
+                           }
+
+#define LOAD_GLEXT_FUNC(name)  {   void * funcAddrs = NULL;                                \
+                                if(name == NULL){                                       \
+                                funcAddrs = (void *)getGLFuncAddress(#name);            \
+                                if(funcAddrs)                                           \
+                                    *(void**)(&name) = funcAddrs;                       \
+                                }                                                       \
+                           }
+
+/* initializing static GLDispatch members*/
+
+android::Mutex GLDispatch::s_lock;
+void (GLAPIENTRY *GLDispatch::glActiveTexture)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glBindBuffer)(GLenum,GLuint) = NULL;
+void (GLAPIENTRY *GLDispatch::glBindTexture)(GLenum, GLuint) = NULL;
+void (GLAPIENTRY *GLDispatch::glBlendFunc)(GLenum,GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glBlendEquation)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glBlendEquationSeparate)(GLenum,GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glBlendFuncSeparate)(GLenum,GLenum,GLenum,GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glBufferData)(GLenum,GLsizeiptr,const GLvoid *,GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glBufferSubData)(GLenum,GLintptr,GLsizeiptr,const GLvoid *) = NULL;
+void (GLAPIENTRY *GLDispatch::glClear)(GLbitfield) = NULL;
+void (GLAPIENTRY *GLDispatch::glClearColor)(GLclampf,GLclampf,GLclampf,GLclampf) = NULL;
+void (GLAPIENTRY *GLDispatch::glClearStencil)(GLint) = NULL;
+void (GLAPIENTRY *GLDispatch::glColorMask)(GLboolean,GLboolean,GLboolean,GLboolean) = NULL;
+void (GLAPIENTRY *GLDispatch::glCompressedTexImage2D)(GLenum,GLint,GLenum,GLsizei,GLsizei,GLint,GLsizei, const GLvoid *) = NULL;
+void (GLAPIENTRY *GLDispatch::glCompressedTexSubImage2D)(GLenum,GLint,GLint,GLint,GLsizei,GLsizei,GLenum,GLsizei,const GLvoid *) = NULL;
+void (GLAPIENTRY *GLDispatch::glCopyTexImage2D)(GLenum,GLint,GLenum,GLint,GLint,GLsizei,GLsizei,GLint) = NULL;
+void (GLAPIENTRY *GLDispatch::glCopyTexSubImage2D)(GLenum,GLint,GLint,GLint,GLint,GLint,GLsizei,GLsizei) = NULL;
+void (GLAPIENTRY *GLDispatch::glCullFace)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glDeleteBuffers)(GLsizei,const GLuint *) = NULL;
+void (GLAPIENTRY *GLDispatch::glDeleteTextures)(GLsizei,const GLuint *) = NULL;
+void (GLAPIENTRY *GLDispatch::glDepthFunc)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glDepthMask)(GLboolean) = NULL;
+void (GLAPIENTRY *GLDispatch::glDepthRange)(GLclampd,GLclampd) = NULL;
+void (GLAPIENTRY *GLDispatch::glDisable)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glDrawArrays)(GLenum,GLint,GLsizei) = NULL;
+void (GLAPIENTRY *GLDispatch::glDrawElements)(GLenum,GLsizei,GLenum,const GLvoid *) = NULL;
+void (GLAPIENTRY *GLDispatch::glEnable)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glFinish)() = NULL;
+void (GLAPIENTRY *GLDispatch::glFlush)() = NULL;
+void (GLAPIENTRY *GLDispatch::glFrontFace)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glGenBuffers)(GLsizei,GLuint *) = NULL;
+void (GLAPIENTRY *GLDispatch::glGenTextures)(GLsizei,GLuint *) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetBooleanv)(GLenum,GLboolean *) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetBufferParameteriv)(GLenum, GLenum, GLint *) = NULL;
+GLenum (GLAPIENTRY *GLDispatch::glGetError)() = NULL;
+void (GLAPIENTRY *GLDispatch::glGetFloatv)(GLenum,GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetIntegerv)(GLenum,GLint *) = NULL;
+const GLubyte * (GLAPIENTRY *GLDispatch::glGetString) (GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetTexParameterfv)(GLenum,GLenum,GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetTexParameteriv)(GLenum,GLenum,GLint *) = NULL;
+void (GLAPIENTRY *GLDispatch::glHint)(GLenum,GLenum) = NULL;
+GLboolean (GLAPIENTRY *GLDispatch::glIsBuffer)(GLuint) = NULL;
+GLboolean (GLAPIENTRY *GLDispatch::glIsEnabled)(GLenum) = NULL;
+GLboolean (GLAPIENTRY *GLDispatch::glIsTexture)(GLuint) = NULL;
+void (GLAPIENTRY *GLDispatch::glLineWidth)(GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glPolygonOffset)(GLfloat, GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glPixelStorei)(GLenum,GLint) = NULL;
+void (GLAPIENTRY *GLDispatch::glReadPixels)(GLint,GLint,GLsizei,GLsizei,GLenum,GLenum,GLvoid *) = NULL;
+void (GLAPIENTRY *GLDispatch::glSampleCoverage)(GLclampf,GLboolean) = NULL;
+void (GLAPIENTRY *GLDispatch::glScissor)(GLint,GLint,GLsizei,GLsizei) = NULL;
+void (GLAPIENTRY *GLDispatch::glStencilFunc)(GLenum,GLint,GLuint) = NULL;
+void (GLAPIENTRY *GLDispatch::glStencilMask)(GLuint) = NULL;
+void (GLAPIENTRY *GLDispatch::glStencilOp)(GLenum, GLenum,GLenum);
+void (GLAPIENTRY *GLDispatch::glTexImage2D)(GLenum,GLint,GLint,GLsizei,GLsizei,GLint,GLenum,GLenum,const GLvoid *) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexParameterf)(GLenum,GLenum, GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexParameterfv)(GLenum,GLenum,const GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexParameteri)(GLenum,GLenum,GLint) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexParameteriv)(GLenum,GLenum,const GLint *) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexSubImage2D)(GLenum,GLint,GLint,GLint,GLsizei,GLsizei,GLenum,GLenum,const GLvoid *) = NULL;
+void (GLAPIENTRY *GLDispatch::glViewport)(GLint,GLint,GLsizei,GLsizei) = NULL;
+void (GLAPIENTRY *GLDispatch::glPushAttrib) ( GLbitfield mask ) = NULL;
+void (GLAPIENTRY *GLDispatch::glPopAttrib) ( void ) = NULL;
+void (GLAPIENTRY *GLDispatch::glPushClientAttrib) ( GLbitfield mask ) = NULL;
+void (GLAPIENTRY *GLDispatch::glPopClientAttrib) ( void ) = NULL;
+
+/*GLES 1.1*/
+void (GLAPIENTRY *GLDispatch::glAlphaFunc)(GLenum,GLclampf) = NULL;
+void (GLAPIENTRY *GLDispatch::glBegin)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glClearDepth)(GLclampd) = NULL;
+void (GLAPIENTRY *GLDispatch::glClientActiveTexture)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glClipPlane)(GLenum,const GLdouble *) = NULL;
+void (GLAPIENTRY *GLDispatch::glColor4d)(GLdouble,GLdouble,GLdouble,GLdouble) = NULL;
+void (GLAPIENTRY *GLDispatch::glColor4f)(GLfloat,GLfloat,GLfloat,GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glColor4fv)(const GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glColor4ub)(GLubyte,GLubyte,GLubyte,GLubyte) = NULL;
+void (GLAPIENTRY *GLDispatch::glColor4ubv)(const GLubyte *) = NULL;
+void (GLAPIENTRY *GLDispatch::glColorPointer)(GLint,GLenum,GLsizei,const GLvoid *) = NULL;
+void (GLAPIENTRY *GLDispatch::glDisableClientState)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glEnableClientState)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glEnd)() = NULL;
+void (GLAPIENTRY *GLDispatch::glFogf)(GLenum, GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glFogfv)(GLenum,const GLfloat *);
+void (GLAPIENTRY *GLDispatch::glFrustum)(GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetClipPlane)(GLenum,GLdouble *) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetDoublev)(GLenum,GLdouble *) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetLightfv)(GLenum,GLenum,GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetMaterialfv)(GLenum,GLenum,GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetPointerv)(GLenum,GLvoid**) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetTexEnvfv)(GLenum,GLenum,GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetTexEnviv)(GLenum,GLenum,GLint *)= NULL;
+void (GLAPIENTRY *GLDispatch::glLightf)(GLenum,GLenum,GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glLightfv)(GLenum,GLenum,const GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glLightModelf)(GLenum,GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glLightModelfv)(GLenum,const GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glLoadIdentity)() = NULL;
+void (GLAPIENTRY *GLDispatch::glLoadMatrixf)(const GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glLogicOp)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glMaterialf)(GLenum,GLenum,GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glMaterialfv)(GLenum,GLenum,const GLfloat *);
+void (GLAPIENTRY *GLDispatch::glMultiTexCoord2fv)(GLenum, const GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glMultiTexCoord2sv)(GLenum, const GLshort *) = NULL;
+void (GLAPIENTRY *GLDispatch::glMultiTexCoord3fv)(GLenum, const GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glMultiTexCoord3sv)(GLenum,const GLshort *) = NULL;
+void (GLAPIENTRY *GLDispatch::glMultiTexCoord4f)(GLenum,GLfloat,GLfloat,GLfloat,GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glMultiTexCoord4fv)(GLenum,const GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glMultiTexCoord4sv)(GLenum,const GLshort *) = NULL;
+void (GLAPIENTRY *GLDispatch::glMultMatrixf)(const GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glNormal3f)(GLfloat,GLfloat,GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glNormal3fv)(const GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glNormal3sv)(const GLshort *) = NULL;
+void (GLAPIENTRY *GLDispatch::glOrtho)(GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble) = NULL;
+void (GLAPIENTRY *GLDispatch::glPointParameterf)(GLenum, GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glPointParameterfv)(GLenum, const GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glPointSize)(GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glRotatef)(GLfloat,GLfloat,GLfloat,GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glScalef)(GLfloat,GLfloat,GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexEnvf)(GLenum,GLenum,GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexEnvfv)(GLenum,GLenum,const GLfloat *) = NULL;
+void (GLAPIENTRY *GLDispatch::glMatrixMode)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glNormalPointer)(GLenum,GLsizei,const GLvoid *) = NULL;
+void (GLAPIENTRY *GLDispatch::glPopMatrix)() = NULL;
+void (GLAPIENTRY *GLDispatch::glPushMatrix)() = NULL;
+void (GLAPIENTRY *GLDispatch::glShadeModel)(GLenum) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexCoordPointer)(GLint,GLenum, GLsizei, const GLvoid*) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexEnvi)(GLenum ,GLenum,GLint) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexEnviv)(GLenum, GLenum, const GLint *) = NULL;
+void (GLAPIENTRY *GLDispatch::glTranslatef)(GLfloat,GLfloat, GLfloat) = NULL;
+void (GLAPIENTRY *GLDispatch::glVertexPointer)(GLint,GLenum,GLsizei, const GLvoid *) = NULL;
+
+/* GLES 1.1 EXTENSIONS*/
+GLboolean (GLAPIENTRY *GLDispatch::glIsRenderbufferEXT) (GLuint renderbuffer) = NULL;
+void (GLAPIENTRY *GLDispatch::glBindRenderbufferEXT) (GLenum target, GLuint renderbuffer) = NULL;
+void (GLAPIENTRY *GLDispatch::glDeleteRenderbuffersEXT) (GLsizei n, const GLuint *renderbuffers) = NULL;
+void (GLAPIENTRY *GLDispatch::glGenRenderbuffersEXT) (GLsizei n, GLuint *renderbuffers) = NULL;
+void (GLAPIENTRY *GLDispatch::glRenderbufferStorageEXT) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetRenderbufferParameterivEXT) (GLenum target, GLenum pname, GLint *params) = NULL;
+GLboolean (GLAPIENTRY *GLDispatch::glIsFramebufferEXT) (GLuint framebuffer) = NULL;
+void (GLAPIENTRY *GLDispatch::glBindFramebufferEXT) (GLenum target, GLuint framebuffer) = NULL;
+void (GLAPIENTRY *GLDispatch::glDeleteFramebuffersEXT) (GLsizei n, const GLuint *framebuffers) = NULL;
+void (GLAPIENTRY *GLDispatch::glGenFramebuffersEXT) (GLsizei n, GLuint *framebuffers) = NULL;
+GLenum (GLAPIENTRY *GLDispatch::glCheckFramebufferStatusEXT) (GLenum target) = NULL;
+void (GLAPIENTRY *GLDispatch::glFramebufferTexture1DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL;
+void (GLAPIENTRY *GLDispatch::glFramebufferTexture2DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL;
+void (GLAPIENTRY *GLDispatch::glFramebufferTexture3DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) = NULL;
+void (GLAPIENTRY *GLDispatch::glFramebufferRenderbufferEXT) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetFramebufferAttachmentParameterivEXT) (GLenum target, GLenum attachment, GLenum pname, GLint *params) = NULL;
+void (GLAPIENTRY *GLDispatch::glGenerateMipmapEXT) (GLenum target) = NULL;
+void (GLAPIENTRY *GLDispatch::glCurrentPaletteMatrixARB) (GLint index) = NULL;
+void (GLAPIENTRY *GLDispatch::glMatrixIndexuivARB) (GLint size, GLuint * indices) = NULL;
+void (GLAPIENTRY *GLDispatch::glMatrixIndexPointerARB) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) = NULL;
+void (GLAPIENTRY *GLDispatch::glWeightPointerARB) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexGenf) (GLenum coord, GLenum pname, GLfloat param ) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexGeni) (GLenum coord, GLenum pname, GLint param ) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexGenfv) (GLenum coord, GLenum pname, const GLfloat *params ) = NULL;
+void (GLAPIENTRY *GLDispatch::glTexGeniv) (GLenum coord, GLenum pname, const GLint *params ) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetTexGenfv) (GLenum coord, GLenum pname, GLfloat *params ) = NULL;
+void (GLAPIENTRY *GLDispatch::glGetTexGeniv) (GLenum coord, GLenum pname, GLint *params ) = NULL;
+
+/* GLES 2.0*/
+void (GL_APIENTRY *GLDispatch::glBlendColor)(GLclampf,GLclampf,GLclampf,GLclampf) = NULL;
+void (GL_APIENTRY *GLDispatch::glStencilFuncSeparate)(GLenum,GLenum,GLint,GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glStencilMaskSeparate)(GLenum,GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glGenerateMipmap)(GLenum) = NULL;
+void (GL_APIENTRY *GLDispatch::glBindFramebuffer)(GLenum,GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glBindRenderbuffer)(GLenum,GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glDeleteFramebuffers)(GLsizei,const GLuint*) = NULL;
+void (GL_APIENTRY *GLDispatch::glDeleteRenderbuffers)(GLsizei,const GLuint*) = NULL;
+GLboolean (GL_APIENTRY *GLDispatch::glIsProgram)(GLuint program) = NULL;
+GLboolean (GL_APIENTRY *GLDispatch::glIsShader)(GLuint shader) = NULL;
+void (GL_APIENTRY *GLDispatch::glVertexAttrib1f)(GLuint,GLfloat) = NULL;
+void (GL_APIENTRY *GLDispatch::glVertexAttrib1fv)(GLuint,const GLfloat*) = NULL;
+void (GL_APIENTRY *GLDispatch::glVertexAttrib2f)(GLuint,GLfloat, GLfloat) = NULL;
+void (GL_APIENTRY *GLDispatch::glVertexAttrib2fv)(GLuint,const GLfloat*) = NULL;
+void (GL_APIENTRY *GLDispatch::glVertexAttrib3f)(GLuint,GLfloat, GLfloat,GLfloat) = NULL;
+void (GL_APIENTRY *GLDispatch::glVertexAttrib3fv)(GLuint,const GLfloat*) = NULL;
+void (GL_APIENTRY *GLDispatch::glVertexAttrib4f)(GLuint,GLfloat,GLfloat,GLfloat,GLfloat ) = NULL;
+void (GL_APIENTRY *GLDispatch::glVertexAttrib4fv)(GLuint,const GLfloat*) = NULL;
+void (GL_APIENTRY *GLDispatch::glVertexAttribPointer)(GLuint,GLint,GLenum,GLboolean,GLsizei,const GLvoid*) = NULL;
+void (GL_APIENTRY *GLDispatch::glDisableVertexAttribArray)(GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glEnableVertexAttribArray)(GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetVertexAttribfv)(GLuint,GLenum,GLfloat*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetVertexAttribiv)(GLuint,GLenum,GLint*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetVertexAttribPointerv)(GLuint,GLenum,GLvoid**) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform1f)(GLint,GLfloat) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform1fv)(GLint,GLsizei,const GLfloat*) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform1i)(GLint,GLint) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform1iv)(GLint,GLsizei,const GLint*) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform2f)(GLint,GLfloat,GLfloat) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform2fv)(GLint,GLsizei,const GLfloat*) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform2i)(GLint,GLint,GLint) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform2iv)(GLint ,GLsizei,const GLint*) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform3f)(GLint,GLfloat,GLfloat,GLfloat) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform3fv)(GLint,GLsizei,const GLfloat*) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform3i)(GLint,GLint,GLint,GLint) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform3iv)(GLint,GLsizei,const GLint*) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform4f)(GLint,GLfloat,GLfloat,GLfloat,GLfloat) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform4fv)(GLint,GLsizei,const GLfloat*) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform4i)(GLint,GLint,GLint,GLint,GLint) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniform4iv)(GLint,GLsizei,const GLint*) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniformMatrix2fv)(GLint,GLsizei,GLboolean,const GLfloat*) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniformMatrix3fv)(GLint,GLsizei,GLboolean,const GLfloat*) = NULL;
+void (GL_APIENTRY *GLDispatch::glUniformMatrix4fv)(GLint,GLsizei,GLboolean,const GLfloat*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetFramebufferAttachmentParameteriv)(GLenum,GLenum,GLenum,GLint*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetRenderbufferParameteriv)(GLenum,GLenum,GLint*) = NULL;
+GLboolean (GL_APIENTRY *GLDispatch::glIsFramebuffer)(GLuint) = NULL;
+GLboolean (GL_APIENTRY *GLDispatch::glIsRenderbuffer)(GLuint) = NULL;
+GLenum (GL_APIENTRY *GLDispatch::glCheckFramebufferStatus)(GLenum) = NULL;
+void (GL_APIENTRY *GLDispatch::glAttachShader)(GLuint,GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glBindAttribLocation)(GLuint,GLuint,const GLchar*) = NULL;
+void (GL_APIENTRY *GLDispatch::glCompileShader)(GLuint) = NULL;
+GLuint (GL_APIENTRY *GLDispatch::glCreateProgram)() = NULL;
+GLuint (GL_APIENTRY *GLDispatch::glCreateShader)(GLenum) = NULL;
+void (GL_APIENTRY *GLDispatch::glDeleteProgram)(GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glDeleteShader)(GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glDetachShader)(GLuint,GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glLinkProgram)(GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glUseProgram)(GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glValidateProgram)(GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetActiveAttrib)(GLuint,GLuint,GLsizei,GLsizei*,GLint*,GLenum*,GLchar*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetActiveUniform)(GLuint,GLuint,GLsizei,GLsizei*,GLint*,GLenum*,GLchar*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetAttachedShaders)(GLuint,GLsizei,GLsizei*,GLuint*) = NULL;
+int  (GL_APIENTRY *GLDispatch::glGetAttribLocation)(GLuint,const GLchar*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetProgramiv)(GLuint,GLenum,GLint*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetProgramInfoLog)(GLuint,GLsizei,GLsizei*,GLchar*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetShaderiv)(GLuint,GLenum,GLint*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetShaderInfoLog)(GLuint,GLsizei,GLsizei*,GLchar*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetShaderPrecisionFormat)(GLenum,GLenum,GLint*,GLint*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetShaderSource)(GLuint,GLsizei,GLsizei*,GLchar*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetUniformfv)(GLuint,GLint,GLfloat*) = NULL;
+void (GL_APIENTRY *GLDispatch::glGetUniformiv)(GLuint,GLint,GLint*) = NULL;
+int  (GL_APIENTRY *GLDispatch::glGetUniformLocation)(GLuint,const GLchar*) = NULL;
+void (GL_APIENTRY *GLDispatch::glReleaseShaderCompiler)() = NULL;
+void (GL_APIENTRY *GLDispatch::glRenderbufferStorage)(GLenum,GLenum,GLsizei,GLsizei) = NULL;
+void (GL_APIENTRY *GLDispatch::glShaderBinary)(GLsizei,const GLuint*,GLenum,const GLvoid*,GLsizei) = NULL;
+void (GL_APIENTRY *GLDispatch::glShaderSource)(GLuint,GLsizei,const GLchar**,const GLint*) = NULL;
+void (GL_APIENTRY *GLDispatch::glFramebufferRenderbuffer)(GLenum,GLenum,GLenum,GLuint) = NULL;
+void (GL_APIENTRY *GLDispatch::glFramebufferTexture2D)(GLenum,GLenum,GLenum,GLuint,GLint) = NULL;
+
+GLDispatch::GLDispatch():m_isLoaded(false){};
+
+
+void GLDispatch::dispatchFuncs(GLESVersion version){
+    android::Mutex::Autolock mutex(s_lock);
+    if(m_isLoaded)
+        return;
+
+    /* Loading OpenGL functions which are needed for implementing BOTH GLES 1.1 & GLES 2.0*/
+    LOAD_GL_FUNC(glActiveTexture);
+    LOAD_GL_FUNC(glBindBuffer);
+    LOAD_GL_FUNC(glBindTexture);
+    LOAD_GL_FUNC(glBlendFunc);
+    LOAD_GL_FUNC(glBlendEquation);
+    LOAD_GL_FUNC(glBlendEquationSeparate);
+    LOAD_GL_FUNC(glBlendFuncSeparate);
+    LOAD_GL_FUNC(glBufferData);
+    LOAD_GL_FUNC(glBufferSubData);
+    LOAD_GL_FUNC(glClear);
+    LOAD_GL_FUNC(glClearColor);
+    LOAD_GL_FUNC(glClearDepth);
+    LOAD_GL_FUNC(glClearStencil);
+    LOAD_GL_FUNC(glColorMask);
+    LOAD_GL_FUNC(glCompressedTexImage2D);
+    LOAD_GL_FUNC(glCompressedTexSubImage2D);
+    LOAD_GL_FUNC(glCopyTexImage2D);
+    LOAD_GL_FUNC(glCopyTexSubImage2D);
+    LOAD_GL_FUNC(glCullFace);
+    LOAD_GL_FUNC(glDeleteBuffers);
+    LOAD_GL_FUNC(glDeleteTextures);
+    LOAD_GL_FUNC(glDepthFunc);
+    LOAD_GL_FUNC(glDepthMask);
+    LOAD_GL_FUNC(glDepthRange);
+    LOAD_GL_FUNC(glDisable);
+    LOAD_GL_FUNC(glDrawArrays);
+    LOAD_GL_FUNC(glDrawElements);
+    LOAD_GL_FUNC(glEnable);
+    LOAD_GL_FUNC(glFinish);
+    LOAD_GL_FUNC(glFlush);
+    LOAD_GL_FUNC(glFrontFace);
+    LOAD_GL_FUNC(glGenBuffers);
+    LOAD_GL_FUNC(glGenTextures);
+    LOAD_GL_FUNC(glGetBooleanv);
+    LOAD_GL_FUNC(glGetBufferParameteriv);
+    LOAD_GL_FUNC(glGetError);
+    LOAD_GL_FUNC(glGetFloatv);
+    LOAD_GL_FUNC(glGetIntegerv);
+    LOAD_GL_FUNC(glGetString);
+    LOAD_GL_FUNC(glTexParameterf);
+    LOAD_GL_FUNC(glTexParameterfv);
+    LOAD_GL_FUNC(glGetTexParameterfv);
+    LOAD_GL_FUNC(glGetTexParameteriv);
+    LOAD_GL_FUNC(glHint);
+    LOAD_GL_FUNC(glIsBuffer);
+    LOAD_GL_FUNC(glIsEnabled);
+    LOAD_GL_FUNC(glIsTexture);
+    LOAD_GL_FUNC(glLineWidth);
+    LOAD_GL_FUNC(glPolygonOffset);
+    LOAD_GL_FUNC(glPixelStorei);
+    LOAD_GL_FUNC(glReadPixels);
+    LOAD_GL_FUNC(glSampleCoverage);
+    LOAD_GL_FUNC(glScissor);
+    LOAD_GL_FUNC(glStencilFunc);
+    LOAD_GL_FUNC(glStencilMask);
+    LOAD_GL_FUNC(glStencilOp);
+    LOAD_GL_FUNC(glTexImage2D);
+    LOAD_GL_FUNC(glTexParameteri);
+    LOAD_GL_FUNC(glTexParameteriv);
+    LOAD_GL_FUNC(glTexSubImage2D);
+    LOAD_GL_FUNC(glViewport);
+    LOAD_GL_FUNC(glPushAttrib);
+    LOAD_GL_FUNC(glPushClientAttrib);
+    LOAD_GL_FUNC(glPopAttrib);
+    LOAD_GL_FUNC(glPopClientAttrib);
+    
+    /* Loading OpenGL functions which are needed ONLY for implementing GLES 1.1*/
+    if(version == GLES_1_1){
+        LOAD_GL_FUNC(glAlphaFunc);
+        LOAD_GL_FUNC(glBegin);
+        LOAD_GL_FUNC(glClientActiveTexture);
+        LOAD_GL_FUNC(glClipPlane);
+        LOAD_GL_FUNC(glColor4d);
+        LOAD_GL_FUNC(glColor4f);
+        LOAD_GL_FUNC(glColor4fv);
+        LOAD_GL_FUNC(glColor4ub);
+        LOAD_GL_FUNC(glColor4ubv);
+        LOAD_GL_FUNC(glColorPointer);
+        LOAD_GL_FUNC(glDisableClientState);
+        LOAD_GL_FUNC(glEnableClientState);
+        LOAD_GL_FUNC(glEnd);
+        LOAD_GL_FUNC(glFogf);
+        LOAD_GL_FUNC(glFogfv);
+        LOAD_GL_FUNC(glFrustum);
+        LOAD_GL_FUNC(glGetClipPlane);
+        LOAD_GL_FUNC(glGetDoublev);
+        LOAD_GL_FUNC(glGetLightfv);
+        LOAD_GL_FUNC(glGetMaterialfv);
+        LOAD_GL_FUNC(glGetPointerv);
+        LOAD_GL_FUNC(glGetTexEnvfv);
+        LOAD_GL_FUNC(glGetTexEnviv);
+        LOAD_GL_FUNC(glLightf);
+        LOAD_GL_FUNC(glLightfv);
+        LOAD_GL_FUNC(glLightModelf);
+        LOAD_GL_FUNC(glLightModelfv);
+        LOAD_GL_FUNC(glLoadIdentity);
+        LOAD_GL_FUNC(glLoadMatrixf);
+        LOAD_GL_FUNC(glLogicOp);
+        LOAD_GL_FUNC(glMaterialf);
+        LOAD_GL_FUNC(glMaterialfv);
+        LOAD_GL_FUNC(glMultiTexCoord2fv);
+        LOAD_GL_FUNC(glMultiTexCoord2sv);
+        LOAD_GL_FUNC(glMultiTexCoord3fv);
+        LOAD_GL_FUNC(glMultiTexCoord3sv);
+        LOAD_GL_FUNC(glMultiTexCoord4fv);
+        LOAD_GL_FUNC(glMultiTexCoord4sv);
+        LOAD_GL_FUNC(glMultiTexCoord4f);
+        LOAD_GL_FUNC(glMultMatrixf);
+        LOAD_GL_FUNC(glNormal3f);
+        LOAD_GL_FUNC(glNormal3fv);
+        LOAD_GL_FUNC(glNormal3sv);
+        LOAD_GL_FUNC(glOrtho);
+        LOAD_GL_FUNC(glPointParameterf);
+        LOAD_GL_FUNC(glPointParameterfv);
+        LOAD_GL_FUNC(glPointSize);
+        LOAD_GL_FUNC(glRotatef);
+        LOAD_GL_FUNC(glScalef);
+        LOAD_GL_FUNC(glTexEnvf);
+        LOAD_GL_FUNC(glTexEnvfv);
+        LOAD_GL_FUNC(glMatrixMode);
+        LOAD_GL_FUNC(glNormalPointer);
+        LOAD_GL_FUNC(glPopMatrix);
+        LOAD_GL_FUNC(glPushMatrix);
+        LOAD_GL_FUNC(glShadeModel);
+        LOAD_GL_FUNC(glTexCoordPointer);
+        LOAD_GL_FUNC(glTexEnvi);
+        LOAD_GL_FUNC(glTexEnviv);
+        LOAD_GL_FUNC(glTranslatef);
+        LOAD_GL_FUNC(glVertexPointer);
+
+   	    LOAD_GLEXT_FUNC(glIsRenderbufferEXT);
+        LOAD_GLEXT_FUNC(glBindRenderbufferEXT);
+        LOAD_GLEXT_FUNC(glDeleteRenderbuffersEXT);
+        LOAD_GLEXT_FUNC(glGenRenderbuffersEXT);
+        LOAD_GLEXT_FUNC(glRenderbufferStorageEXT);
+        LOAD_GLEXT_FUNC(glGetRenderbufferParameterivEXT);
+        LOAD_GLEXT_FUNC(glIsFramebufferEXT);
+        LOAD_GLEXT_FUNC(glBindFramebufferEXT);
+        LOAD_GLEXT_FUNC(glDeleteFramebuffersEXT);
+        LOAD_GLEXT_FUNC(glGenFramebuffersEXT);
+        LOAD_GLEXT_FUNC(glCheckFramebufferStatusEXT);
+        LOAD_GLEXT_FUNC(glFramebufferTexture1DEXT);
+        LOAD_GLEXT_FUNC(glFramebufferTexture2DEXT);
+        LOAD_GLEXT_FUNC(glFramebufferTexture3DEXT);
+        LOAD_GLEXT_FUNC(glFramebufferRenderbufferEXT);
+        LOAD_GLEXT_FUNC(glGetFramebufferAttachmentParameterivEXT);
+        LOAD_GLEXT_FUNC(glGenerateMipmapEXT);
+        LOAD_GLEXT_FUNC(glCurrentPaletteMatrixARB);
+        LOAD_GLEXT_FUNC(glMatrixIndexuivARB);
+        LOAD_GLEXT_FUNC(glMatrixIndexPointerARB);
+        LOAD_GLEXT_FUNC(glWeightPointerARB);
+        LOAD_GLEXT_FUNC(glTexGenf);
+        LOAD_GLEXT_FUNC(glTexGeni);
+        LOAD_GLEXT_FUNC(glTexGenfv);
+        LOAD_GLEXT_FUNC(glTexGeniv);
+        LOAD_GLEXT_FUNC(glGetTexGenfv);
+        LOAD_GLEXT_FUNC(glGetTexGeniv);
+
+    } else if (version == GLES_2_0){
+
+    /* Loading OpenGL functions which are needed ONLY for implementing GLES 2.0*/
+
+        LOAD_GL_FUNC(glBlendColor);
+        LOAD_GL_FUNC(glBlendFuncSeparate);
+        LOAD_GL_FUNC(glStencilFuncSeparate);
+        LOAD_GL_FUNC(glGenerateMipmap);
+        LOAD_GL_FUNC(glBindFramebuffer);
+        LOAD_GL_FUNC(glBindRenderbuffer);
+        LOAD_GL_FUNC(glDeleteFramebuffers);
+        LOAD_GL_FUNC(glDeleteRenderbuffers);
+        LOAD_GL_FUNC(glIsProgram);
+        LOAD_GL_FUNC(glIsShader);
+        LOAD_GL_FUNC(glVertexAttrib1f);
+        LOAD_GL_FUNC(glVertexAttrib1fv);
+        LOAD_GL_FUNC(glVertexAttrib2f);
+        LOAD_GL_FUNC(glVertexAttrib2fv);
+        LOAD_GL_FUNC(glVertexAttrib3f);
+        LOAD_GL_FUNC(glVertexAttrib3fv);
+        LOAD_GL_FUNC(glVertexAttrib4f);
+        LOAD_GL_FUNC(glVertexAttrib4fv);
+        LOAD_GL_FUNC(glVertexAttribPointer);
+        LOAD_GL_FUNC(glDisableVertexAttribArray);
+        LOAD_GL_FUNC(glEnableVertexAttribArray);
+        LOAD_GL_FUNC(glGetVertexAttribfv);
+        LOAD_GL_FUNC(glGetVertexAttribiv);
+        LOAD_GL_FUNC(glGetVertexAttribPointerv);
+        LOAD_GL_FUNC(glIsFramebuffer);
+        LOAD_GL_FUNC(glIsRenderbuffer);
+        LOAD_GL_FUNC(glUniform1f);
+        LOAD_GL_FUNC(glUniform1fv);
+        LOAD_GL_FUNC(glUniform1i);
+        LOAD_GL_FUNC(glUniform1iv);
+        LOAD_GL_FUNC(glUniform2f);
+        LOAD_GL_FUNC(glUniform2fv);
+        LOAD_GL_FUNC(glUniform2i);
+        LOAD_GL_FUNC(glUniform2iv);
+        LOAD_GL_FUNC(glUniform3f);
+        LOAD_GL_FUNC(glUniform3fv);
+        LOAD_GL_FUNC(glUniform3i);
+        LOAD_GL_FUNC(glUniform3iv);
+        LOAD_GL_FUNC(glUniform4f);
+        LOAD_GL_FUNC(glUniform4fv);
+        LOAD_GL_FUNC(glUniform4i);
+        LOAD_GL_FUNC(glUniform4iv);
+        LOAD_GL_FUNC(glUniformMatrix2fv);
+        LOAD_GL_FUNC(glUniformMatrix3fv);
+        LOAD_GL_FUNC(glUniformMatrix4fv);
+        LOAD_GL_FUNC(glCheckFramebufferStatus);
+        LOAD_GL_FUNC(glGetFramebufferAttachmentParameteriv);
+        LOAD_GL_FUNC(glGetRenderbufferParameteriv);
+        LOAD_GL_FUNC(glAttachShader);
+        LOAD_GL_FUNC(glBindAttribLocation);
+        LOAD_GL_FUNC(glCompileShader);
+        LOAD_GL_FUNC(glCreateProgram);
+        LOAD_GL_FUNC(glCreateShader);
+        LOAD_GL_FUNC(glDeleteProgram);
+        LOAD_GL_FUNC(glDeleteShader);
+        LOAD_GL_FUNC(glDetachShader);
+        LOAD_GL_FUNC(glLinkProgram);
+        LOAD_GL_FUNC(glUseProgram);
+        LOAD_GL_FUNC(glValidateProgram);
+        LOAD_GL_FUNC(glGetActiveAttrib);
+        LOAD_GL_FUNC(glGetActiveUniform);
+        LOAD_GL_FUNC(glGetAttachedShaders);
+        LOAD_GL_FUNC(glGetAttribLocation);
+        LOAD_GL_FUNC(glGetProgramiv);
+        LOAD_GL_FUNC(glGetProgramInfoLog);
+        LOAD_GL_FUNC(glGetShaderiv);
+        LOAD_GL_FUNC(glGetShaderInfoLog);
+        LOAD_GL_FUNC(glGetShaderPrecisionFormat);
+        LOAD_GL_FUNC(glGetShaderSource);
+        LOAD_GL_FUNC(glGetUniformfv);
+        LOAD_GL_FUNC(glGetUniformiv);
+        LOAD_GL_FUNC(glGetUniformLocation);
+        LOAD_GL_FUNC(glReleaseShaderCompiler);
+        LOAD_GL_FUNC(glRenderbufferStorage);
+        LOAD_GL_FUNC(glShaderBinary);
+        LOAD_GL_FUNC(glShaderSource);
+        LOAD_GL_FUNC(glStencilMaskSeparate);
+        LOAD_GL_FUNC(glFramebufferRenderbuffer);
+        LOAD_GL_FUNC(glFramebufferTexture2D);
+    }
+    m_isLoaded = true;
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESbuffer.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESbuffer.cpp
similarity index 97%
rename from tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESbuffer.cpp
rename to tools/emulator/opengl/host/libs/Translator/GLcommon/GLESbuffer.cpp
index 531e79d..b055cc7 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESbuffer.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESbuffer.cpp
@@ -13,7 +13,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-#include "GLESbuffer.h"
+#include <GLcommon/GLESbuffer.h>
 #include <string.h>
 
 bool  GLESbuffer::setBuffer(GLuint size,GLuint usage,const GLvoid* data) {
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScontext.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
similarity index 63%
rename from tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScontext.cpp
rename to tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
index d1d76ef..93818fe 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScontext.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
@@ -1,35 +1,12 @@
-/*
-* Copyright (C) 2011 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include "GLEScontext.h"
-#include "GLESutils.h"
-#include "GLfixed_ops.h"
-#include "RangeManip.h"
-#include <GLcommon/GLutils.h>
-#include <string.h>
+#include <GLcommon/GLEScontext.h>
+#include <GLcommon/GLfixed_ops.h>
 #include <GLES/gl.h>
+#include <GLES/glext.h>
 
-//declerations
+//decleration
+static int findMaxIndex(GLsizei count,GLenum type,const GLvoid* indices);
 static void convertDirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,unsigned int nBytes,unsigned int strideOut,int attribSize);
 static void convertIndirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,GLsizei count,GLenum indices_type,const GLvoid* indices,unsigned int strideOut,int attribSize);
-static int findMaxIndex(GLsizei count,GLenum type,const GLvoid* indices);
-
-
-GLDispatch     GLEScontext::s_glDispatch;
-GLsupport      GLEScontext::s_glSupport;
-android::Mutex GLEScontext::s_lock;
 
 GLESFloatArrays::~GLESFloatArrays() {
     for(std::map<GLenum,GLfloat*>::iterator it = arrays.begin(); it != arrays.end();it++) {
@@ -40,44 +17,62 @@
     }
 }
 
-GLEScontext::~GLEScontext() {
-    for(ArraysMap::iterator it = m_map.begin(); it != m_map.end();it++) {
-        GLESpointer* p = (*it).second;
-        if(p) {
-            delete[] p;
+GLDispatch     GLEScontext::s_glDispatch;
+android::Mutex GLEScontext::s_lock;
+std::string*   GLEScontext::s_glExtensions= NULL;
+GLSupport      GLEScontext::s_glSupport;
+
+Version::Version():m_major(0),
+                   m_minor(0),
+                   m_release(0){};
+
+Version::Version(int major,int minor,int release):m_major(major),
+                                                  m_minor(minor),
+                                                  m_release(release){};
+
+Version::Version(const Version& ver):m_major(ver.m_major),
+                                     m_minor(ver.m_minor),
+                                     m_release(ver.m_release){}
+
+Version::Version(const char* versionString){
+    m_release = 0;
+    if((!versionString) || 
+      ((!(sscanf(versionString,"%d.%d"   ,&m_major,&m_minor) == 2)) && 
+       (!(sscanf(versionString,"%d.%d.%d",&m_major,&m_minor,&m_release) == 3)))){
+        m_major = m_minor = 0; // the version is not in the right format 
+    }
+}
+
+Version& Version::operator=(const Version& ver){
+    m_major   = ver.m_major;
+    m_minor   = ver.m_minor;
+    m_release = ver.m_release;
+    return *this;
+}
+
+bool Version::operator<(const Version& ver) const{
+    if(m_major < ver.m_major) return true;
+    if(m_major == ver.m_major){
+        if(m_minor < ver.m_minor) return true;
+        if(m_minor == ver.m_minor){
+           return m_release < ver.m_release;
         }
     }
+    return false;
 }
 
-void GLEScontext::init() {
-    android::Mutex::Autolock mutex(s_lock);
-    if(!m_initialized) {
-        int maxTexUnits;
-        s_glDispatch.dispatchFuncs();
-        s_glDispatch.glGetIntegerv(GL_MAX_CLIP_PLANES,&s_glSupport.maxClipPlane);
-        s_glDispatch.glGetIntegerv(GL_MAX_LIGHTS,&s_glSupport.maxLights);
-        s_glDispatch.glGetIntegerv(GL_MAX_TEXTURE_SIZE,&s_glSupport.maxTexSize);
-        s_glDispatch.glGetIntegerv(GL_MAX_TEXTURE_UNITS,&maxTexUnits);
-        s_glSupport.maxTexUnits = maxTexUnits < MAX_TEX_UNITS ? maxTexUnits:MAX_TEX_UNITS;
-    }
-
-    m_texCoords = new GLESpointer[s_glSupport.maxTexUnits];
-    m_map[GL_TEXTURE_COORD_ARRAY]  = &m_texCoords[m_activeTexture];
-    m_initialized = true;
-}
-
-GLEScontext::GLEScontext():m_glError(GL_NO_ERROR),m_activeTexture(0),m_arrayBuffer(0),m_elementBuffer(0),m_pointsIndex(-1),m_initialized(false) {
-
-
-    m_map[GL_COLOR_ARRAY]          = new GLESpointer();
-    m_map[GL_NORMAL_ARRAY]         = new GLESpointer();
-    m_map[GL_VERTEX_ARRAY]         = new GLESpointer();
-    m_map[GL_POINT_SIZE_ARRAY_OES] = new GLESpointer();
-}
-
-GLDispatch& GLEScontext::dispatcher() {
-    return s_glDispatch;
-}
+GLEScontext::GLEScontext():
+                           m_initialized(false)    ,
+                           m_activeTexture(0)      ,
+                           m_glError(GL_NO_ERROR)  ,
+                           m_arrayBuffer(0)        ,
+                           m_elementBuffer(0) {
+    for (int i=0;i<MAX_TEX_UNITS;++i) {
+        m_tex2DBind[i].texture = 0;
+        for (int j=0;j<NUM_TEXTURE_TARGETS;++j)
+            m_tex2DBind[i].enabled[j] = GL_FALSE;
+    }  
+};
 
 GLenum GLEScontext::getGLerror() {
     return m_glError;
@@ -89,22 +84,29 @@
 
 void GLEScontext::setActiveTexture(GLenum tex) {
    m_activeTexture = tex - GL_TEXTURE0;
-   m_map[GL_TEXTURE_COORD_ARRAY] = &m_texCoords[m_activeTexture];
 }
 
-const GLvoid* GLEScontext::setPointer(GLenum arrType,GLint size,GLenum type,GLsizei stride,const GLvoid* data) {
+GLEScontext::~GLEScontext() {
+    for(ArraysMap::iterator it = m_map.begin(); it != m_map.end();it++) {
+        GLESpointer* p = (*it).second;
+        if(p) {
+            delete p;
+        }
+    }
+}
+
+const GLvoid* GLEScontext::setPointer(GLenum arrType,GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize) {
     GLuint bufferName = m_arrayBuffer;
     if(bufferName) {
         unsigned int offset = reinterpret_cast<unsigned int>(data);
         GLESbuffer* vbo = static_cast<GLESbuffer*>(m_shareGroup->getObjectData(VERTEXBUFFER,bufferName).Ptr());
-        m_map[arrType]->setBuffer(size,type,stride,vbo,offset);
+        m_map[arrType]->setBuffer(size,type,stride,vbo,offset,normalize);
         return  static_cast<const unsigned char*>(vbo->getData()) +  offset;
     }
-    m_map[arrType]->setArray(size,type,stride,data);
+    m_map[arrType]->setArray(size,type,stride,data,normalize);
     return data;
 }
 
-
 void GLEScontext::enableArr(GLenum arr,bool enable) {
     m_map[arr]->enable(enable);
 }
@@ -114,29 +116,19 @@
 }
 
 const GLESpointer* GLEScontext::getPointer(GLenum arrType) {
-    if(m_map.find(arrType) != m_map.end()) return m_map[arrType];
-    return NULL;
-}
+    GLenum type =
+        arrType == GL_VERTEX_ARRAY_POINTER          ? GL_VERTEX_ARRAY :
+        arrType == GL_NORMAL_ARRAY_POINTER          ? GL_NORMAL_ARRAY :
+        arrType == GL_TEXTURE_COORD_ARRAY_POINTER   ? GL_TEXTURE_COORD_ARRAY :
+        arrType == GL_COLOR_ARRAY_POINTER           ? GL_COLOR_ARRAY :
+        arrType == GL_POINT_SIZE_ARRAY_POINTER_OES  ? GL_POINT_SIZE_ARRAY_OES :
+        0;
 
-//sending data to server side
-void GLEScontext::sendArr(GLvoid* arr,GLenum arrayType,GLint size,GLsizei stride,int index) {
-    switch(arrayType) {
-        case GL_VERTEX_ARRAY:
-            s_glDispatch.glVertexPointer(size,GL_FLOAT,stride,arr);
-            break;
-        case GL_NORMAL_ARRAY:
-            s_glDispatch.glNormalPointer(GL_FLOAT,stride,arr);
-            break;
-        case GL_TEXTURE_COORD_ARRAY:
-            s_glDispatch.glTexCoordPointer(size,GL_FLOAT,stride,arr);
-            break;
-        case GL_COLOR_ARRAY:
-            s_glDispatch.glColorPointer(size,GL_FLOAT,stride,arr);
-            break;
-        case GL_POINT_SIZE_ARRAY_OES:
-            m_pointsIndex = index;
-            break;
+    if(type != 0 && m_map.find(type) != m_map.end())
+    {
+        return m_map[type];
     }
+    return NULL;
 }
 
 static void convertDirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,unsigned int nBytes,unsigned int strideOut,int attribSize) {
@@ -208,7 +200,6 @@
     }
     return n;
 }
-
 void GLEScontext::convertDirect(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum array_id,GLESpointer* p,unsigned int& index) {
     GLenum type    = p->getType();
     if(isArrEnabled(array_id) && type == GL_FIXED) {
@@ -251,6 +242,23 @@
     }
 }
 
+static int findMaxIndex(GLsizei count,GLenum type,const GLvoid* indices) {
+    //finding max index
+    int max = 0;
+    if(type == GL_UNSIGNED_BYTE) {
+        GLubyte*  b_indices  =(GLubyte *)indices;
+        for(int i=0;i<count;i++) {
+            if(b_indices[i] > max) max = b_indices[i];
+        }
+    } else {
+        GLushort* us_indices =(GLushort *)indices;
+        for(int i=0;i<count;i++) {
+            if(us_indices[i] > max) max = us_indices[i];
+        }
+    }
+    return max;
+}
+
 void GLEScontext::convertIndirect(GLESFloatArrays& fArrs,GLsizei count,GLenum indices_type,const GLvoid* indices,GLenum array_id,GLESpointer* p,unsigned int& index_out) {
     GLenum type    = p->getType();
     int maxElements = findMaxIndex(count,type,indices) + 1;
@@ -310,140 +318,6 @@
     }
 }
 
-void GLEScontext::convertArrs(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct) {
-    ArraysMap::iterator it;
-    unsigned int index = 0;
-    m_pointsIndex = -1;
-
-    //going over all clients arrays Pointers
-    for ( it=m_map.begin() ; it != m_map.end(); it++ ) {
-        GLenum array_id   = (*it).first;
-        GLESpointer* p = (*it).second;
-
-        if(array_id == GL_TEXTURE_COORD_ARRAY) continue; //handling textures later
-        chooseConvertMethod(fArrs,first,count,type,indices,direct,p,array_id,index);
-    }
-
-    unsigned int activeTexture = m_activeTexture + GL_TEXTURE0;
-
-    s_lock.lock();
-    int maxTexUnits = s_glSupport.maxTexUnits;
-    s_lock.unlock();
-
-    //converting all texture coords arrays
-    for(int i=0; i< maxTexUnits;i++) {
-
-        unsigned int tex = GL_TEXTURE0+i;
-        setActiveTexture(tex);
-        s_glDispatch.glClientActiveTexture(tex);
-
-        GLenum array_id   = GL_TEXTURE_COORD_ARRAY;
-        GLESpointer* p = m_map[array_id];
-        chooseConvertMethod(fArrs,first,count,type,indices,direct,p,array_id,index);
-    }
-
-    setActiveTexture(activeTexture);
-    s_glDispatch.glClientActiveTexture(activeTexture);
-}
-
-
-static int findMaxIndex(GLsizei count,GLenum type,const GLvoid* indices) {
-    //finding max index
-    int max = 0;
-    if(type == GL_UNSIGNED_BYTE) {
-        GLubyte*  b_indices  =(GLubyte *)indices;
-        for(int i=0;i<count;i++) {
-            if(b_indices[i] > max) max = b_indices[i];
-        }
-    } else {
-        GLushort* us_indices =(GLushort *)indices;
-        for(int i=0;i<count;i++) {
-            if(us_indices[i] > max) max = us_indices[i];
-        }
-    }
-    return max;
-}
-
-//TODO change it into merge sort to work in O(nlogn)
-void sortPoints(GLfloat* sortedPoints,GLushort* sortedIndices,int size) {
-
-    int flag = 1;    // set flag to 1 to start first pass
-    for(int i = 1; (i <= size) && flag; i++) {
-        flag = 0;
-        for (int j=0; j < (size -1); j++) {
-            if (sortedPoints[j+1] < sortedPoints[j]) {
-                swap<GLfloat>(sortedPoints[j],sortedPoints[j+1]);
-                swap<GLushort>(sortedIndices[j],sortedIndices[j+1]);
-                flag = 1;               // indicates that a swap occurred.
-            }
-        }
-    }
-}
-
-
-void GLEScontext::drawPoints(PointSizeIndices* points) {
-
-    GLushort* indices = NULL;
-    int last_size = 0;
-
-    //drawing each group of vertices by the points size
-    for(PointSizeIndices::iterator it = points->begin();it != points->end(); it++) {
-            int count = (*it).second.size();
-            int pointSize = (*it).first;
-            std::vector<int>& arr = (*it).second;
-
-            if(count > last_size) {
-             if(indices) delete [] indices;
-             indices = new GLushort[count];
-            }
-            int i = 0 ;
-            for(std::vector<int>::iterator it2 = arr.begin();it2 != arr.end();it2++) {
-                indices[i++] = (*it2);
-            }
-            s_glDispatch.glPointSize(pointSize);
-            s_glDispatch.glDrawElements(GL_POINTS,count,GL_UNSIGNED_SHORT,indices);
-    }
-    if(indices) delete [] indices;
-}
-
-void  GLEScontext::drawPointsData(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices_in,bool isElemsDraw) {
-    const GLfloat  *pointsArr =  NULL;
-    int stride = 0; //steps in GLfloats
-
-    //choosing the right points sizes array source
-    if(m_pointsIndex >= 0) { //point size array was converted
-        pointsArr=fArrs.arrays[m_pointsIndex];
-        stride = 1;
-    } else {
-        GLESpointer* p = m_map[GL_POINT_SIZE_ARRAY_OES];
-        pointsArr = static_cast<const GLfloat*>(isBindedBuffer(GL_ARRAY_BUFFER)?p->getBufferData():p->getArrayData());
-        stride = p->getStride()?p->getStride()/sizeof(GLfloat):1;
-    }
-
-    //filling  arrays before sorting them
-    PointSizeIndices  points;
-    if(isElemsDraw) {
-        for(int i=0; i< count; i++) {
-            GLushort index = (type == GL_UNSIGNED_SHORT?
-                    static_cast<const GLushort*>(indices_in)[i]:
-                    static_cast<const GLubyte*>(indices_in)[i]);
-            points[pointsArr[index*stride]].push_back(index);
-        }
-    } else {
-        for(int i=0; i< count; i++) {
-            points[pointsArr[first+i*stride]].push_back(i+first);
-        }
-    }
-    drawPoints(&points);
-}
-
-void  GLEScontext::drawPointsArrs(GLESFloatArrays& arrs,GLint first,GLsizei count) {
-    drawPointsData(arrs,first,count,0,NULL,false);
-}
-
-void GLEScontext::drawPointsElems(GLESFloatArrays& arrs,GLsizei count,GLenum type,const GLvoid* indices_in) {
-    drawPointsData(arrs,0,count,type,indices_in,true);
-}
 
 void GLEScontext::bindBuffer(GLenum target,GLuint buffer) {
     if(target == GL_ARRAY_BUFFER) {
@@ -453,6 +327,17 @@
     }
 }
 
+void GLEScontext::unbindBuffer(GLuint buffer) {
+    if(m_arrayBuffer == buffer)
+    {
+        m_arrayBuffer = 0;
+    }
+    if(m_elementBuffer == buffer)
+    {
+        m_elementBuffer = 0;
+    }
+}
+
 //checks if any buffer is binded to target
 bool GLEScontext::isBindedBuffer(GLenum target) {
     if(target == GL_ARRAY_BUFFER) {
@@ -500,3 +385,77 @@
     GLESbuffer* vbo = static_cast<GLESbuffer*>(m_shareGroup->getObjectData(VERTEXBUFFER,bufferName).Ptr());
     return vbo->setSubBuffer(offset,size,data);
 }
+
+const char * GLEScontext::getExtensionString() { 
+    const char * ret;
+    s_lock.lock();
+    if (s_glExtensions)
+        ret = s_glExtensions->c_str();
+    else 
+        ret="";
+    s_lock.unlock();
+    return ret;
+}
+
+void GLEScontext::getGlobalLock() {
+    s_lock.lock();
+}
+
+void GLEScontext::releaseGlobalLock() {
+    s_lock.unlock();
+}
+
+
+void GLEScontext::initCapsLocked(const GLubyte * extensionString)
+{
+    int maxTexUnits;
+    const char* cstring = (const char*)extensionString; 
+
+    s_glDispatch.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS,&s_glSupport.maxVertexAttribs);
+    s_glDispatch.glGetIntegerv(GL_MAX_CLIP_PLANES,&s_glSupport.maxClipPlane);
+    s_glDispatch.glGetIntegerv(GL_MAX_LIGHTS,&s_glSupport.maxLights);
+    s_glDispatch.glGetIntegerv(GL_MAX_TEXTURE_SIZE,&s_glSupport.maxTexSize);
+    s_glDispatch.glGetIntegerv(GL_MAX_TEXTURE_UNITS,&maxTexUnits);
+    s_glSupport.maxTexUnits = maxTexUnits < MAX_TEX_UNITS ? maxTexUnits:MAX_TEX_UNITS;
+    const GLubyte* glslVersion = s_glDispatch.glGetString(GL_SHADING_LANGUAGE_VERSION);
+    s_glSupport.glslVersion = Version((const  char*)(glslVersion));
+
+    if (strstr(cstring,"GL_EXT_bgra ")!=NULL)
+        s_glSupport.GL_EXT_TEXTURE_FORMAT_BGRA8888 = true;
+
+    if (strstr(cstring,"GL_EXT_framebuffer_object ")!=NULL)
+        s_glSupport.GL_EXT_FRAMEBUFFER_OBJECT = true;
+
+    if (strstr(cstring,"GL_ARB_vertex_blend ")!=NULL)
+        s_glSupport.GL_ARB_VERTEX_BLEND = true;
+
+    if (strstr(cstring,"GL_ARB_matrix_palette ")!=NULL)
+        s_glSupport.GL_ARB_MATRIX_PALETTE = true;
+
+    if (strstr(cstring,"GL_NV_packed_depth_stencil ")!=NULL)
+        s_glSupport.GL_NV_PACKED_DEPTH_STENCIL = true;
+
+    if (strstr(cstring,"GL_OES_read_format ")!=NULL)
+        s_glSupport.GL_OES_READ_FORMAT = true;
+
+    if (strstr(cstring,"GL_ARB_half_float_pixel ")!=NULL)
+        s_glSupport.GL_ARB_HALF_FLOAT_PIXEL = true;
+
+    if (strstr(cstring,"GL_NV_half_float ")!=NULL)
+        s_glSupport.GL_NV_HALF_FLOAT = true;
+
+    if (strstr(cstring,"GL_ARB_half_float_vertex ")!=NULL)
+        s_glSupport.GL_ARB_HALF_FLOAT_VERTEX = true;
+
+    //init extension string
+    s_glExtensions = new std::string("");
+}
+
+bool GLEScontext::isTextureUnitEnabled(GLenum unit) {
+    for (int i=0;i<NUM_TEXTURE_TARGETS;++i) {
+        if (m_tex2DBind[unit-GL_TEXTURE0].enabled[i])
+            return true;
+    }
+    return false;
+}
+
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESpointer.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESpointer.cpp
similarity index 74%
rename from tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESpointer.cpp
rename to tools/emulator/opengl/host/libs/Translator/GLcommon/GLESpointer.cpp
index 55b4dcd..d297a7c 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESpointer.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESpointer.cpp
@@ -13,10 +13,17 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-#include "GLESpointer.h"
+#include <GLcommon/GLESpointer.h>
 #include <stdlib.h>
 
-GLESpointer::GLESpointer():m_size(0),m_type(0),m_stride(0),m_enabled(false),m_data(NULL),m_buffer(NULL),m_buffOffset(0){};
+GLESpointer::GLESpointer():m_size(0),
+                           m_type(0),
+                           m_stride(0),
+                           m_enabled(false),
+                           m_normalize(false),
+                           m_data(NULL),
+                           m_buffer(NULL),
+                           m_buffOffset(0){};
 
 
 GLenum GLESpointer:: getType() const {
@@ -49,25 +56,31 @@
     return m_enabled;
 }
 
+bool GLESpointer::isNormalize() const {
+    return m_normalize;
+}
+
 void GLESpointer::enable(bool b) {
     m_enabled = b;
 }
 
-void GLESpointer::setArray(GLint size,GLenum type,GLsizei stride,const GLvoid* data) {
+void GLESpointer::setArray(GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize) {
     m_size   = size;
     m_type   = type;
     m_stride = stride;
     m_data   = data;
     m_buffer = NULL;
+    m_normalize = normalize;
 }
 
-void GLESpointer::setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer* buf,int offset) {
+void GLESpointer::setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer* buf,int offset,bool normalize) {
     m_size   = size;
     m_type   = type;
     m_stride = stride;
     m_data   = NULL;
     m_buffer = buf;
     m_buffOffset = offset;
+    m_normalize = normalize;
 }
 
 void GLESpointer::getBufferConversions(const RangeList& rl,RangeList& rlOut) {
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp
new file mode 100644
index 0000000..2b487e9
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp
@@ -0,0 +1,160 @@
+#include<GLcommon/GLESvalidate.h>
+#include<GLES/gl.h>
+#include<GLES/glext.h>
+#include<GLES2/gl2.h>
+#include<GLES2/gl2ext.h>
+
+
+bool  GLESvalidate::textureEnum(GLenum e,unsigned int maxTex) {
+    return e >= GL_TEXTURE0 && e <= (GL_TEXTURE0 + maxTex);
+}
+
+bool GLESvalidate::pixelType(GLEScontext * ctx, GLenum type) {
+    if ((ctx && ctx->getCaps()->GL_NV_PACKED_DEPTH_STENCIL) &&
+       (type == GL_UNSIGNED_INT_24_8_OES) )
+        return true;
+
+    if (ctx && 
+       (ctx->getCaps()->GL_ARB_HALF_FLOAT_PIXEL || ctx->getCaps()->GL_NV_HALF_FLOAT) &&
+       (type == GL_HALF_FLOAT_OES))
+        return true;
+
+    switch(type) {
+    case GL_UNSIGNED_BYTE:
+    case GL_UNSIGNED_SHORT_5_6_5:
+    case GL_UNSIGNED_SHORT_4_4_4_4:
+    case GL_UNSIGNED_SHORT_5_5_5_1:
+    case GL_FLOAT:
+        return true;
+    }
+    return false;
+}
+
+bool GLESvalidate::pixelOp(GLenum format,GLenum type) {
+     switch(type) {
+     case GL_UNSIGNED_SHORT_4_4_4_4:
+     case GL_UNSIGNED_SHORT_5_5_5_1:
+         return format == GL_RGBA;
+     case GL_UNSIGNED_SHORT_5_6_5:
+         return format == GL_RGB;
+     }
+     return true;
+}
+
+bool GLESvalidate::pixelFrmt(GLEScontext* ctx ,GLenum format) {
+    if (ctx && ctx->getCaps()->GL_EXT_TEXTURE_FORMAT_BGRA8888 && format == GL_BGRA_EXT)
+      return true;
+    if (ctx && ctx->getCaps()->GL_NV_PACKED_DEPTH_STENCIL && format == GL_DEPTH_STENCIL_OES)
+      return true;
+    switch(format) {
+    case GL_ALPHA:
+    case GL_RGB:
+    case GL_RGBA:
+    case GL_LUMINANCE:
+    case GL_LUMINANCE_ALPHA:
+        return true;
+    }
+    return false;
+}
+
+bool GLESvalidate::bufferTarget(GLenum target) {
+    return target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER;
+}
+
+bool GLESvalidate::bufferParam(GLenum param) {
+ return  (param == GL_BUFFER_SIZE) || (param == GL_BUFFER_USAGE);
+}
+
+bool GLESvalidate::drawMode(GLenum mode) {
+    switch(mode) {
+    case GL_POINTS:
+    case GL_LINE_STRIP:
+    case GL_LINE_LOOP:
+    case GL_LINES:
+    case GL_TRIANGLE_STRIP:
+    case GL_TRIANGLE_FAN:
+    case GL_TRIANGLES:
+        return true;
+    }
+    return false;
+}
+
+bool GLESvalidate::drawType(GLenum mode) {
+    return  mode == GL_UNSIGNED_BYTE || 
+            mode == GL_UNSIGNED_SHORT || 
+            mode == GL_UNSIGNED_INT;
+}
+
+bool GLESvalidate::textureTarget(GLenum target) {
+    return target==GL_TEXTURE_2D || target==GL_TEXTURE_CUBE_MAP;
+}
+
+bool GLESvalidate::textureTargetLimited(GLenum target) {
+    return target==GL_TEXTURE_2D;
+}
+
+bool GLESvalidate::textureTargetEx(GLenum target) {
+    switch(target) {
+    case GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES:
+    case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES:
+    case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES:
+    case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES:
+    case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES:
+    case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES:
+    case GL_TEXTURE_2D:
+      return true;
+    } 
+    return false;
+}
+
+bool GLESvalidate::blendEquationMode(GLenum mode){
+    return mode == GL_FUNC_ADD             ||
+           mode == GL_FUNC_SUBTRACT        ||
+           mode == GL_FUNC_REVERSE_SUBTRACT;
+}
+
+bool GLESvalidate::framebufferTarget(GLenum target){
+    return target == GL_FRAMEBUFFER;
+}
+
+bool GLESvalidate::framebufferAttachment(GLenum attachment){
+    switch(attachment){
+    case GL_COLOR_ATTACHMENT0:
+    case GL_DEPTH_ATTACHMENT:
+    case GL_STENCIL_ATTACHMENT:
+        return true;
+    }
+    return false;
+}
+
+bool GLESvalidate::framebufferAttachmentParams(GLenum pname){
+    switch(pname){
+    case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
+    case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
+    case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
+    case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
+        return true;
+    }
+    return false;
+}
+
+bool GLESvalidate::renderbufferTarget(GLenum target){
+    return target == GL_RENDERBUFFER;
+}
+
+bool GLESvalidate::renderbufferParams(GLenum pname){
+    switch(pname){
+    case GL_RENDERBUFFER_WIDTH:
+    case GL_RENDERBUFFER_HEIGHT:
+    case GL_RENDERBUFFER_INTERNAL_FORMAT:
+    case GL_RENDERBUFFER_RED_SIZE:
+    case GL_RENDERBUFFER_GREEN_SIZE:
+    case GL_RENDERBUFFER_BLUE_SIZE:
+    case GL_RENDERBUFFER_ALPHA_SIZE:
+    case GL_RENDERBUFFER_DEPTH_SIZE:
+    case GL_RENDERBUFFER_STENCIL_SIZE:
+        return true;
+    }
+    return false;
+}
+
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/RangeManip.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/RangeManip.cpp
similarity index 98%
rename from tools/emulator/opengl/host/libs/Translator/GLES_CM/RangeManip.cpp
rename to tools/emulator/opengl/host/libs/Translator/GLcommon/RangeManip.cpp
index 6c41e6f..96e0970 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/RangeManip.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/RangeManip.cpp
@@ -13,7 +13,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-#include "RangeManip.h"
+#include <GLcommon/RangeManip.h>
 
 
 bool Range::rangeIntersection(const Range& r,Range& rOut) const {
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp
index 32f97c2..e6d42cf 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp
@@ -16,58 +16,11 @@
 #include <map>
 #include <GLcommon/objectNameManager.h>
 
-class GlobalNameSpace
-{
-public:
-    GlobalNameSpace()
-    {
-        mutex_init(&m_lock);
 
-        for (int i=0; i<NUM_OBJECT_TYPES; i++) {
-            m_nameSpace[i] = new NameSpace((NamedObjectType)i);
-        }
-
-    }
-
-    ~GlobalNameSpace()
-    {
-        mutex_lock(&m_lock);
-        for (int i=0; i<NUM_OBJECT_TYPES; i++) {
-            delete m_nameSpace[i];
-        }
-        mutex_unlock(&m_lock);
-        mutex_destroy(&m_lock);
-    }
-
-    unsigned int genName(NamedObjectType p_type)
-    {
-        if ( p_type >= NUM_OBJECT_TYPES ) return 0;
-
-        mutex_lock(&m_lock);
-        unsigned int name = m_nameSpace[p_type]->genName(0, false);
-        mutex_unlock(&m_lock);
-        return name;
-    }
-
-    void deleteName(NamedObjectType p_type, unsigned int p_name)
-    {
-        if ( p_type >= NUM_OBJECT_TYPES ) return;
-
-        mutex_lock(&m_lock);
-        m_nameSpace[p_type]->deleteName(p_name);
-        mutex_unlock(&m_lock);
-    }
-
-private:
-    mutex_t m_lock;
-    NameSpace *m_nameSpace[NUM_OBJECT_TYPES];
-};
-
-static GlobalNameSpace *s_globalNameSpace = NULL;
-
-NameSpace::NameSpace(NamedObjectType p_type) :
+NameSpace::NameSpace(NamedObjectType p_type, GlobalNameSpace *globalNameSpace) :
     m_nextName(0),
-    m_type(p_type)
+    m_type(p_type),
+    m_globalNameSpace(globalNameSpace)
 {
 }
 
@@ -76,7 +29,7 @@
     for (NamesMap::iterator n = m_localToGlobalMap.begin();
          n != m_localToGlobalMap.end();
          n++) {
-        s_globalNameSpace->deleteName(m_type, (*n).second);
+        m_globalNameSpace->deleteName(m_type, (*n).second);
     }
 }
 
@@ -92,7 +45,7 @@
     }
 
     if (genGlobal) {
-        unsigned int globalName = s_globalNameSpace->genName(m_type);
+        unsigned int globalName = m_globalNameSpace->genName(m_type);
         m_localToGlobalMap[localName] = globalName;
     }
 
@@ -131,7 +84,7 @@
 {
     NamesMap::iterator n( m_localToGlobalMap.find(p_localName) );
     if (n != m_localToGlobalMap.end()) {
-        s_globalNameSpace->deleteName(m_type, (*n).second);
+        m_globalNameSpace->deleteName(m_type, (*n).second);
         m_localToGlobalMap.erase(p_localName);
     }
 }
@@ -147,7 +100,7 @@
 {
     NamesMap::iterator n( m_localToGlobalMap.find(p_localName) );
     if (n != m_localToGlobalMap.end()) {
-        s_globalNameSpace->deleteName(m_type, (*n).second);
+        m_globalNameSpace->deleteName(m_type, (*n).second);
         (*n).second = p_globalName;
     }
 }
@@ -155,12 +108,12 @@
 typedef std::pair<NamedObjectType, unsigned int> ObjectIDPair;
 typedef std::map<ObjectIDPair, ObjectDataPtr> ObjectDataMap;
 
-ShareGroup::ShareGroup()
+ShareGroup::ShareGroup(GlobalNameSpace *globalNameSpace)
 {
     mutex_init(&m_lock);
 
     for (int i=0; i<NUM_OBJECT_TYPES; i++) {
-        m_nameSpace[i] = new NameSpace((NamedObjectType)i);
+        m_nameSpace[i] = new NameSpace((NamedObjectType)i, globalNameSpace);
     }
 
     m_objectsData = NULL;
@@ -291,7 +244,8 @@
     return ret;
 }
 
-ObjectNameManager::ObjectNameManager()
+ObjectNameManager::ObjectNameManager(GlobalNameSpace *globalNameSpace) :
+    m_globalNameSpace(globalNameSpace)
 {
     mutex_init(&m_lock);
 }
@@ -306,8 +260,6 @@
 {
     mutex_lock(&m_lock);
 
-    if (!s_globalNameSpace) s_globalNameSpace = new GlobalNameSpace();
-
     ShareGroupPtr shareGroupReturn;
 
     ShareGroupsMap::iterator s( m_groups.find(p_groupName) );
@@ -318,7 +270,7 @@
         //
         // Group does not exist, create new group
         //
-        shareGroupReturn = ShareGroupPtr( new ShareGroup() );
+        shareGroupReturn = ShareGroupPtr( new ShareGroup(m_globalNameSpace) );
         m_groups.insert( std::pair<void *, ShareGroupPtr>(p_groupName, shareGroupReturn) );
     }
 
@@ -332,8 +284,6 @@
 {
     mutex_lock(&m_lock);
 
-    if (!s_globalNameSpace) s_globalNameSpace = new GlobalNameSpace();
-
     ShareGroupPtr shareGroupReturn(NULL);
 
     ShareGroupsMap::iterator s( m_groups.find(p_groupName) );
@@ -350,8 +300,6 @@
 {
     mutex_lock(&m_lock);
 
-    if (!s_globalNameSpace) s_globalNameSpace = new GlobalNameSpace();
-
     ShareGroupPtr shareGroupReturn;
 
     ShareGroupsMap::iterator s( m_groups.find(p_existingGroupName) );
@@ -383,10 +331,6 @@
         m_groups.erase(s);
     }
 
-    if (m_groups.size() == 0 && s_globalNameSpace) {
-        delete s_globalNameSpace;
-        s_globalNameSpace = NULL;
-    }
     mutex_unlock(&m_lock);
 }
 
diff --git a/tools/emulator/opengl/host/libs/Translator/include/EGL/eglinternalplatform.h b/tools/emulator/opengl/host/libs/Translator/include/EGL/eglinternalplatform.h
new file mode 100644
index 0000000..3137027
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/include/EGL/eglinternalplatform.h
@@ -0,0 +1,59 @@
+#ifndef EGL_INTERNAL_PLATFORM_H
+#define EGL_INTERNAL_PLATFORM_H
+
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+
+#include <GL/gl.h>
+#define WGL_WGLEXT_PROTOTYPES
+#include <GL/wglext.h>
+
+typedef PIXELFORMATDESCRIPTOR  EGLNativePixelFormatType;
+#define PIXEL_FORMAT_INITIALIZER {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+typedef HGLRC                  EGLNativeContextType;
+typedef HPBUFFERARB            EGLNativePbufferType;
+
+#elif defined(__APPLE__)
+
+typedef void*                  EGLNativePixelFormatType;
+#define PIXEL_FORMAT_INITIALIZER NULL
+typedef void*                  EGLNativeContextType;
+typedef void*                  EGLNativePbufferType;
+
+
+#elif defined(__unix__)
+
+/* X11 (tentative)  */
+#include <GL/glx.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+typedef GLXFBConfig         EGLNativePixelFormatType;
+#define PIXEL_FORMAT_INITIALIZER 0;
+typedef GLXContext          EGLNativeContextType;
+typedef GLXPbuffer          EGLNativePbufferType;
+
+#else
+#error "Platform not recognized"
+#endif
+
+
+#endif
diff --git a/tools/emulator/opengl/host/libs/Translator/include/EGL/eglplatform.h b/tools/emulator/opengl/host/libs/Translator/include/EGL/eglplatform.h
index f5ce901..95aaa22 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/EGL/eglplatform.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/EGL/eglplatform.h
@@ -65,44 +65,28 @@
 #define WIN32_LEAN_AND_MEAN 1
 #endif
 #include <windows.h>
-#include <GL/gl.h>
-#define WGL_WGLEXT_PROTOTYPES
-#include <GL/wglext.h>
 
 class WinDisplay; //defined in EglWindows.cpp
 typedef WinDisplay* DISPLAY;
 
 
-typedef PIXELFORMATDESCRIPTOR  EGLNativePixelFormatType;
-#define PIXEL_FORMAT_INITIALIZER {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-typedef HGLRC                  EGLNativeContextType;
-typedef HPBUFFERARB            EGLNativePbufferType;
 typedef DISPLAY                EGLNativeDisplayType;
 typedef HBITMAP                EGLNativePixmapType;
 typedef HWND                   EGLNativeWindowType;
 
 #elif defined(__APPLE__)
 
-typedef int  EGLNativePixelFormatType;
-#define PIXEL_FORMAT_INITIALIZER 0
+typedef unsigned int           EGLNativeDisplayType;
+typedef void*                  EGLNativePixmapType;
+typedef void*                  EGLNativeWindowType;
 
-typedef struct _EGLNativeContextType*      EGLNativeContextType;
-typedef struct _EGLNativePbufferType*      EGLNativePbufferType;
-typedef struct _EGLNativeDisplayType*      EGLNativeDisplayType;
-typedef int       EGLNativePixmapType;
-typedef int       EGLNativeWindowType;
 
 #elif defined(__unix__)
 
 /* X11 (tentative)  */
-#include <GL/glx.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 
-typedef GLXFBConfig         EGLNativePixelFormatType;
-#define PIXEL_FORMAT_INITIALIZER 0;
-typedef GLXContext          EGLNativeContextType;
-typedef GLXPbuffer          EGLNativePbufferType;
 typedef Display *           EGLNativeDisplayType;
 typedef Pixmap              EGLNativePixmapType;
 typedef Window              EGLNativeWindowType;
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h
new file mode 100644
index 0000000..da982f3
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h
@@ -0,0 +1,279 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef GLDISPATCHH
+#define GLDISPATCHH
+
+#include <GLES/gl.h>
+#include <GLES2/gl2.h>
+#include <utils/threads.h>
+#include "gldefs.h"
+#include "GLutils.h"
+
+#define GLAPIENTRY GL_APIENTRY
+typedef void(*FUNCPTR)();
+
+class GLDispatch
+{
+public:
+
+    GLDispatch();
+    void dispatchFuncs(GLESVersion version);
+
+    /* OpenGL functions which are needed for implementing BOTH GLES 1.1 & GLES 2.0*/
+    static void (GLAPIENTRY *glActiveTexture) ( GLenum texture );
+    static void (GLAPIENTRY *glBindBuffer) (GLenum target, GLuint buffer);
+    static void (GLAPIENTRY *glBindTexture) (GLenum target, GLuint texture);
+    static void (GLAPIENTRY *glBlendFunc) (GLenum sfactor, GLenum dfactor);
+    static void (GLAPIENTRY *glBlendEquation)( GLenum mode );
+    static void (GLAPIENTRY *glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha);
+    static void (GLAPIENTRY *glBlendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+    static void (GLAPIENTRY *glBufferData) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
+    static void (GLAPIENTRY *glBufferSubData) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+    static void (GLAPIENTRY *glClear) (GLbitfield mask);
+    static void (GLAPIENTRY *glClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+    static void (GLAPIENTRY *glClearStencil) (GLint s);
+    static void (GLAPIENTRY *glColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+    static void (GLAPIENTRY *glCompressedTexImage2D) ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data );
+    static void (GLAPIENTRY *glCompressedTexSubImage2D) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data );
+    static void (GLAPIENTRY *glCopyTexImage2D) (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+    static void (GLAPIENTRY *glCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+    static void (GLAPIENTRY *glCullFace) (GLenum mode);
+    static void (GLAPIENTRY *glDeleteBuffers) (GLsizei n, const GLuint *buffers);
+    static void (GLAPIENTRY *glDeleteTextures) (GLsizei n, const GLuint *textures);
+    static void (GLAPIENTRY *glDepthFunc) (GLenum func);
+    static void (GLAPIENTRY *glDepthMask) (GLboolean flag);
+    static void (GLAPIENTRY *glDepthRange) (GLclampd zNear, GLclampd zFar);
+    static void (GLAPIENTRY *glDisable) (GLenum cap);
+    static void (GLAPIENTRY *glDrawArrays) (GLenum mode, GLint first, GLsizei count);
+    static void (GLAPIENTRY *glDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+    static void (GLAPIENTRY *glEnable) (GLenum cap);
+    static void (GLAPIENTRY *glFinish) (void);
+    static void (GLAPIENTRY *glFlush) (void);
+    static void (GLAPIENTRY *glFrontFace) (GLenum mode);
+    static void (GLAPIENTRY *glGenBuffers) (GLsizei n, GLuint *buffers);
+    static void (GLAPIENTRY *glGenTextures) (GLsizei n, GLuint *textures);
+    static void (GLAPIENTRY *glGetBooleanv) (GLenum pname, GLboolean *params);
+    static void (GLAPIENTRY *glGetBufferParameteriv) (GLenum, GLenum, GLint *);
+    static GLenum (GLAPIENTRY *glGetError) (void);
+    static void (GLAPIENTRY *glGetFloatv) (GLenum pname, GLfloat *params);
+    static void (GLAPIENTRY *glGetIntegerv) (GLenum pname, GLint *params);
+    static const GLubyte * (GLAPIENTRY *glGetString) (GLenum name);
+    static void (GLAPIENTRY *glGetTexParameterfv) (GLenum target, GLenum pname, GLfloat *params);
+    static void (GLAPIENTRY *glGetTexParameteriv) (GLenum target, GLenum pname, GLint *params);
+    static void (GLAPIENTRY *glHint) (GLenum target, GLenum mode);
+    static GLboolean (GLAPIENTRY *glIsBuffer) (GLuint);
+    static GLboolean (GLAPIENTRY *glIsEnabled) (GLenum cap);
+    static GLboolean (GLAPIENTRY *glIsTexture) (GLuint texture);
+    static void (GLAPIENTRY *glLineWidth) (GLfloat width);
+    static void (GLAPIENTRY *glPolygonOffset) (GLfloat factor, GLfloat units);
+    static void (GLAPIENTRY *glPixelStorei) (GLenum pname, GLint param);
+    static void (GLAPIENTRY *glReadPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
+    static void (GLAPIENTRY *glSampleCoverage) ( GLclampf value, GLboolean invert );
+    static void (GLAPIENTRY *glScissor) (GLint x, GLint y, GLsizei width, GLsizei height);
+    static void (GLAPIENTRY *glStencilFunc) (GLenum func, GLint ref, GLuint mask);
+    static void (GLAPIENTRY *glStencilMask) (GLuint mask);
+    static void (GLAPIENTRY *glStencilOp) (GLenum fail, GLenum zfail, GLenum zpass);
+    static void (GLAPIENTRY *glTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+    static void (GLAPIENTRY *glTexParameteri) (GLenum target, GLenum pname, GLint param);
+    static void (GLAPIENTRY *glTexParameteriv) (GLenum target, GLenum pname, const GLint *params);
+    static void (GLAPIENTRY *glTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+    static void (GLAPIENTRY *glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
+    static void (GLAPIENTRY *glPushAttrib) ( GLbitfield mask );
+    static void (GLAPIENTRY *glPopAttrib) ( void );
+    static void (GLAPIENTRY *glPushClientAttrib) ( GLbitfield mask );
+    static void (GLAPIENTRY *glPopClientAttrib) ( void );
+
+    /* OpenGL functions which are needed ONLY for implementing GLES 1.1*/
+    static void (GLAPIENTRY *glAlphaFunc) (GLenum func, GLclampf ref);
+    static void (GLAPIENTRY *glBegin)( GLenum mode );
+    static void (GLAPIENTRY *glClearDepth) (GLclampd depth);
+    static void (GLAPIENTRY *glClientActiveTexture) ( GLenum texture );
+    static void (GLAPIENTRY *glClipPlane) (GLenum plane, const GLdouble *equation);
+    static void (GLAPIENTRY *glColor4d) (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
+    static void (GLAPIENTRY *glColor4f) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+    static void (GLAPIENTRY *glColor4fv) ( const GLfloat *v );
+    static void (GLAPIENTRY *glColor4ub) (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+    static void (GLAPIENTRY *glColor4ubv) ( const GLubyte *v );
+    static void (GLAPIENTRY *glColorPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+    static void (GLAPIENTRY *glDisableClientState) (GLenum array);
+    static void (GLAPIENTRY *glEnableClientState) (GLenum array);
+    static void (GLAPIENTRY *glEnd) (void);
+    static void (GLAPIENTRY *glFogf) (GLenum pname, GLfloat param);
+    static void (GLAPIENTRY *glFogfv) (GLenum pname, const GLfloat *params);
+    static void (GLAPIENTRY *glFrustum) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+    static void (GLAPIENTRY *glGetClipPlane) (GLenum plane, GLdouble *equation);
+    static void (GLAPIENTRY *glGetDoublev) ( GLenum pname, GLdouble *params );
+    static void (GLAPIENTRY *glGetLightfv) (GLenum light, GLenum pname, GLfloat *params);
+    static void (GLAPIENTRY *glGetMaterialfv) (GLenum face, GLenum pname, GLfloat *params);
+    static void (GLAPIENTRY *glGetPointerv) (GLenum pname, GLvoid* *params);
+    static void (GLAPIENTRY *glGetTexEnvfv) (GLenum target, GLenum pname, GLfloat *params);
+    static void (GLAPIENTRY *glGetTexEnviv) (GLenum target, GLenum pname, GLint *params);
+    static void (GLAPIENTRY *glLightf) (GLenum light, GLenum pname, GLfloat param);
+    static void (GLAPIENTRY *glLightfv) (GLenum light, GLenum pname, const GLfloat *params);
+    static void (GLAPIENTRY *glLightModelf) (GLenum pname, GLfloat param);
+    static void (GLAPIENTRY *glLightModelfv) (GLenum pname, const GLfloat *params);
+    static void (GLAPIENTRY *glLoadIdentity) (void);
+    static void (GLAPIENTRY *glLoadMatrixf) (const GLfloat *m);
+    static void (GLAPIENTRY *glLogicOp) (GLenum opcode);
+    static void (GLAPIENTRY *glMaterialf) (GLenum face, GLenum pname, GLfloat param);
+    static void (GLAPIENTRY *glMaterialfv) (GLenum face, GLenum pname, const GLfloat *params);
+    static void (GLAPIENTRY *glMultiTexCoord2fv) ( GLenum target, const GLfloat *v );
+    static void (GLAPIENTRY *glMultiTexCoord2sv) ( GLenum target, const GLshort *v );
+    static void (GLAPIENTRY *glMultiTexCoord3fv) ( GLenum target, const GLfloat *v );
+    static void (GLAPIENTRY *glMultiTexCoord3sv) ( GLenum target, const GLshort *v );
+    static void (GLAPIENTRY *glMultiTexCoord4f) ( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q );
+    static void (GLAPIENTRY *glMultiTexCoord4fv) ( GLenum target, const GLfloat *v );
+    static void (GLAPIENTRY *glMultiTexCoord4sv) ( GLenum target, const GLshort *v );
+    static void (GLAPIENTRY *glMultMatrixf) (const GLfloat *m);
+    static void (GLAPIENTRY *glNormal3f) (GLfloat nx, GLfloat ny, GLfloat nz);
+    static void (GLAPIENTRY *glNormal3fv) ( const GLfloat *v );
+    static void (GLAPIENTRY *glNormal3sv) ( const GLshort *v );
+    static void (GLAPIENTRY *glOrtho) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+    static void (GLAPIENTRY *glPointParameterf) (GLenum, GLfloat);
+    static void (GLAPIENTRY *glPointParameterfv) (GLenum, const GLfloat *);
+    static void (GLAPIENTRY *glPointSize) (GLfloat size);
+    static void (GLAPIENTRY *glRotatef) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+    static void (GLAPIENTRY *glScalef) (GLfloat x, GLfloat y, GLfloat z);
+    static void (GLAPIENTRY *glTexEnvf) (GLenum target, GLenum pname, GLfloat param);
+    static void (GLAPIENTRY *glTexEnvfv) (GLenum target, GLenum pname, const GLfloat *params);
+    static void (GLAPIENTRY *glTexParameterf) (GLenum target, GLenum pname, GLfloat param);
+    static void (GLAPIENTRY *glTexParameterfv) (GLenum target, GLenum pname, const GLfloat *params);
+    static void (GLAPIENTRY *glMatrixMode) (GLenum mode);
+    static void (GLAPIENTRY *glNormalPointer) (GLenum type, GLsizei stride, const GLvoid *pointer);
+    static void (GLAPIENTRY *glPopMatrix) (void);
+    static void (GLAPIENTRY *glPushMatrix) (void);
+    static void (GLAPIENTRY *glShadeModel) (GLenum mode);
+    static void (GLAPIENTRY *glTexCoordPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+    static void (GLAPIENTRY *glTexEnvi) (GLenum target, GLenum pname, GLint param);
+    static void (GLAPIENTRY *glTexEnviv) (GLenum target, GLenum pname, const GLint *params);
+    static void (GLAPIENTRY *glTranslatef) (GLfloat x, GLfloat y, GLfloat z);
+    static void (GLAPIENTRY *glVertexPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+
+    /* OpenGL functions which are needed ONLY for implementing GLES 1.1 EXTENSIONS*/
+    static GLboolean (GLAPIENTRY *glIsRenderbufferEXT) (GLuint renderbuffer);
+    static void (GLAPIENTRY *glBindRenderbufferEXT) (GLenum target, GLuint renderbuffer);
+    static void (GLAPIENTRY *glDeleteRenderbuffersEXT) (GLsizei n, const GLuint *renderbuffers);
+    static void (GLAPIENTRY *glGenRenderbuffersEXT) (GLsizei n, GLuint *renderbuffers);
+    static void (GLAPIENTRY *glRenderbufferStorageEXT) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+    static void (GLAPIENTRY *glGetRenderbufferParameterivEXT) (GLenum target, GLenum pname, GLint *params);
+    static GLboolean (GLAPIENTRY *glIsFramebufferEXT) (GLuint framebuffer);
+    static void (GLAPIENTRY *glBindFramebufferEXT) (GLenum target, GLuint framebuffer);
+    static void (GLAPIENTRY *glDeleteFramebuffersEXT) (GLsizei n, const GLuint *framebuffers);
+    static void (GLAPIENTRY *glGenFramebuffersEXT) (GLsizei n, GLuint *framebuffers);
+    static GLenum (GLAPIENTRY *glCheckFramebufferStatusEXT) (GLenum target);
+    static void (GLAPIENTRY *glFramebufferTexture1DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+    static void (GLAPIENTRY *glFramebufferTexture2DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+    static void (GLAPIENTRY *glFramebufferTexture3DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+    static void (GLAPIENTRY *glFramebufferRenderbufferEXT) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+    static void (GLAPIENTRY *glGetFramebufferAttachmentParameterivEXT) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+    static void (GLAPIENTRY *glGenerateMipmapEXT) (GLenum target);
+    static void (GLAPIENTRY *glCurrentPaletteMatrixARB) (GLint index);
+    static void (GLAPIENTRY *glMatrixIndexuivARB) (GLint size, GLuint * indices);
+    static void (GLAPIENTRY *glMatrixIndexPointerARB) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+    static void (GLAPIENTRY *glWeightPointerARB) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+    static void (GLAPIENTRY *glTexGenf) (GLenum coord, GLenum pname, GLfloat param );
+    static void (GLAPIENTRY *glTexGeni) (GLenum coord, GLenum pname, GLint param );
+    static void (GLAPIENTRY *glTexGenfv) (GLenum coord, GLenum pname, const GLfloat *params );
+    static void (GLAPIENTRY *glTexGeniv) (GLenum coord, GLenum pname, const GLint *params );
+    static void (GLAPIENTRY *glGetTexGenfv) (GLenum coord, GLenum pname, GLfloat *params );
+    static void (GLAPIENTRY *glGetTexGeniv) (GLenum coord, GLenum pname, GLint *params );
+
+    /* Loading OpenGL functions which are needed ONLY for implementing GLES 2.0*/
+    static void (GL_APIENTRY *glBlendColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+    static void (GL_APIENTRY *glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask);
+    static void (GL_APIENTRY *glStencilMaskSeparate)(GLenum face, GLuint mask);
+    static void (GL_APIENTRY *glGenerateMipmap)(GLenum target);
+    static void (GL_APIENTRY *glBindFramebuffer)(GLenum target, GLuint framebuffer);
+    static void (GL_APIENTRY *glBindRenderbuffer)(GLenum target, GLuint renderbuffer);
+    static void (GL_APIENTRY *glDeleteFramebuffers)(GLsizei n, const GLuint* framebuffers);
+    static void (GL_APIENTRY *glDeleteRenderbuffers)(GLsizei n, const GLuint* renderbuffers);
+    static GLboolean (GL_APIENTRY *glIsProgram)(GLuint program);
+    static GLboolean (GL_APIENTRY *glIsShader)(GLuint shader);
+    static void (GL_APIENTRY *glVertexAttrib1f)(GLuint indx, GLfloat x);
+    static void (GL_APIENTRY *glVertexAttrib1fv)(GLuint indx, const GLfloat* values);
+    static void (GL_APIENTRY *glVertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y);
+    static void (GL_APIENTRY *glVertexAttrib2fv)(GLuint indx, const GLfloat* values);
+    static void (GL_APIENTRY *glVertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+    static void (GL_APIENTRY *glVertexAttrib3fv)(GLuint indx, const GLfloat* values);
+    static void (GL_APIENTRY *glVertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+    static void (GL_APIENTRY *glVertexAttrib4fv)(GLuint indx, const GLfloat* values);
+    static void (GL_APIENTRY *glVertexAttribPointer)(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
+    static void (GL_APIENTRY *glDisableVertexAttribArray)(GLuint index);
+    static void (GL_APIENTRY *glEnableVertexAttribArray)(GLuint index);
+    static void (GL_APIENTRY *glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params);
+    static void (GL_APIENTRY *glGetVertexAttribiv)(GLuint index, GLenum pname, GLint* params);
+    static void (GL_APIENTRY *glGetVertexAttribPointerv)(GLuint index, GLenum pname, GLvoid** pointer);
+    static void (GL_APIENTRY *glUniform1f)(GLint location, GLfloat x);
+    static void (GL_APIENTRY *glUniform1fv)(GLint location, GLsizei count, const GLfloat* v);
+    static void (GL_APIENTRY *glUniform1i)(GLint location, GLint x);
+    static void (GL_APIENTRY *glUniform1iv)(GLint location, GLsizei count, const GLint* v);
+    static void (GL_APIENTRY *glUniform2f)(GLint location, GLfloat x, GLfloat y);
+    static void (GL_APIENTRY *glUniform2fv)(GLint location, GLsizei count, const GLfloat* v);
+    static void (GL_APIENTRY *glUniform2i)(GLint location, GLint x, GLint y);
+    static void (GL_APIENTRY *glUniform2iv)(GLint location, GLsizei count, const GLint* v);
+    static void (GL_APIENTRY *glUniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z);
+    static void (GL_APIENTRY *glUniform3fv)(GLint location, GLsizei count, const GLfloat* v);
+    static void (GL_APIENTRY *glUniform3i)(GLint location, GLint x, GLint y, GLint z);
+    static void (GL_APIENTRY *glUniform3iv)(GLint location, GLsizei count, const GLint* v);
+    static void (GL_APIENTRY *glUniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+    static void (GL_APIENTRY *glUniform4fv)(GLint location, GLsizei count, const GLfloat* v);
+    static void (GL_APIENTRY *glUniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w);
+    static void (GL_APIENTRY *glUniform4iv)(GLint location, GLsizei count, const GLint* v);
+    static void (GL_APIENTRY *glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+    static void (GL_APIENTRY *glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+    static void (GL_APIENTRY *glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+    static void (GL_APIENTRY *glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint* params);
+    static void (GL_APIENTRY *glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint* params);
+    static GLboolean (GL_APIENTRY *glIsFramebuffer)(GLuint framebuffer);
+    static GLboolean (GL_APIENTRY *glIsRenderbuffer)(GLuint renderbuffer);
+    static GLenum (GL_APIENTRY *glCheckFramebufferStatus)(GLenum target);
+    static void (GL_APIENTRY *glAttachShader)(GLuint program, GLuint shader);
+    static void (GL_APIENTRY *glBindAttribLocation)(GLuint program, GLuint index, const GLchar* name);
+    static void (GL_APIENTRY *glCompileShader)(GLuint shader);
+    static GLuint (GL_APIENTRY *glCreateProgram)(void);
+    static GLuint (GL_APIENTRY *glCreateShader)(GLenum type);
+    static void (GL_APIENTRY *glDeleteProgram)(GLuint program);
+    static void (GL_APIENTRY *glDeleteShader)(GLuint shader);
+    static void (GL_APIENTRY *glDetachShader)(GLuint program, GLuint shader);
+    static void (GL_APIENTRY *glLinkProgram)(GLuint program);
+    static void (GL_APIENTRY *glUseProgram)(GLuint program);
+    static void (GL_APIENTRY *glValidateProgram)(GLuint program);
+    static void (GL_APIENTRY *glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+    static void (GL_APIENTRY *glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+    static void (GL_APIENTRY *glGetAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+    static int  (GL_APIENTRY *glGetAttribLocation)(GLuint program, const GLchar* name);
+    static void (GL_APIENTRY *glGetProgramiv)(GLuint program, GLenum pname, GLint* params);
+    static void (GL_APIENTRY *glGetProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+    static void (GL_APIENTRY *glGetShaderiv)(GLuint shader, GLenum pname, GLint* params);
+    static void (GL_APIENTRY *glGetShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+    static void (GL_APIENTRY *glGetShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+    static void (GL_APIENTRY *glGetShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
+    static void (GL_APIENTRY *glGetUniformfv)(GLuint program, GLint location, GLfloat* params);
+    static void (GL_APIENTRY *glGetUniformiv)(GLuint program, GLint location, GLint* params);
+    static int  (GL_APIENTRY *glGetUniformLocation)(GLuint program, const GLchar* name);
+    static void (GL_APIENTRY *glReleaseShaderCompiler)(void);
+    static void (GL_APIENTRY *glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+    static void (GL_APIENTRY *glShaderBinary)(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
+    static void (GL_APIENTRY *glShaderSource)(GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
+    static void (GL_APIENTRY *glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+    static void (GL_APIENTRY *glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+
+private:
+    bool                    m_isLoaded;
+    static android::Mutex   s_lock;
+};
+
+#endif
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESbuffer.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h
similarity index 97%
rename from tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESbuffer.h
rename to tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h
index 5c4ce78..f4dcc7a 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESbuffer.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h
@@ -19,7 +19,7 @@
 #include <stdio.h>
 #include <GLES/gl.h>
 #include <GLcommon/objectNameManager.h>
-#include "RangeManip.h"
+#include <GLcommon/RangeManip.h>
 
 class GLESbuffer: public ObjectData {
 public:
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
new file mode 100644
index 0000000..af2d39a
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
@@ -0,0 +1,142 @@
+#ifndef GLES_CONTEXT_H
+#define GLES_CONTEXT_H
+
+#include "GLDispatch.h"
+#include "GLESpointer.h"
+#include "objectNameManager.h"
+#include <utils/threads.h>
+#include <string>
+
+#define MAX_TEX_UNITS 8
+
+typedef std::map<GLenum,GLESpointer*>  ArraysMap;
+
+enum TextureTarget {
+TEXTURE_2D,
+TEXTURE_CUBE_MAP,
+NUM_TEXTURE_TARGETS
+};
+
+typedef struct _textureUnitState {
+    GLuint texture;
+    GLboolean enabled[NUM_TEXTURE_TARGETS];
+} textureUnitState;
+
+class Version{
+public:
+    Version();
+    Version(int major,int minor,int release);
+    Version(const char* versionString);
+    Version(const Version& ver);
+    bool operator<(const Version& ver) const;
+    Version& operator=(const Version& ver);
+private:
+    int m_major;
+    int m_minor;
+    int m_release;
+};
+
+struct GLSupport {
+    GLSupport():maxLights(0),maxVertexAttribs(0),maxClipPlane(0),maxTexUnits(0),maxTexSize(0) , \
+                GL_EXT_TEXTURE_FORMAT_BGRA8888(false), GL_EXT_FRAMEBUFFER_OBJECT(false), \
+                GL_ARB_VERTEX_BLEND(false), GL_ARB_MATRIX_PALETTE(false), \
+                GL_NV_PACKED_DEPTH_STENCIL(false) , GL_OES_READ_FORMAT(false), \
+                GL_ARB_HALF_FLOAT_PIXEL(false), GL_NV_HALF_FLOAT(false), \
+                GL_ARB_HALF_FLOAT_VERTEX(false) {} ;
+    int  maxLights;
+    int  maxVertexAttribs;
+    int  maxClipPlane;
+    int  maxTexUnits;
+    int  maxTexSize;
+    Version glslVersion;
+    bool GL_EXT_TEXTURE_FORMAT_BGRA8888;
+    bool GL_EXT_FRAMEBUFFER_OBJECT;
+    bool GL_ARB_VERTEX_BLEND;
+    bool GL_ARB_MATRIX_PALETTE;
+    bool GL_NV_PACKED_DEPTH_STENCIL;
+    bool GL_OES_READ_FORMAT;
+    bool GL_ARB_HALF_FLOAT_PIXEL;
+    bool GL_NV_HALF_FLOAT;
+    bool GL_ARB_HALF_FLOAT_VERTEX;
+
+};
+
+struct GLESFloatArrays
+{
+    GLESFloatArrays(){};
+    ~GLESFloatArrays();
+    std::map<GLenum,GLfloat*> arrays;
+};
+
+class GLEScontext{
+public:
+    virtual void init() = 0;
+    GLEScontext();
+    GLenum getGLerror();
+    void setGLerror(GLenum err);
+    void setShareGroup(ShareGroupPtr grp){m_shareGroup = grp;};
+    virtual void setActiveTexture(GLenum tex);
+    unsigned int getBindedTexture(){return m_tex2DBind[m_activeTexture].texture;};
+    unsigned int getBindedTexture(GLenum unit) { return m_tex2DBind[unit - GL_TEXTURE0].texture;};
+    void setBindedTexture(unsigned int tex){ m_tex2DBind[m_activeTexture].texture = tex;};
+    bool isTextureUnitEnabled(GLenum unit);
+    void setTextureEnabled(TextureTarget target, GLenum enable) {m_tex2DBind[m_activeTexture].enabled[target] = enable; };
+
+    bool  isArrEnabled(GLenum);
+    void  enableArr(GLenum arr,bool enable);
+    const GLvoid* setPointer(GLenum arrType,GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize = false);
+    const GLESpointer* getPointer(GLenum arrType);
+    virtual void convertArrs(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct) = 0;
+    void bindBuffer(GLenum target,GLuint buffer);
+    void unbindBuffer(GLuint buffer);
+    bool isBuffer(GLuint buffer);
+    bool isBindedBuffer(GLenum target);
+    GLvoid* getBindedBuffer(GLenum target);
+    void getBufferSize(GLenum target,GLint* param);
+    void getBufferUsage(GLenum target,GLint* param);
+    bool setBufferData(GLenum target,GLsizeiptr size,const GLvoid* data,GLenum usage);
+    bool setBufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,const GLvoid* data);
+    const char * getExtensionString();
+    void getGlobalLock();
+    void releaseGlobalLock();
+    virtual GLSupport*  getCaps(){return &s_glSupport;};
+    virtual ~GLEScontext();
+
+    static GLDispatch& dispatcher(){return s_glDispatch;};
+
+    static int getMaxLights(){return s_glSupport.maxLights;}
+    static int getMaxClipPlanes(){return s_glSupport.maxClipPlane;}
+    static int getMaxTexUnits(){return s_glSupport.maxTexUnits;}
+    static int getMaxTexSize(){return s_glSupport.maxTexSize;}
+    static Version glslVersion(){return s_glSupport.glslVersion;}
+
+
+protected:
+    void chooseConvertMethod(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id,unsigned int& index);
+    void initCapsLocked(const GLubyte * extensionString);
+    static android::Mutex s_lock;
+    static GLDispatch     s_glDispatch;
+    bool                  m_initialized;
+    unsigned int          m_activeTexture;
+    ArraysMap             m_map;
+    static std::string*   s_glExtensions;
+    static GLSupport      s_glSupport;
+
+private:
+
+    virtual void sendArr(GLvoid* arr,GLenum arrayType,GLint size,GLsizei stride,int pointsIndex = -1) = 0 ;
+    GLuint getBuffer(GLenum target);
+    void convertDirect(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum array_id,GLESpointer* p,unsigned int& index);
+    void convertDirectVBO(GLint first,GLsizei count,GLenum array_id,GLESpointer* p);
+    void convertIndirect(GLESFloatArrays& fArrs,GLsizei count,GLenum type,const GLvoid* indices,GLenum array_id,GLESpointer* p,unsigned int& index);
+    void convertIndirectVBO(GLsizei count,GLenum indices_type,const GLvoid* indices,GLenum array_id,GLESpointer* p);
+
+    ShareGroupPtr         m_shareGroup;
+    GLenum                m_glError;
+    textureUnitState      m_tex2DBind[MAX_TEX_UNITS];
+    unsigned int          m_arrayBuffer;
+    unsigned int          m_elementBuffer;
+};
+
+#endif
+
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h
new file mode 100644
index 0000000..08b1a07
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h
@@ -0,0 +1,61 @@
+#ifndef GLES_MACROS_H
+#define GLES_MACROS_H
+
+#define GET_THREAD()                                                         \
+            ThreadInfo* thrd = NULL;                                         \
+            if(s_eglIface) {                                                 \
+                thrd = s_eglIface->getThreadInfo();                          \
+            } else {                                                         \
+                fprintf(stderr,"Context wasn't initialized yet \n");         \
+            }
+
+
+#define GET_CTX()                                                                \
+            GET_THREAD();                                                        \
+            if(!thrd) return;                                                    \
+            GLEScontext *ctx = static_cast<GLEScontext*>(thrd->glesContext);     \
+            if(!ctx) return;
+
+#define GET_CTX_CM()                                                             \
+            GET_THREAD();                                                        \
+            if(!thrd) return;                                                    \
+            GLEScmContext *ctx = static_cast<GLEScmContext*>(thrd->glesContext); \
+            if(!ctx) return;
+
+#define GET_CTX_V2()                                                             \
+            GET_THREAD();                                                        \
+            if(!thrd) return;                                                    \
+            GLESv2Context *ctx = static_cast<GLESv2Context*>(thrd->glesContext); \
+            if(!ctx) return;
+
+#define GET_CTX_RET(failure_ret)                                                 \
+            GET_THREAD();                                                        \
+            if(!thrd) return failure_ret;                                        \
+            GLEScontext *ctx = static_cast<GLEScontext*>(thrd->glesContext);     \
+            if(!ctx) return failure_ret;
+
+#define GET_CTX_CM_RET(failure_ret)                                              \
+            GET_THREAD();                                                        \
+            if(!thrd) return failure_ret;                                        \
+            GLEScmContext *ctx = static_cast<GLEScmContext*>(thrd->glesContext); \
+            if(!ctx) return failure_ret;
+
+#define GET_CTX_V2_RET(failure_ret)                                              \
+            GET_THREAD();                                                        \
+            if(!thrd) return failure_ret;                                        \
+            GLESv2Context *ctx = static_cast<GLESv2Context*>(thrd->glesContext); \
+            if(!ctx) return failure_ret;
+
+
+#define SET_ERROR_IF(condition,err) if((condition)) {                            \
+                        ctx->setGLerror(err);                                    \
+                        return;                                                  \
+                    }
+
+
+#define RET_AND_SET_ERROR_IF(condition,err,ret) if((condition)) {                \
+                        ctx->setGLerror(err);                                    \
+                        return ret;                                              \
+                    }
+
+#endif
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESpointer.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h
similarity index 89%
rename from tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESpointer.h
rename to tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h
index 9d897e4..c17be74 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLESpointer.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h
@@ -32,9 +32,10 @@
     unsigned int  getBufferOffset() const;
     void          getBufferConversions(const RangeList& rl,RangeList& rlOut);
     bool          bufferNeedConversion(){ return !m_buffer->fullyConverted();}
-    void          setArray (GLint size,GLenum type,GLsizei stride,const GLvoid* data);
-    void          setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer* buf,int offset);
+    void          setArray (GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize = false);
+    void          setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer* buf,int offset,bool normalize = false);
     bool          isEnable() const;
+    bool          isNormalize() const;
     void          enable(bool b);
 
 private:
@@ -42,6 +43,7 @@
     GLenum        m_type;
     GLsizei       m_stride;
     bool          m_enabled;
+    bool          m_normalize;
     const GLvoid* m_data;
     GLESbuffer*   m_buffer;
     unsigned int  m_buffOffset;
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESvalidate.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESvalidate.h
new file mode 100644
index 0000000..23a2cb7
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESvalidate.h
@@ -0,0 +1,42 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef GLES_VALIDATE_H
+#define GLES_VALIDATE_H
+
+#include <GLES/gl.h>
+#include "GLEScontext.h"
+struct GLESvalidate
+{
+static bool textureEnum(GLenum e,unsigned int maxTex);
+static bool pixelType(GLEScontext * ctx,GLenum type);
+static bool pixelOp(GLenum format,GLenum type); 
+static bool pixelFrmt(GLEScontext* ctx , GLenum format);
+static bool bufferTarget(GLenum target);
+static bool bufferParam(GLenum param);
+static bool drawMode(GLenum mode);
+static bool drawType(GLenum mode);
+static bool textureTarget(GLenum target);
+static bool textureTargetLimited(GLenum target);
+static bool textureTargetEx(GLenum target);
+static bool blendEquationMode(GLenum mode);
+static bool framebufferTarget(GLenum target);
+static bool framebufferAttachment(GLenum attachment);
+static bool framebufferAttachmentParams(GLenum pname);
+static bool renderbufferTarget(GLenum target);
+static bool renderbufferParams(GLenum pname);
+};
+
+#endif
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLfixed_ops.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLfixed_ops.h
similarity index 96%
rename from tools/emulator/opengl/host/libs/Translator/GLES_CM/GLfixed_ops.h
rename to tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLfixed_ops.h
index 824bb94..0cf6566 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLfixed_ops.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLfixed_ops.h
@@ -25,5 +25,6 @@
                (d) < -32768.65535 ? -32768 * 65536 + 65535 : \
                ((GLfixed) ((d) * 65536)))
 
+#define I2X(d) ((d)*65536)
 
 #endif
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h
index 2da321a..7e2a038 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h
@@ -16,6 +16,12 @@
 #ifndef GL_UTILS_H
 #define GL_UTILS_H
 
+typedef enum{
+             GLES_1_1 = 1,
+             GLES_2_0 = 2,
+             MAX_GLES_VERSION //Must be last
+            }GLESVersion;
+
 template <class T>
 void swap(T& x,T& y) {
      T temp;
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/RangeManip.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/RangeManip.h
similarity index 100%
rename from tools/emulator/opengl/host/libs/Translator/GLES_CM/RangeManip.h
rename to tools/emulator/opengl/host/libs/Translator/include/GLcommon/RangeManip.h
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h
index 4bdfbe4..8ac93fb 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h
@@ -91,10 +91,6 @@
         return *m_ptr;
     }
 
-    operator void*() const {
-        return (void *)m_ptr;
-    }
-
     // This gives STL lists something to compare.
     bool operator <(const SmartPtr<T>& t1) const {
         return m_ptr < t1.m_ptr;
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/ThreadInfo.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/ThreadInfo.h
index ba451e6..69b8ac4 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/ThreadInfo.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/ThreadInfo.h
@@ -18,12 +18,22 @@
 
 #include "objectNameManager.h"
 
+class EglContext;
+class EglDisplay;
+class GLEScontext;
+
 struct ThreadInfo {
     ThreadInfo():eglContext(NULL),glesContext(NULL),objManager(NULL){}
-    void updateInfo(void* eglctx,void* dpy,void* glesCtx,ShareGroupPtr share,ObjectNameManager* manager);
-    void*                eglContext;
-    void*                eglDisplay;
-    void*                glesContext;
+
+    void updateInfo(EglContext* eglctx,
+                    EglDisplay* dpy,
+                    GLEScontext* glesCtx,
+                    ShareGroupPtr share,
+                    ObjectNameManager* manager);
+
+    EglContext*          eglContext;
+    EglDisplay*          eglDisplay;
+    GLEScontext*         glesContext;
     ShareGroupPtr        shareGroup;
     ObjectNameManager*   objManager;
 };
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
index 51ad4b3..5d00ce6 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
@@ -17,6 +17,7 @@
 #define TRANSLATOR_IFACES_H
 #include <GLcommon/ThreadInfo.h>
 #include <GLES/gl.h>
+#include <string.h>
 
 extern "C" {
 
@@ -36,13 +37,16 @@
     ~TextureData() {
         if (sourceEGLImage && eglImageDetach) (*eglImageDetach)(sourceEGLImage);
     }
-    TextureData():width(0),height(0),border(0),internalFormat(GL_RGBA),sourceEGLImage(0){};
+    TextureData():width(0),height(0),border(0),internalFormat(GL_RGBA),sourceEGLImage(0){ 
+        memset(crop_rect,0,4*sizeof(int)); 
+    };
 
     unsigned int width;
     unsigned int height;
     unsigned int border;
     unsigned int internalFormat;
     unsigned int sourceEGLImage;
+    int          crop_rect[4];
     void (*eglImageDetach)(unsigned int imageId);
 };
 
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/gldefs.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/gldefs.h
new file mode 100644
index 0000000..1cba3bf
--- /dev/null
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/gldefs.h
@@ -0,0 +1,27 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+typedef double      GLclampd;   /* double precision float in [0,1] */
+typedef double      GLdouble;   /* double precision float */
+
+#define GL_TEXTURE_GEN_S			0x0C60
+#define GL_TEXTURE_GEN_T			0x0C61
+#define GL_TEXTURE_GEN_R			0x0C62
+#define GL_CLIENT_VERTEX_ARRAY_BIT    0x00000002
+#define GL_TRANSFORM_BIT      0x00001000
+#define GL_INT                0x1404
+#define GL_HALF_FLOAT_NV      0x140B
+#define GL_HALF_FLOAT         0x140B
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h
index 2afc4bc..5f2e82c 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h
@@ -28,7 +28,6 @@
     RENDERBUFFER = 2,
     FRAMEBUFFER = 3,
     SHADER = 4,
-    PROGRAM = 5,
     NUM_OBJECT_TYPES = 6  // Must be last
 };
 
@@ -49,13 +48,14 @@
 //   NOTE: this class does not used by the EGL/GLES layer directly,
 //         the EGL/GLES layer creates objects using the ShareGroup class
 //         interface (see below).
+class GlobalNameSpace;
 class NameSpace
 {
     friend class ShareGroup;
     friend class GlobalNameSpace;
 
 private:
-    explicit NameSpace(NamedObjectType p_type);
+    NameSpace(NamedObjectType p_type, GlobalNameSpace *globalNameSpace);
     ~NameSpace();
 
     //
@@ -99,6 +99,54 @@
     unsigned int m_nextName;
     NamesMap m_localToGlobalMap;
     const NamedObjectType m_type;
+    GlobalNameSpace *m_globalNameSpace;
+};
+
+class GlobalNameSpace
+{
+public:
+    GlobalNameSpace()
+    {
+        mutex_init(&m_lock);
+
+        for (int i=0; i<NUM_OBJECT_TYPES; i++) {
+            m_nameSpace[i] = new NameSpace((NamedObjectType)i, NULL);
+        }
+
+    }
+
+    ~GlobalNameSpace()
+    {
+        mutex_lock(&m_lock);
+        for (int i=0; i<NUM_OBJECT_TYPES; i++) {
+            delete m_nameSpace[i];
+        }
+        mutex_unlock(&m_lock);
+        mutex_destroy(&m_lock);
+    }
+
+    unsigned int genName(NamedObjectType p_type)
+    {
+        if ( p_type >= NUM_OBJECT_TYPES ) return 0;
+
+        mutex_lock(&m_lock);
+        unsigned int name = m_nameSpace[p_type]->genName(0, false);
+        mutex_unlock(&m_lock);
+        return name;
+    }
+
+    void deleteName(NamedObjectType p_type, unsigned int p_name)
+    {
+        if ( p_type >= NUM_OBJECT_TYPES ) return;
+
+        mutex_lock(&m_lock);
+        m_nameSpace[p_type]->deleteName(p_name);
+        mutex_unlock(&m_lock);
+    }
+
+private:
+    mutex_t m_lock;
+    NameSpace *m_nameSpace[NUM_OBJECT_TYPES];
 };
 
 //
@@ -164,7 +212,7 @@
     ObjectDataPtr getObjectData(NamedObjectType p_type, unsigned int p_localName);
 
 private:
-    ShareGroup();
+    explicit ShareGroup(GlobalNameSpace *globalNameSpace);
     ~ShareGroup();
 
 private:
@@ -188,7 +236,7 @@
 class ObjectNameManager
 {
 public:
-    ObjectNameManager();
+    explicit ObjectNameManager(GlobalNameSpace *globalNameSpace);
     ~ObjectNameManager();
 
     //
@@ -227,6 +275,7 @@
 private:
     ShareGroupsMap m_groups;
     mutex_t m_lock;
+    GlobalNameSpace *m_globalNameSpace;
 };
 
 #endif
diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp
index 14e84b9..81ba067 100644
--- a/tools/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp
+++ b/tools/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp
@@ -24,15 +24,15 @@
 const GLuint FBConfig::s_configAttribs[] = {
     EGL_DEPTH_SIZE,     // must be first - see getDepthSize()
     EGL_STENCIL_SIZE,   // must be second - see getStencilSize()
-    EGL_RENDERABLE_TYPE, // must be third - see getRenderableType()
-    EGL_SURFACE_TYPE,  // must be fourth - see getSurfaceType()
+    EGL_RENDERABLE_TYPE,// must be third - see getRenderableType()
+    EGL_SURFACE_TYPE,   // must be fourth - see getSurfaceType()
+    EGL_CONFIG_ID,      // must be fifth  - see chooseConfig()
     EGL_BUFFER_SIZE,
     EGL_ALPHA_SIZE,
     EGL_BLUE_SIZE,
     EGL_GREEN_SIZE,
     EGL_RED_SIZE,
     EGL_CONFIG_CAVEAT,
-    EGL_CONFIG_ID,
     EGL_LEVEL,
     EGL_MAX_PBUFFER_HEIGHT,
     EGL_MAX_PBUFFER_PIXELS,
@@ -201,6 +201,52 @@
     }
 }
 
+int FBConfig::chooseConfig(FrameBuffer *fb, EGLint * attribs, uint32_t * configs, uint32_t configs_size)
+{
+    EGLDisplay dpy = fb->getDisplay();
+    int ret = 0;
+
+    if (dpy == EGL_NO_DISPLAY) {
+        fprintf(stderr,"Could not get EGL Display\n");
+        return ret;
+    }
+    //
+    // Query the num of configs in the EGL backend
+    //
+    EGLint nConfigs;
+    if (!s_egl.eglGetConfigs(dpy, NULL, 0, &nConfigs)) {
+        fprintf(stderr, "Could not get number of available configs\n");
+        return ret;
+    }
+    //
+    // Query the max matching configs in the backend
+    //
+    EGLConfig *matchedConfigs = new EGLConfig[nConfigs];
+    s_egl.eglChooseConfig(dpy, attribs, matchedConfigs, nConfigs, &nConfigs);
+
+    //
+    // From all matchedConfigs we need only config_size FBConfigs, so we intersect both lists compating the CONFIG_ID attribute
+    //
+    uint32_t nVerifiedCfgs = 0;
+    for (int matchedIdx=0; matchedIdx<nConfigs; matchedIdx++) {
+        if (nVerifiedCfgs >= configs_size) break; //We have enouhgt configs
+        int sCfgId;
+        s_egl.eglGetConfigAttrib(dpy, matchedConfigs[matchedIdx], EGL_CONFIG_ID, &sCfgId);
+        for (int fbIdx=0; fbIdx<s_numConfigs; fbIdx++) {
+            int dCfgId = s_fbConfigs[fbIdx]->m_attribValues[4]; //CONFIG_ID
+            if (sCfgId == dCfgId) {
+                //This config matches the requested attributes and filtered into fbConfigs, so we're happy with it
+                configs[nVerifiedCfgs++] = fbIdx;
+                break;
+            }
+        }
+    }
+
+    delete matchedConfigs;
+
+    return nVerifiedCfgs;
+}
+
 FBConfig::FBConfig(EGLDisplay p_eglDpy, EGLConfig p_eglCfg)
 {
     m_eglConfig = p_eglCfg;
diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/FBConfig.h b/tools/emulator/opengl/host/libs/libOpenglRender/FBConfig.h
index b898b37..8e0356a 100644
--- a/tools/emulator/opengl/host/libs/libOpenglRender/FBConfig.h
+++ b/tools/emulator/opengl/host/libs/libOpenglRender/FBConfig.h
@@ -35,6 +35,7 @@
     static int getNumConfigs();
     static int getNumAttribs() { return s_numConfigAttribs; }
     static void packConfigsInfo(GLuint *buffer);
+    static int chooseConfig(FrameBuffer *fb, EGLint * attribs, uint32_t * configs, uint32_t configs_size);
     ~FBConfig();
 
     EGLConfig getEGLConfig() const { return m_eglConfig; }
diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp
index 504d792..891c89b 100644
--- a/tools/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp
+++ b/tools/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp
@@ -78,6 +78,16 @@
     return nConfigs;
 }
 
+static EGLint rcChooseConfig(EGLint *attribs, uint32_t attribs_size, uint32_t *configs, uint32_t configs_size)
+{
+    FrameBuffer *fb = FrameBuffer::getFB();
+    if (!fb) {
+        return 0;
+    }
+
+    return FBConfig::chooseConfig(fb, attribs, configs, configs_size);
+}
+
 static EGLint rcGetFBParam(EGLint param)
 {
     FrameBuffer *fb = FrameBuffer::getFB();
@@ -252,6 +262,7 @@
     dec->set_rcQueryEGLString(rcQueryEGLString);
     dec->set_rcGetNumConfigs(rcGetNumConfigs);
     dec->set_rcGetConfigs(rcGetConfigs);
+    dec->set_rcChooseConfig(rcChooseConfig);
     dec->set_rcGetFBParam(rcGetFBParam);
     dec->set_rcCreateContext(rcCreateContext);
     dec->set_rcDestroyContext(rcDestroyContext);
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp
index 4623bf8..f07e9ae 100644
--- a/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp
@@ -169,6 +169,7 @@
     case GL_TEXTURE_2D:
     case GL_TEXTURE_BINDING_2D:
     case GL_TEXTURE_BINDING_CUBE_MAP:
+    case GL_TEXTURE_BINDING_EXTERNAL_OES:
     case GL_TEXTURE_COORD_ARRAY:
     case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING:
     case GL_TEXTURE_COORD_ARRAY_SIZE:
@@ -244,6 +245,8 @@
     case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
     case GL_MAX_RENDERBUFFER_SIZE:
     case GL_MAX_TEXTURE_IMAGE_UNITS:
+    case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
+    case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
         s = 1;
         break;
     case GL_ALIASED_LINE_WIDTH_RANGE:
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/EGLClientIface.h b/tools/emulator/opengl/system/OpenglSystemCommon/EGLClientIface.h
new file mode 100644
index 0000000..df66ba6
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/EGLClientIface.h
@@ -0,0 +1,23 @@
+#ifndef _SYSTEM_COMMON_EGL_CLIENT_IFACE_H
+#define _SYSTEM_COMMON_EGL_CLIENT_IFACE_H
+
+struct EGLThreadInfo;  // defined in ThreadInfo.h
+
+typedef struct {
+    EGLThreadInfo* (*getThreadInfo)();
+} EGLClient_eglInterface;
+
+typedef struct {
+    void* (*getProcAddress)(const char *funcName);
+    void (*finish)();
+} EGLClient_glesInterface;
+
+//
+// Any GLES/GLES2 client API library should define a function named "init_emul_gles"
+// with the following prototype,
+// It will be called by EGL after loading the GLES library for initialization
+// and exchanging interface function pointers.
+//
+typedef EGLClient_glesInterface *(*init_emul_gles_t)(EGLClient_eglInterface *eglIface);
+
+#endif
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/ThreadInfo.h b/tools/emulator/opengl/system/OpenglSystemCommon/ThreadInfo.h
index cdb66a1..82936cb 100644
--- a/tools/emulator/opengl/system/OpenglSystemCommon/ThreadInfo.h
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/ThreadInfo.h
@@ -22,10 +22,11 @@
 
 struct EGLThreadInfo
 {
-    EGLThreadInfo() : currentContext(NULL), hostConn(NULL) {}
+    EGLThreadInfo() : currentContext(NULL), hostConn(NULL), eglError(0) {}
 
     EGLContext_t *currentContext;
     HostConnection *hostConn;
+    int           eglError;
 };
 
 
diff --git a/tools/emulator/opengl/system/OpenglSystemCommon/gralloc_cb.h b/tools/emulator/opengl/system/OpenglSystemCommon/gralloc_cb.h
new file mode 100644
index 0000000..3bfabc8
--- /dev/null
+++ b/tools/emulator/opengl/system/OpenglSystemCommon/gralloc_cb.h
@@ -0,0 +1,76 @@
+#ifndef __GRALLOC_CB_H__
+#define __GRALLOC_CB_H__
+
+#include <hardware/hardware.h>
+#include <hardware/gralloc.h>
+#include <cutils/native_handle.h>
+
+#define BUFFER_HANDLE_MAGIC ((int)0xabfabfab)
+#define CB_HANDLE_NUM_INTS(nfds) ((sizeof(cb_handle_t) - (nfds)*sizeof(int)) / sizeof(int))
+
+//
+// Our buffer handle structure
+//
+struct cb_handle_t : public native_handle {
+
+    cb_handle_t(int p_fd, int p_ashmemSize, int p_usage,
+                int p_width, int p_height, int p_glFormat) :
+        fd(p_fd),
+        magic(BUFFER_HANDLE_MAGIC),
+        usage(p_usage),
+        width(p_width),
+        height(p_height),
+        glFormat(p_glFormat),
+        ashmemSize(p_ashmemSize),
+        ashmemBase(NULL),
+        ashmemBasePid(0),
+        mappedPid(0),
+        lockedLeft(0),
+        lockedTop(0),
+        lockedWidth(0),
+        lockedHeight(0),
+        hostHandle(0)
+    {
+        version = sizeof(native_handle);
+        numFds = 1;
+        numInts = CB_HANDLE_NUM_INTS(numFds);
+    }
+
+    ~cb_handle_t() {
+        magic = 0;
+    }
+
+    bool validate() const {
+        return (version == sizeof(native_handle) &&
+                magic == BUFFER_HANDLE_MAGIC &&
+                numInts == CB_HANDLE_NUM_INTS(1) &&
+                numFds == 1);
+    }
+
+    bool canBePosted() {
+        return (0 != (usage & GRALLOC_USAGE_HW_FB));
+    }
+
+    // file-descriptors
+    int fd;  // ashmem fd (-1 of ashmem region did not allocated, i.e. no SW access needed)
+
+    // ints
+    int magic;              // magic number in order to validate a pointer to be a cb_handle_t
+    int usage;              // usage bits the buffer was created with
+    int width;              // buffer width
+    int height;             // buffer height
+    int glFormat;           // OpenGL format enum used for host h/w color buffer
+    int ashmemSize;         // ashmem region size for the buffer (0 unless is HW_FB buffer or
+                            //                                    s/w access is needed)
+    int ashmemBase;         // CPU address of the mapped ashmem region
+    int ashmemBasePid;      // process id which mapped the ashmem region
+    int mappedPid;          // process id which succeeded gralloc_register call
+    int lockedLeft;         // region of buffer locked for s/w write
+    int lockedTop;
+    int lockedWidth;
+    int lockedHeight;
+    uint32_t hostHandle;
+};
+
+
+#endif //__GRALLOC_CB_H__
diff --git a/tools/emulator/opengl/system/egl/Android.mk b/tools/emulator/opengl/system/egl/Android.mk
new file mode 100644
index 0000000..10a52bc
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/Android.mk
@@ -0,0 +1,51 @@
+ifneq (,$(BUILD_EMULATOR_OPENGL_DRIVER))
+
+LOCAL_PATH := $(call my-dir)
+emulatorOpengl := $(LOCAL_PATH)/../..
+
+### EGL implementation ###########################################
+include $(CLEAR_VARS)
+
+# add additional depencies to ensure that the generated code that we depend on
+# is generated
+LOCAL_ADDITIONAL_DEPENDENCIES := \
+	$(TARGET_OUT_SHARED_LIBRARIES)/lib_renderControl_enc$(TARGET_SHLIB_SUFFIX) \
+	$(TARGET_OUT_SHARED_LIBRARIES)/libGLESv1_enc$(TARGET_SHLIB_SUFFIX)
+
+LOCAL_SRC_FILES := \
+        eglDisplay.cpp \
+        egl.cpp
+
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS += -DLOG_TAG=\"EGL_emulation\" -DEGL_EGLEXT_PROTOTYPES
+LOCAL_C_INCLUDES +=  \
+        $(emulatorOpengl)/host/include/libOpenglRender \
+        $(emulatorOpengl)/shared/OpenglCodecCommon \
+        $(emulatorOpengl)/system/OpenglSystemCommon \
+        $(emulatorOpengl)/system/GLESv1_enc \
+        $(emulatorOpengl)/system/renderControl_enc \
+		$(call intermediates-dir-for, SHARED_LIBRARIES, lib_renderControl_enc) \
+		$(call intermediates-dir-for, SHARED_LIBRARIES, libGLESv1_enc)
+
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := libEGL_emulation
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+
+
+LOCAL_STATIC_LIBRARIES := \
+    libOpenglSystemCommon \
+    libOpenglCodecCommon \
+	libqemu
+
+LOCAL_SHARED_LIBRARIES := \
+    libcutils \
+	libutils \
+	libdl	\
+    libGLESv1_enc \
+    lib_renderControl_enc
+
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif # of ifneq (,$(BUILD_EMULATOR_OPENGL_DRIVER))
diff --git a/tools/emulator/opengl/system/egl/egl.cpp b/tools/emulator/opengl/system/egl/egl.cpp
new file mode 100644
index 0000000..5427363
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/egl.cpp
@@ -0,0 +1,1012 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#include "HostConnection.h"
+#include "ThreadInfo.h"
+#include "eglDisplay.h"
+#include "egl_ftable.h"
+#include <cutils/log.h>
+#include "gralloc_cb.h"
+
+#include <private/ui/android_natives_priv.h>
+
+template<typename T>
+static T setError(GLint error, T returnValue) {
+    getEGLThreadInfo()->eglError = error;
+    return returnValue;
+}
+
+#define RETURN_ERROR(ret,err)           \
+    getEGLThreadInfo()->eglError = err; \
+    return ret;
+
+#define VALIDATE_CONFIG(cfg,ret) \
+    if(((int)cfg<0)||((int)cfg>s_display.getNumConfigs())) { \
+        RETURN_ERROR(ret,EGL_BAD_CONFIG); \
+    }
+
+#define VALIDATE_DISPLAY(dpy,ret) \
+    if ((dpy) != (EGLDisplay)&s_display) { \
+        getEGLThreadInfo()->eglError = EGL_BAD_DISPLAY; \
+        return ret; \
+    }
+
+#define VALIDATE_DISPLAY_INIT(dpy,ret) \
+    VALIDATE_DISPLAY(dpy, ret)    \
+    if (!s_display.initialized()) {        \
+        getEGLThreadInfo()->eglError = EGL_NOT_INITIALIZED;    \
+        return ret; \
+    }
+
+#define DEFINE_HOST_CONNECTION \
+    HostConnection *hostCon = HostConnection::get(); \
+    renderControl_encoder_context_t *rcEnc = (hostCon ? hostCon->rcEncoder() : NULL)
+
+#define DEFINE_AND_VALIDATE_HOST_CONNECTION(ret) \
+    HostConnection *hostCon = HostConnection::get(); \
+    if (!hostCon) { \
+        LOGE("egl: Failed to get host connection\n"); \
+        return ret; \
+    } \
+    renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \
+    if (!rcEnc) { \
+        LOGE("egl: Failed to get renderControl encoder context\n"); \
+        return ret; \
+    }
+
+#define VALIDATE_CONTEXT_RETURN(context,ret)        \
+    if (!context) {                                    \
+        RETURN_ERROR(ret,EGL_BAD_CONTEXT);    \
+    }
+
+#define VALIDATE_SURFACE_RETURN(surface, ret)    \
+    if (surface != EGL_NO_SURFACE) {    \
+        egl_surface_t* s( static_cast<egl_surface_t*>(surface) );    \
+        if (!s->isValid())    \
+            return setError(EGL_BAD_SURFACE, EGL_FALSE);    \
+        if (s->dpy != (EGLDisplay)&s_display)    \
+            return setError(EGL_BAD_DISPLAY, EGL_FALSE);    \
+    }
+
+
+// ----------------------------------------------------------------------------
+//EGLContext_t
+
+struct EGLContext_t {
+
+    enum {
+        IS_CURRENT      =   0x00010000,
+        NEVER_CURRENT   =   0x00020000
+    };
+
+    EGLContext_t(EGLDisplay dpy, EGLConfig config) : dpy(dpy), config(config),
+        read(EGL_NO_SURFACE), draw(EGL_NO_SURFACE),
+        rcContext(0) {
+            flags = 0;
+            version = 1;
+        };
+    ~EGLContext_t(){};
+    uint32_t            flags;
+    EGLDisplay          dpy;
+    EGLConfig           config;
+    EGLSurface          read;
+    EGLSurface          draw;
+    EGLint                version;
+    uint32_t             rcContext;
+};
+
+// ----------------------------------------------------------------------------
+//egl_surface_t
+
+//we don't need to handle depth since it's handled when window created on the host
+
+struct egl_surface_t {
+
+    EGLDisplay          dpy;
+    EGLConfig           config;
+
+    egl_surface_t(EGLDisplay dpy, EGLConfig config);
+    virtual     ~egl_surface_t();
+
+    virtual     EGLBoolean         rcCreate() = 0;
+    virtual     EGLBoolean         rcDestroy() = 0;
+
+    virtual     EGLBoolean  connect() { return EGL_TRUE; }
+    virtual     void        disconnect() {}
+    virtual     EGLBoolean     swapBuffers() { return EGL_TRUE; }
+
+    void         setRcSurface(uint32_t handle){ rcSurface = handle; }
+    uint32_t     getRcSurface(){ return rcSurface; }
+
+    virtual     EGLBoolean    isValid(){ return valid; }
+    virtual     EGLint      getWidth() const = 0;
+    virtual     EGLint      getHeight() const = 0;
+
+protected:
+    EGLBoolean    valid;
+    uint32_t     rcSurface; //handle to surface created via remote control
+};
+
+egl_surface_t::egl_surface_t(EGLDisplay dpy, EGLConfig config)
+    : dpy(dpy), config(config), valid(EGL_FALSE), rcSurface(0)
+{
+}
+
+egl_surface_t::~egl_surface_t()
+{
+}
+
+// ----------------------------------------------------------------------------
+// egl_window_surface_t
+
+struct egl_window_surface_t : public egl_surface_t {
+
+    egl_window_surface_t(
+            EGLDisplay dpy, EGLConfig config,
+            ANativeWindow* window);
+
+    ~egl_window_surface_t();
+
+    virtual     EGLBoolean     rcCreate();
+    virtual     EGLBoolean     rcDestroy();
+
+    virtual     EGLBoolean  connect();
+    virtual     void        disconnect();
+    virtual     EGLBoolean  swapBuffers();
+
+    virtual     EGLint      getWidth() const    { return width;  }
+    virtual     EGLint      getHeight() const   { return height; }
+
+
+private:
+    ANativeWindow*     nativeWindow;
+    int width;
+    int height;
+    android_native_buffer_t*   buffer;
+
+};
+
+
+egl_window_surface_t::egl_window_surface_t (
+            EGLDisplay dpy, EGLConfig config,
+            ANativeWindow* window)
+    : egl_surface_t(dpy, config),
+    nativeWindow(window),
+    buffer(NULL)
+{
+    // keep a reference on the window
+    nativeWindow->common.incRef(&nativeWindow->common);
+    nativeWindow->query(nativeWindow, NATIVE_WINDOW_WIDTH, &width);
+    nativeWindow->query(nativeWindow, NATIVE_WINDOW_HEIGHT, &height);
+}
+
+egl_window_surface_t::~egl_window_surface_t() {
+    nativeWindow->common.decRef(&nativeWindow->common);
+}
+
+EGLBoolean egl_window_surface_t::rcCreate()
+{
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+    uint32_t rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uint32_t)config, getWidth(), getHeight());
+    if (!rcSurface) {
+        LOGE("rcCreateWindowSurface returned 0");
+        return EGL_FALSE;
+    }
+    valid = EGL_TRUE;
+    return EGL_TRUE;
+}
+
+EGLBoolean egl_window_surface_t::rcDestroy()
+{
+    if (!rcSurface) {
+        LOGE("rcDestroy called on invalid rcSurface");
+        return EGL_FALSE;
+    }
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+    rcEnc->rcDestroyWindowSurface(rcEnc, rcSurface);
+    rcSurface = 0;
+
+    return EGL_TRUE;
+}
+
+EGLBoolean egl_window_surface_t::connect()
+{
+    // dequeue a buffer
+    if (nativeWindow->dequeueBuffer(nativeWindow, &buffer) != NO_ERROR) {
+        return setError(EGL_BAD_ALLOC, EGL_FALSE);
+    }
+    buffer->common.incRef(&buffer->common);
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+    rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface, ((cb_handle_t *)(buffer->handle))->hostHandle);
+
+    return EGL_TRUE;
+}
+
+void egl_window_surface_t::disconnect()
+{
+    if (buffer) {
+        nativeWindow->queueBuffer(nativeWindow, buffer);
+        buffer->common.decRef(&buffer->common);
+        buffer = 0;
+    }
+}
+
+EGLBoolean egl_window_surface_t::swapBuffers()
+{
+    if (!buffer) {
+        return setError(EGL_BAD_ACCESS, EGL_FALSE);
+    }
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+
+    //post the back buffer
+    nativeWindow->queueBuffer(nativeWindow, buffer);
+
+    // dequeue a new buffer
+    if (nativeWindow->dequeueBuffer(nativeWindow, &buffer)) {
+        return setError(EGL_BAD_ALLOC, EGL_FALSE);
+    }
+
+    rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface, ((cb_handle_t *)(buffer->handle))->hostHandle);
+
+    return EGL_TRUE;
+}
+
+// ----------------------------------------------------------------------------
+//egl_pbuffer_surface_t
+
+struct egl_pbuffer_surface_t : public egl_surface_t {
+
+    int width;
+    int height;
+    GLenum    format;
+
+    virtual     EGLint      getWidth() const    { return width;  }
+    virtual     EGLint      getHeight() const   { return height; }
+
+    egl_pbuffer_surface_t(
+            EGLDisplay dpy, EGLConfig config,
+            int32_t w, int32_t h, GLenum format);
+
+    virtual ~egl_pbuffer_surface_t();
+    virtual     EGLBoolean     rcCreate();
+    virtual     EGLBoolean     rcDestroy();
+
+    virtual     EGLBoolean    connect();
+
+    uint32_t    getRcColorBuffer(){ return rcColorBuffer; }
+    void         setRcColorBuffer(uint32_t colorBuffer){ rcColorBuffer = colorBuffer; }
+private:
+    uint32_t rcColorBuffer;
+};
+
+egl_pbuffer_surface_t::egl_pbuffer_surface_t(
+        EGLDisplay dpy, EGLConfig config,
+        int32_t w, int32_t h, GLenum pixelFormat)
+    : egl_surface_t(dpy, config),
+    width(w), height(h), format(pixelFormat)
+{
+}
+
+egl_pbuffer_surface_t::~egl_pbuffer_surface_t()
+{
+    rcColorBuffer = 0;
+}
+
+EGLBoolean egl_pbuffer_surface_t::rcCreate()
+{
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+    rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uint32_t)config, getWidth(), getHeight());
+    if (!rcSurface) {
+        LOGE("rcCreateWindowSurface returned 0");
+        return EGL_FALSE;
+    }
+    rcColorBuffer = rcEnc->rcCreateColorBuffer(rcEnc, getWidth(), getHeight(), format);
+    if (!rcColorBuffer) {
+        LOGE("rcCreateColorBuffer returned 0");
+        return EGL_FALSE;
+    }
+
+    valid = EGL_TRUE;
+    return EGL_TRUE;
+}
+
+EGLBoolean egl_pbuffer_surface_t::rcDestroy()
+{
+    if ((!rcSurface)||(!rcColorBuffer)) {
+        LOGE("destroyRc called on invalid rcSurface");
+        return EGL_FALSE;
+    }
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+    rcEnc->rcDestroyWindowSurface(rcEnc, rcSurface);
+    rcEnc->rcDestroyColorBuffer(rcEnc, rcColorBuffer);
+    rcSurface = 0;
+
+    return EGL_TRUE;
+}
+
+EGLBoolean egl_pbuffer_surface_t::connect()
+{
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+    rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface, rcColorBuffer);
+
+    return EGL_TRUE;
+}
+
+// ----------------------------------------------------------------------------
+
+// The one and only supported display object.
+static eglDisplay s_display;
+
+static EGLClient_eglInterface s_eglIface = {
+    getThreadInfo: getEGLThreadInfo
+};
+EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id)
+{
+    //
+    // we support only EGL_DEFAULT_DISPLAY.
+    //
+    if (display_id != EGL_DEFAULT_DISPLAY) {
+        return EGL_NO_DISPLAY;
+    }
+
+    return (EGLDisplay)&s_display;
+}
+
+EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
+{
+    VALIDATE_DISPLAY(dpy,EGL_FALSE);
+
+    if (!s_display.initialize(&s_eglIface)) {
+        return EGL_FALSE;
+    }
+
+    *major = s_display.getVersionMajor();
+    *minor = s_display.getVersionMinor();
+    return EGL_TRUE;
+}
+
+EGLBoolean eglTerminate(EGLDisplay dpy)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+
+    s_display.terminate();
+    return EGL_TRUE;
+}
+
+EGLint eglGetError()
+{
+    return getEGLThreadInfo()->eglError;
+}
+
+__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
+{
+    // search in EGL function table
+    for (int i=0; i<egl_num_funcs; i++) {
+        if (!strcmp(egl_funcs_by_name[i].name, procname)) {
+            return (__eglMustCastToProperFunctionPointerType)egl_funcs_by_name[i].proc;
+        }
+    }
+
+    //
+    // Make sure display is initialized before searching in client APIs
+    //
+    if (!s_display.initialized()) {
+        if (!s_display.initialize(&s_eglIface)) {
+            return NULL;
+        }
+    }
+
+    // look in gles
+    void *proc = s_display.gles_iface()->getProcAddress( procname );
+    if (proc != NULL) {
+        return (__eglMustCastToProperFunctionPointerType)proc;
+    }
+
+    // look in gles2
+    if (s_display.gles2_iface() != NULL) {
+        proc = s_display.gles2_iface()->getProcAddress( procname );
+        if (proc != NULL) {
+            return (__eglMustCastToProperFunctionPointerType)proc;
+        }
+    }
+
+    // Fail - function not found.
+    return NULL;
+}
+
+const char* eglQueryString(EGLDisplay dpy, EGLint name)
+{
+    VALIDATE_DISPLAY_INIT(dpy, NULL);
+
+    return s_display.queryString(name);
+}
+
+EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+{
+    VALIDATE_DISPLAY_INIT(dpy, NULL);
+
+    if(!num_config) {
+        RETURN_ERROR(EGL_FALSE,EGL_BAD_PARAMETER);
+    }
+
+    GLint numConfigs = s_display.getNumConfigs();
+    if (!configs) {
+        *num_config = numConfigs;
+        return EGL_TRUE;
+    }
+
+    int i=0;
+    for (i=0 ; i<numConfigs && i<config_size ; i++) {
+        *configs++ = (EGLConfig)i;
+    }
+    *num_config = i;
+    return EGL_TRUE;
+}
+
+EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+
+    int attribs_size = 0;
+    if (attrib_list) {
+        const EGLint * attrib_p = attrib_list;
+        while (attrib_p[0] != EGL_NONE) {
+            attribs_size += 2;
+            attrib_p += 2;
+        }
+        attribs_size++; //for the terminating EGL_NONE
+    }
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+    *num_config = rcEnc->rcChooseConfig(rcEnc, (EGLint*)attrib_list, attribs_size, (uint32_t*)configs, config_size);
+
+    return EGL_TRUE;
+}
+
+EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
+{
+    VALIDATE_DISPLAY_INIT(dpy, NULL);
+    VALIDATE_CONFIG(config, EGL_FALSE);
+
+    if (s_display.getConfigAttrib(config, attribute, value))
+    {
+        return EGL_TRUE;
+    }
+    else
+    {
+        RETURN_ERROR(EGL_FALSE, EGL_BAD_ATTRIBUTE);
+    }
+}
+
+EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
+{
+    VALIDATE_DISPLAY_INIT(dpy, NULL);
+    VALIDATE_CONFIG(config, EGL_FALSE);
+    if (win == 0) {
+        return setError(EGL_BAD_MATCH, EGL_NO_SURFACE);
+    }
+
+    EGLint surfaceType;
+    if (s_display.getConfigAttrib(config, EGL_SURFACE_TYPE, &surfaceType) == EGL_FALSE)    return EGL_FALSE;
+
+    if (!(surfaceType & EGL_WINDOW_BIT)) {
+        return setError(EGL_BAD_MATCH, EGL_NO_SURFACE);
+    }
+
+    if (static_cast<ANativeWindow*>(win)->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) {
+        return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
+    }
+
+    egl_surface_t* surface;
+    surface = new egl_window_surface_t(&s_display, config, static_cast<ANativeWindow*>(win));
+    if (!surface)
+        return setError(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+    if (!surface->rcCreate()) {
+        delete surface;
+        return setError(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+    }
+
+    return surface;
+}
+
+EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
+{
+    VALIDATE_DISPLAY_INIT(dpy, NULL);
+    VALIDATE_CONFIG(config, EGL_FALSE);
+
+    EGLint surfaceType;
+    if (s_display.getConfigAttrib(config, EGL_SURFACE_TYPE, &surfaceType) == EGL_FALSE)    return EGL_FALSE;
+
+    if (!(surfaceType & EGL_PBUFFER_BIT)) {
+        return setError(EGL_BAD_MATCH, EGL_NO_SURFACE);
+    }
+
+    int32_t w = 0;
+    int32_t h = 0;
+    while (attrib_list[0]) {
+        if (attrib_list[0] == EGL_WIDTH)  w = attrib_list[1];
+        if (attrib_list[0] == EGL_HEIGHT) h = attrib_list[1];
+        attrib_list+=2;
+    }
+    // TODO: check EGL_TEXTURE_FORMAT - need to support eglBindTexImage
+
+    GLenum pixelFormat;
+    if (s_display.getConfigPixelFormat(config, &pixelFormat) == EGL_FALSE)
+        return setError(EGL_BAD_MATCH, EGL_NO_SURFACE);
+
+    egl_surface_t* surface = new egl_pbuffer_surface_t(dpy, config, w, h, pixelFormat);
+    if (!surface)
+        return setError(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+    if (!surface->rcCreate()) {
+        delete surface;
+        return setError(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+    }
+
+    return surface;
+}
+
+EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
+{
+    //XXX: Pixmap not supported. The host cannot render to a pixmap resource
+    //     located on host. In order to support Pixmaps we should either punt
+    //     to s/w rendering -or- let the host render to a buffer that will be
+    //     copied back to guest at some sync point. None of those methods not
+    //     implemented and pixmaps are not used with OpenGL anyway ...
+    return EGL_NO_SURFACE;
+}
+
+EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface eglSurface)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    VALIDATE_SURFACE_RETURN(eglSurface, EGL_FALSE);
+
+    egl_surface_t* surface( static_cast<egl_surface_t*>(eglSurface) );
+
+    surface->disconnect();
+    surface->rcDestroy();
+    delete surface;
+
+    return EGL_TRUE;
+}
+
+EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface eglSurface, EGLint attribute, EGLint *value)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    VALIDATE_SURFACE_RETURN(eglSurface, EGL_FALSE);
+
+    egl_surface_t* surface( static_cast<egl_surface_t*>(eglSurface) );
+    EGLBoolean ret = EGL_TRUE;
+    switch (attribute) {
+        case EGL_CONFIG_ID:
+            ret = s_display.getConfigAttrib(surface->config, EGL_CONFIG_ID, value);
+            break;
+        case EGL_WIDTH:
+            *value = surface->getWidth();
+            break;
+        case EGL_HEIGHT:
+            *value = surface->getHeight();
+            break;
+            //TODO: complete other attributes
+        default:
+            ret = setError(EGL_BAD_ATTRIBUTE, EGL_FALSE);
+            break;
+    }
+
+    return ret;
+}
+
+EGLBoolean eglBindAPI(EGLenum api)
+{
+    if (api != EGL_OPENGL_ES_API)
+        return setError(EGL_BAD_PARAMETER, EGL_FALSE);
+    return EGL_TRUE;
+}
+
+EGLenum eglQueryAPI()
+{
+    return EGL_OPENGL_ES_API;
+}
+
+EGLBoolean eglWaitClient()
+{
+    return eglWaitGL();
+}
+
+EGLBoolean eglReleaseThread()
+{
+    EGLThreadInfo *tInfo = getEGLThreadInfo();
+    if (tInfo && tInfo->currentContext) {
+        return eglMakeCurrent(&s_display, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE);
+    }
+    return EGL_TRUE;
+}
+
+EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
+{
+    //TODO
+    LOGW("%s not implemented", __FUNCTION__);
+    return 0;
+}
+
+EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
+{
+    //TODO
+    LOGW("%s not implemented", __FUNCTION__);
+    return 0;
+}
+
+EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+{
+    //TODO
+    LOGW("%s not implemented", __FUNCTION__);
+    return 0;
+}
+
+EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+{
+    //TODO
+    LOGW("%s not implemented", __FUNCTION__);
+    return 0;
+}
+
+EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
+{
+    //TODO
+    LOGW("%s not implemented", __FUNCTION__);
+    return 0;
+}
+
+EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_NO_CONTEXT);
+    VALIDATE_CONFIG(config, EGL_NO_CONTEXT);
+
+    EGLint version = 1; //default
+    while (attrib_list[0]) {
+        if (attrib_list[0] == EGL_CONTEXT_CLIENT_VERSION) version = attrib_list[1];
+        attrib_list+=2;
+    }
+
+    uint32_t rcShareCtx = 0;
+    if (share_context) {
+        EGLContext_t * shareCtx = static_cast<EGLContext_t*>(share_context);
+        rcShareCtx = shareCtx->rcContext;
+        if (shareCtx->dpy != dpy)
+            return setError(EGL_BAD_MATCH, EGL_NO_CONTEXT);
+    }
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_NO_CONTEXT);
+    uint32_t rcContext = rcEnc->rcCreateContext(rcEnc, (uint32_t)config, rcShareCtx, version);
+    if (!rcContext) {
+        LOGE("rcCreateContext returned 0");
+        return setError(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
+    }
+
+    EGLContext_t * context = new EGLContext_t(dpy, config);
+    if (!context)
+        return setError(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
+
+    context->version = version;
+    context->rcContext = rcContext;
+
+
+    return context;
+}
+
+EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    VALIDATE_CONTEXT_RETURN(ctx, EGL_FALSE);
+
+    EGLContext_t * context = static_cast<EGLContext_t*>(ctx);
+
+    if (getEGLThreadInfo()->currentContext == context)
+    {
+        eglMakeCurrent(dpy, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE);
+    }
+
+    if (context->rcContext) {
+        DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+        rcEnc->rcDestroyContext(rcEnc, context->rcContext);
+        context->rcContext = 0;
+    }
+
+    delete context;
+    return EGL_TRUE;
+}
+
+EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    VALIDATE_SURFACE_RETURN(draw, EGL_FALSE);
+    VALIDATE_SURFACE_RETURN(read, EGL_FALSE);
+
+    if ((read == EGL_NO_SURFACE && draw == EGL_NO_SURFACE) && (ctx != EGL_NO_CONTEXT))
+        return setError(EGL_BAD_MATCH, EGL_FALSE);
+    if ((read != EGL_NO_SURFACE || draw != EGL_NO_SURFACE) && (ctx == EGL_NO_CONTEXT))
+        return setError(EGL_BAD_MATCH, EGL_FALSE);
+
+    EGLContext_t * context = static_cast<EGLContext_t*>(ctx);
+    uint32_t ctxHandle = (context) ? context->rcContext : 0;
+    egl_surface_t * drawSurf = static_cast<egl_surface_t *>(draw);
+    uint32_t drawHandle = (drawSurf) ? drawSurf->getRcSurface() : 0;
+    egl_surface_t * readSurf = static_cast<egl_surface_t *>(read);
+    uint32_t readHandle = (readSurf) ? readSurf->getRcSurface() : 0;
+
+    //
+    // Nothing to do if no binding change has made
+    //
+    EGLThreadInfo *tInfo = getEGLThreadInfo();
+    if (tInfo->currentContext == context &&
+        context &&
+        context->draw == draw &&
+        context->read == read) {
+        return EGL_TRUE;
+    }
+
+    if (context && (context->flags & EGLContext_t::IS_CURRENT) && (context != tInfo->currentContext)) {
+        //context is current to another thread
+        return setError(EGL_BAD_ACCESS, EGL_FALSE);
+    }
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+    if (rcEnc->rcMakeCurrent(rcEnc, ctxHandle, drawHandle, readHandle) == EGL_FALSE) {
+        LOGE("rcMakeCurrent returned EGL_FALSE");
+        return setError(EGL_BAD_CONTEXT, EGL_FALSE);
+    }
+
+    //
+    // Disconnect from the previous drawable
+    //
+    if (tInfo->currentContext && tInfo->currentContext->draw) {
+        egl_surface_t * prevDrawSurf = static_cast<egl_surface_t *>(tInfo->currentContext->draw);
+        prevDrawSurf->disconnect();
+    }
+
+    //Now make the local bind
+    if (context) {
+        context->draw = draw;
+        context->read = read;
+        context->flags |= EGLContext_t::IS_CURRENT;
+    }
+
+    if (tInfo->currentContext)
+        tInfo->currentContext->flags &= ~EGLContext_t::IS_CURRENT;
+
+    //Now make current
+    tInfo->currentContext = context;
+
+
+    //connect the color buffer
+    if (drawSurf)
+        drawSurf->connect();
+
+    return EGL_TRUE;
+}
+
+EGLContext eglGetCurrentContext()
+{
+    return getEGLThreadInfo()->currentContext;
+}
+
+EGLSurface eglGetCurrentSurface(EGLint readdraw)
+{
+    EGLContext_t * context = getEGLThreadInfo()->currentContext;
+    if (!context)
+        return EGL_NO_SURFACE; //not an error
+
+    switch (readdraw) {
+        case EGL_READ:
+            return context->read;
+        case EGL_DRAW:
+            return context->draw;
+        default:
+            return setError(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
+    }
+}
+
+EGLDisplay eglGetCurrentDisplay()
+{
+    EGLContext_t * context = getEGLThreadInfo()->currentContext;
+    if (!context)
+        return EGL_NO_DISPLAY; //not an error
+
+    return context->dpy;
+}
+
+EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    VALIDATE_CONTEXT_RETURN(ctx, EGL_FALSE);
+
+    EGLContext_t * context = static_cast<EGLContext_t*>(ctx);
+
+    EGLBoolean ret = EGL_TRUE;
+    switch (attribute) {
+        case EGL_CONFIG_ID:
+            ret = s_display.getConfigAttrib(context->config, EGL_CONFIG_ID, value);
+            break;
+        case EGL_CONTEXT_CLIENT_TYPE:
+            *value = EGL_OPENGL_ES_API;
+            break;
+        case EGL_CONTEXT_CLIENT_VERSION:
+            *value = context->version;
+            break;
+        case EGL_RENDER_BUFFER:
+            if (!context->draw)
+                *value = EGL_NONE;
+            else
+                *value = EGL_BACK_BUFFER; //single buffer not supported
+            break;
+        default:
+            return setError(EGL_BAD_ATTRIBUTE, EGL_FALSE);
+    }
+
+    return ret;
+}
+
+EGLBoolean eglWaitGL()
+{
+    EGLThreadInfo *tInfo = getEGLThreadInfo();
+    if (!tInfo || !tInfo->currentContext) {
+        return EGL_FALSE;
+    }
+
+    if (tInfo->currentContext->version == 2) {
+        s_display.gles2_iface()->finish();
+    }
+    else {
+        s_display.gles_iface()->finish();
+    }
+
+    return EGL_TRUE;
+}
+
+EGLBoolean eglWaitNative(EGLint engine)
+{
+    return EGL_TRUE;
+}
+
+EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface eglSurface)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+    if (eglSurface == EGL_NO_SURFACE)
+        return setError(EGL_BAD_SURFACE, EGL_FALSE);
+
+    DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
+
+    egl_surface_t* d = static_cast<egl_surface_t*>(eglSurface);
+    if (!d->isValid())
+        return setError(EGL_BAD_SURFACE, EGL_FALSE);
+    if (d->dpy != dpy)
+        return setError(EGL_BAD_DISPLAY, EGL_FALSE);
+
+    // post the surface
+    d->swapBuffers();
+
+    hostCon->flush();
+    return EGL_TRUE;
+}
+
+EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
+{
+    //TODO :later
+    return 0;
+}
+
+EGLBoolean eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list)
+{
+    //TODO later
+    return 0;
+}
+
+EGLBoolean eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface)
+{
+    //TODO later
+    return 0;
+}
+
+EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_NO_IMAGE_KHR);
+
+    if (ctx != EGL_NO_CONTEXT) {
+        return setError(EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR);
+    }
+    if (target != EGL_NATIVE_BUFFER_ANDROID) {
+        return setError(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+    }
+
+    android_native_buffer_t* native_buffer = (android_native_buffer_t*)buffer;
+
+    if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC)
+        return setError(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+
+    if (native_buffer->common.version != sizeof(android_native_buffer_t))
+        return setError(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+
+    switch (native_buffer->format) {
+        case HAL_PIXEL_FORMAT_RGBA_8888:
+        case HAL_PIXEL_FORMAT_RGBX_8888:
+        case HAL_PIXEL_FORMAT_RGB_888:
+        case HAL_PIXEL_FORMAT_RGB_565:
+        case HAL_PIXEL_FORMAT_BGRA_8888:
+        case HAL_PIXEL_FORMAT_RGBA_5551:
+        case HAL_PIXEL_FORMAT_RGBA_4444:
+            break;
+        default:
+            return setError(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
+    }
+
+    native_buffer->common.incRef(&native_buffer->common);
+    return (EGLImageKHR)native_buffer;
+}
+
+EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img)
+{
+    VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE);
+
+    android_native_buffer_t* native_buffer = (android_native_buffer_t*)img;
+
+    if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC)
+        return setError(EGL_BAD_PARAMETER, EGL_FALSE);
+
+    if (native_buffer->common.version != sizeof(android_native_buffer_t))
+        return setError(EGL_BAD_PARAMETER, EGL_FALSE);
+
+    native_buffer->common.decRef(&native_buffer->common);
+
+    return EGL_TRUE;
+}
+
+EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
+{
+    //TODO later
+    return 0;
+}
+
+EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
+{
+    //TODO later
+    return 0;
+}
+
+EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
+{
+    //TODO
+    return 0;
+}
+
+EGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode)
+{
+    //TODO later
+    return 0;
+}
+
+EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)
+{
+    //TODO later
+    return 0;
+}
+
+EGLBoolean eglSetSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height)
+{
+    //TODO later
+    return 0;
+}
diff --git a/tools/emulator/opengl/system/egl/eglDisplay.cpp b/tools/emulator/opengl/system/egl/eglDisplay.cpp
new file mode 100644
index 0000000..30974a7
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/eglDisplay.cpp
@@ -0,0 +1,415 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#include "eglDisplay.h"
+#include "HostConnection.h"
+#include <dlfcn.h>
+
+static const int systemEGLVersionMajor = 1;
+static const int systemEGLVersionMinor = 4;
+static const char *systemEGLVendor = "Google Android emulator";
+
+// list of extensions supported by this EGL implementation
+//  NOTE that each extension name should be suffixed with space
+static const char *systemStaticEGLExtensions =
+            "EGL_ANDROID_image_native_buffer ";
+
+// list of extensions supported by this EGL implementation only if supported
+// on the host implementation.
+//  NOTE that each extension name should be suffixed with space
+static const char *systemDynamicEGLExtensions =
+            "EGL_KHR_image_base "
+            "EGL_KHR_gl_texture_2d_image ";
+
+
+static void *s_gles_lib = NULL;
+static void *s_gles2_lib = NULL;
+
+// The following function will be called when we (libEGL)
+// gets unloaded
+// At this point we want to unload the gles libraries we
+// might have loaded during initialization
+static void __attribute__ ((destructor)) do_on_unload(void)
+{
+    if (s_gles_lib) {
+        dlclose(s_gles_lib);
+    }
+
+    if (s_gles2_lib) {
+        dlclose(s_gles2_lib);
+    }
+}
+
+eglDisplay::eglDisplay() :
+    m_initialized(false),
+    m_major(0),
+    m_minor(0),
+    m_hostRendererVersion(0),
+    m_numConfigs(0),
+    m_numConfigAttribs(0),
+    m_attribs(DefaultKeyedVector<EGLint, EGLint>(ATTRIBUTE_NONE)),
+    m_configs(NULL),
+    m_gles_iface(NULL),
+    m_gles2_iface(NULL),
+    m_versionString(NULL),
+    m_vendorString(NULL),
+    m_extensionString(NULL)
+{
+    pthread_mutex_init(&m_lock, NULL);
+}
+
+bool eglDisplay::initialize(EGLClient_eglInterface *eglIface)
+{
+    pthread_mutex_lock(&m_lock);
+    if (!m_initialized) {
+
+        //
+        // load GLES client API
+        //
+        m_gles_iface = loadGLESClientAPI("/system/lib/egl/libGLESv1_CM_emulation.so",
+                                         eglIface,
+                                         &s_gles_lib);
+        if (!m_gles_iface) {
+            pthread_mutex_unlock(&m_lock);
+            return false;
+        }
+
+#ifdef WITH_GLES2
+        m_gles2_iface = loadGLESClientAPI("/system/lib/egl/libGLESv2_emulation.so",
+                                          eglIface,
+                                          &s_gles2_lib);
+        // Note that if loading gles2 failed, we can still run with no
+        // GLES2 support, having GLES2 is not mandatory.
+#endif
+
+        //
+        // establish connection with the host
+        //
+        HostConnection *hcon = HostConnection::get();
+        if (!hcon) {
+            pthread_mutex_unlock(&m_lock);
+            return false;
+        }
+
+        //
+        // get renderControl encoder instance
+        //
+        renderControl_encoder_context_t *rcEnc = hcon->rcEncoder();
+        if (!rcEnc) {
+            pthread_mutex_unlock(&m_lock);
+            return false;
+        }
+
+        //
+        // Query host reneder and EGL version
+        //
+        m_hostRendererVersion = rcEnc->rcGetRendererVersion(rcEnc);
+        EGLint status = rcEnc->rcGetEGLVersion(rcEnc, &m_major, &m_minor);
+        if (status != EGL_TRUE) {
+            // host EGL initialization failed !!
+            pthread_mutex_unlock(&m_lock);
+            return false;
+        }
+
+        //
+        // Take minimum version beween what we support and what the host support
+        //
+        if (m_major > systemEGLVersionMajor) {
+            m_major = systemEGLVersionMajor;
+            m_minor = systemEGLVersionMinor;
+        }
+        else if (m_major == systemEGLVersionMajor &&
+                 m_minor > systemEGLVersionMinor) {
+            m_minor = systemEGLVersionMinor;
+        }
+
+        //
+        // Query the host for the set of configs
+        //
+        m_numConfigs = rcEnc->rcGetNumConfigs(rcEnc, (uint32_t*)&m_numConfigAttribs);
+        if (m_numConfigs <= 0 || m_numConfigAttribs <= 0) {
+            // just sanity check - should never happen
+            pthread_mutex_unlock(&m_lock);
+            return false;
+        }
+
+        uint32_t nInts = m_numConfigAttribs * (m_numConfigs + 1);
+        EGLint tmp_buf[nInts];
+        m_configs = new EGLint[nInts-1];
+        if (!m_configs) {
+            pthread_mutex_unlock(&m_lock);
+            return false;
+        }
+
+        //EGLint n = rcEnc->rcGetConfigs(rcEnc, nInts*sizeof(EGLint), m_configs);
+        EGLint n = rcEnc->rcGetConfigs(rcEnc, nInts*sizeof(EGLint), (GLuint*)tmp_buf);
+        if (n != m_numConfigs) {
+            pthread_mutex_unlock(&m_lock);
+            return false;
+        }
+
+        //Fill the attributes vector.
+        //The first m_numConfigAttribs values of tmp_buf are the actual attributes enums.
+        for (int i=0; i<m_numConfigAttribs; i++)
+        {
+            m_attribs.add(tmp_buf[i], i);
+        }
+
+        //Copy the actual configs data to m_configs
+        memcpy(m_configs, tmp_buf + m_numConfigAttribs, m_numConfigs*sizeof(EGLint));
+
+        m_initialized = true;
+    }
+    pthread_mutex_unlock(&m_lock);
+
+    return true;
+}
+
+void eglDisplay::terminate()
+{
+    pthread_mutex_lock(&m_lock);
+    if (m_initialized) {
+        m_initialized = false;
+        delete [] m_configs;
+        m_configs = NULL;
+
+        if (m_versionString) {
+            free(m_versionString);
+            m_versionString = NULL;
+        }
+        if (m_vendorString) {
+            free(m_vendorString);
+            m_vendorString = NULL;
+        }
+        if (m_extensionString) {
+            free(m_extensionString);
+            m_extensionString = NULL;
+        }
+    }
+    pthread_mutex_unlock(&m_lock);
+}
+
+EGLClient_glesInterface *eglDisplay::loadGLESClientAPI(const char *libName,
+                                                       EGLClient_eglInterface *eglIface,
+                                                       void **libHandle)
+{
+    void *lib = dlopen(libName, RTLD_NOW);
+    if (!lib) {
+        return NULL;
+    }
+
+    init_emul_gles_t init_gles_func = (init_emul_gles_t)dlsym(lib,"init_emul_gles");
+    if (!init_gles_func) {
+        dlclose((void*)libName);
+        return NULL;
+    }
+
+    *libHandle = lib;
+    return (*init_gles_func)(eglIface);
+}
+
+static char *queryHostEGLString(EGLint name)
+{
+    HostConnection *hcon = HostConnection::get();
+    if (hcon) {
+        renderControl_encoder_context_t *rcEnc = hcon->rcEncoder();
+        if (rcEnc) {
+            int n = rcEnc->rcQueryEGLString(rcEnc, name, NULL, 0);
+            if (n < 0) {
+                // allocate space for the string with additional
+                // space charachter to be suffixed at the end.
+                char *str = (char *)malloc(-n+2);
+                n = rcEnc->rcQueryEGLString(rcEnc, name, str, -n);
+                if (n > 0) {
+                    // add extra space at end of string which will be
+                    // needed later when filtering the extension list.
+                    strcat(str, " ");
+                    return str;
+                }
+
+                free(str);
+            }
+        }
+    }
+
+    return NULL;
+}
+
+static bool findExtInList(const char* token, int tokenlen, const char* list)
+{
+    const char* p = list;
+    while (*p != '\0') {
+        const char* q = strchr(p, ' ');
+        if (q == NULL) {
+            /* should not happen, list must be space-terminated */
+            break;
+        }
+        if (tokenlen == (q - p) && !memcmp(token, p, tokenlen)) {
+            return true;  /* found it */
+        }
+        p = q+1;
+    }
+    return false;  /* not found */
+}
+
+static char *buildExtensionString()
+{
+    //Query host extension string
+    char *hostExt = queryHostEGLString(EGL_EXTENSIONS);
+    if (!hostExt || (hostExt[1] == '\0')) {
+        // no extensions on host - only static extension list supported
+        return strdup(systemStaticEGLExtensions);
+    }
+
+    //
+    // Filter host extension list to include only extensions
+    // we can support (in the systemDynamicEGLExtensions list)
+    //
+    char *ext = (char *)hostExt;
+    char *c = ext;
+    char *insert = ext;
+    while(*c != '\0') {
+        if (*c == ' ') {
+            int len = c - ext;
+            if (findExtInList(ext, len, systemDynamicEGLExtensions)) {
+                if (ext != insert) {
+                    memcpy(insert, ext, len+1); // including space
+                }
+                insert += (len + 1);
+            }
+            ext = c + 1;
+        }
+        c++;
+    }
+    *insert = '\0';
+
+    int n = strlen(hostExt);
+    if (n > 0) {
+        char *str;
+        asprintf(&str,"%s%s", systemStaticEGLExtensions, hostExt);
+        free((char*)hostExt);
+        return str;
+    }
+    else {
+        free((char*)hostExt);
+        return strdup(systemStaticEGLExtensions);
+    }
+}
+
+const char *eglDisplay::queryString(EGLint name)
+{
+    if (name == EGL_CLIENT_APIS) {
+        return "OpenGL_ES";
+    }
+    else if (name == EGL_VERSION) {
+        pthread_mutex_lock(&m_lock);
+        if (m_versionString) {
+            pthread_mutex_unlock(&m_lock);
+            return m_versionString;
+        }
+
+        // build version string
+        asprintf(&m_versionString, "%d.%d", m_major, m_minor);
+        pthread_mutex_unlock(&m_lock);
+
+        return m_versionString;
+    }
+    else if (name == EGL_VENDOR) {
+        pthread_mutex_lock(&m_lock);
+        if (m_vendorString) {
+            pthread_mutex_unlock(&m_lock);
+            return m_vendorString;
+        }
+
+        // build vendor string
+        const char *hostVendor = queryHostEGLString(EGL_VENDOR);
+
+        if (hostVendor) {
+            asprintf(&m_vendorString, "%s Host: %s",
+                                     systemEGLVendor, hostVendor);
+            free((char*)hostVendor);
+        }
+        else {
+            m_vendorString = (char *)systemEGLVendor;
+        }
+        pthread_mutex_unlock(&m_lock);
+
+        return m_vendorString;
+    }
+    else if (name == EGL_EXTENSIONS) {
+        pthread_mutex_lock(&m_lock);
+        if (m_extensionString) {
+            pthread_mutex_unlock(&m_lock);
+            return m_extensionString;
+        }
+
+        // build extension string
+        m_extensionString = buildExtensionString();
+        pthread_mutex_unlock(&m_lock);
+
+        return m_extensionString;
+    }
+    else {
+        LOGE("[%s] Unknown name %d\n", __FUNCTION__, name);
+        return NULL;
+    }
+}
+
+/* To get the value of attribute <a> of config <c> use the following formula:
+ * value = *(m_configs + (int)c*m_numConfigAttribs + a);
+ */
+EGLBoolean eglDisplay::getAttribValue(EGLConfig config, EGLint attribIdx, EGLint * value)
+{
+    if (attribIdx == ATTRIBUTE_NONE)
+    {
+        LOGE("[%s] Bad attribute idx\n", __FUNCTION__);
+        return EGL_FALSE;
+    }
+    *value = *(m_configs + (int)config*m_numConfigAttribs + attribIdx);
+    return EGL_TRUE;
+}
+
+EGLBoolean eglDisplay::getConfigAttrib(EGLConfig config, EGLint attrib, EGLint * value)
+{
+    //Though it seems that valueFor() is thread-safe, we don't take chanses
+    pthread_mutex_lock(&m_lock);
+    EGLBoolean ret = getAttribValue(config, m_attribs.valueFor(attrib), value);
+    pthread_mutex_unlock(&m_lock);
+    return ret;
+}
+
+EGLBoolean eglDisplay::getConfigPixelFormat(EGLConfig config, GLenum * format)
+{
+    EGLint redSize, blueSize, greenSize, alphaSize;
+
+    if ( !(getAttribValue(config, m_attribs.valueFor(EGL_RED_SIZE), &redSize) &&
+        getAttribValue(config, m_attribs.valueFor(EGL_BLUE_SIZE), &blueSize) &&
+        getAttribValue(config, m_attribs.valueFor(EGL_GREEN_SIZE), &greenSize) &&
+        getAttribValue(config, m_attribs.valueFor(EGL_ALPHA_SIZE), &alphaSize)) )
+    {
+        LOGE("Couldn't find value for one of the pixel format attributes");
+        return EGL_FALSE;
+    }
+
+    //calculate the GL internal format
+    if ((redSize==8)&&(blueSize==8)&&(greenSize==8)&&(alphaSize==8)) *format = GL_RGBA;
+    else if ((redSize==8)&&(blueSize==8)&&(greenSize==8)&&(alphaSize==0)) *format = GL_RGB;
+    else if ((redSize==5)&&(blueSize==6)&&(greenSize==5)&&(alphaSize==0)) *format = GL_RGB565_OES;
+    else if ((redSize==5)&&(blueSize==5)&&(greenSize==5)&&(alphaSize==1)) *format = GL_RGB5_A1_OES;
+    else if ((redSize==4)&&(blueSize==4)&&(greenSize==4)&&(alphaSize==4)) *format = GL_RGBA4_OES;
+    else return EGL_FALSE;
+
+    return EGL_TRUE;
+}
diff --git a/tools/emulator/opengl/system/egl/eglDisplay.h b/tools/emulator/opengl/system/egl/eglDisplay.h
new file mode 100644
index 0000000..6f36854
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/eglDisplay.h
@@ -0,0 +1,81 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef _SYSTEM_EGL_DISPLAY_H
+#define _SYSTEM_EGL_DISPLAY_H
+
+#include <pthread.h>
+#include "glUtils.h"
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include "EGLClientIface.h"
+#include <utils/KeyedVector.h>
+
+#define ATTRIBUTE_NONE -1
+//FIXME: are we in this namespace?
+using namespace android;
+
+class eglDisplay
+{
+public:
+    eglDisplay();
+
+    bool initialize(EGLClient_eglInterface *eglIface);
+    void terminate();
+
+    int getVersionMajor() const { return m_major; }
+    int getVersionMinor() const { return m_minor; }
+    bool initialized() const { return m_initialized; }
+
+    const char *queryString(EGLint name);
+
+    const EGLClient_glesInterface *gles_iface() const { return m_gles_iface; }
+    const EGLClient_glesInterface *gles2_iface() const { return m_gles2_iface; }
+
+    int     getNumConfigs(){ return m_numConfigs; }
+    EGLBoolean  getConfigAttrib(EGLConfig config, EGLint attrib, EGLint * value);
+    EGLBoolean getConfigPixelFormat(EGLConfig config, GLenum * format);
+
+private:
+    EGLClient_glesInterface *loadGLESClientAPI(const char *libName,
+                                               EGLClient_eglInterface *eglIface,
+                                               void **libHandle);
+    EGLBoolean getAttribValue(EGLConfig config, EGLint attribIdxi, EGLint * value);
+
+private:
+    pthread_mutex_t m_lock;
+    bool m_initialized;
+    int  m_major;
+    int  m_minor;
+    int  m_hostRendererVersion;
+    int  m_numConfigs;
+    int  m_numConfigAttribs;
+
+    /* This is the mapping between an attribute name to it's index in any given config */
+    DefaultKeyedVector<EGLint, EGLint>    m_attribs;
+    /* This is an array of all config's attributes values stored in the following sequencial fasion (read: v[c,a] = the value of attribute <a> of config <c>)
+     * v[0,0],..,v[0,m_numConfigAttribs-1],
+     *...
+     * v[m_numConfigs-1,0],..,v[m_numConfigs-1,m_numConfigAttribs-1]
+     */
+    EGLint *m_configs;
+    EGLClient_glesInterface *m_gles_iface;
+    EGLClient_glesInterface *m_gles2_iface;
+    char *m_versionString;
+    char *m_vendorString;
+    char *m_extensionString;
+};
+
+#endif
diff --git a/tools/emulator/opengl/system/egl/egl_ftable.h b/tools/emulator/opengl/system/egl/egl_ftable.h
new file mode 100644
index 0000000..ee40585
--- /dev/null
+++ b/tools/emulator/opengl/system/egl/egl_ftable.h
@@ -0,0 +1,66 @@
+/*
+* Copyright (C) 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+static struct _egl_funcs_by_name {
+    const char *name;
+    void *proc;
+} egl_funcs_by_name[] = {
+    {"eglGetError", (void *)eglGetError},
+    {"eglGetDisplay", (void *)eglGetDisplay},
+    {"eglInitialize", (void *)eglInitialize},
+    {"eglTerminate", (void *)eglTerminate},
+    {"eglQueryString", (void *)eglQueryString},
+    {"eglGetConfigs", (void *)eglGetConfigs},
+    {"eglChooseConfig", (void *)eglChooseConfig},
+    {"eglGetConfigAttrib", (void *)eglGetConfigAttrib},
+    {"eglCreateWindowSurface", (void *)eglCreateWindowSurface},
+    {"eglCreatePbufferSurface", (void *)eglCreatePbufferSurface},
+    {"eglCreatePixmapSurface", (void *)eglCreatePixmapSurface},
+    {"eglDestroySurface", (void *)eglDestroySurface},
+    {"eglQuerySurface", (void *)eglQuerySurface},
+    {"eglBindAPI", (void *)eglBindAPI},
+    {"eglQueryAPI", (void *)eglQueryAPI},
+    {"eglWaitClient", (void *)eglWaitClient},
+    {"eglReleaseThread", (void *)eglReleaseThread},
+    {"eglCreatePbufferFromClientBuffer", (void *)eglCreatePbufferFromClientBuffer},
+    {"eglSurfaceAttrib", (void *)eglSurfaceAttrib},
+    {"eglBindTexImage", (void *)eglBindTexImage},
+    {"eglReleaseTexImage", (void *)eglReleaseTexImage},
+    {"eglSwapInterval", (void *)eglSwapInterval},
+    {"eglCreateContext", (void *)eglCreateContext},
+    {"eglDestroyContext", (void *)eglDestroyContext},
+    {"eglMakeCurrent", (void *)eglMakeCurrent},
+    {"eglGetCurrentContext", (void *)eglGetCurrentContext},
+    {"eglGetCurrentSurface", (void *)eglGetCurrentSurface},
+    {"eglGetCurrentDisplay", (void *)eglGetCurrentDisplay},
+    {"eglQueryContext", (void *)eglQueryContext},
+    {"eglWaitGL", (void *)eglWaitGL},
+    {"eglWaitNative", (void *)eglWaitNative},
+    {"eglSwapBuffers", (void *)eglSwapBuffers},
+    {"eglCopyBuffers", (void *)eglCopyBuffers},
+    {"eglGetProcAddress", (void *)eglGetProcAddress},
+    {"eglLockSurfaceKHR", (void *)eglLockSurfaceKHR},
+    {"eglUnlockSurfaceKHR", (void *)eglUnlockSurfaceKHR},
+    {"eglCreateImageKHR", (void *)eglCreateImageKHR},
+    {"eglDestroyImageKHR", (void *)eglDestroyImageKHR},
+    {"eglCreateSyncKHR", (void *)eglCreateSyncKHR},
+    {"eglDestroySyncKHR", (void *)eglDestroySyncKHR},
+    {"eglClientWaitSyncKHR", (void *)eglClientWaitSyncKHR},
+    {"eglSignalSyncKHR", (void *)eglSignalSyncKHR},
+    {"eglGetSyncAttribKHR", (void *)eglGetSyncAttribKHR},
+    {"eglSetSwapRectangleANDROID", (void *)eglSetSwapRectangleANDROID}
+};
+
+static int egl_num_funcs = sizeof(egl_funcs_by_name) / sizeof(struct _egl_funcs_by_name);
diff --git a/tools/emulator/opengl/system/gralloc/gralloc.cpp b/tools/emulator/opengl/system/gralloc/gralloc.cpp
index 8aafd46..abc01a0 100644
--- a/tools/emulator/opengl/system/gralloc/gralloc.cpp
+++ b/tools/emulator/opengl/system/gralloc/gralloc.cpp
@@ -13,9 +13,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-#include <hardware/hardware.h>
-#include <hardware/gralloc.h>
-#include <cutils/native_handle.h>
+#include "gralloc_cb.h"
 #include <pthread.h>
 #ifdef HAVE_ANDROID_OS      // just want PAGE_SIZE define
 # include <asm/page.h>
@@ -30,7 +28,6 @@
 #include "glUtils.h"
 #include <cutils/log.h>
 
-#define BUFFER_HANDLE_MAGIC ((int)0xabfabfab)
 
 //
 // our private gralloc module structure
@@ -62,72 +59,6 @@
     framebuffer_device_t  device;
 };
 
-#define CB_HANDLE_NUM_INTS(nfds) ((sizeof(cb_handle_t) - (nfds)*sizeof(int)) / sizeof(int))
-
-//
-// Our buffer handle structure
-//
-struct cb_handle_t : public native_handle {
-
-    cb_handle_t(int p_fd, int p_ashmemSize, int p_usage,
-                int p_width, int p_height, int p_glFormat) :
-        fd(p_fd),
-        magic(BUFFER_HANDLE_MAGIC),
-        usage(p_usage),
-        width(p_width),
-        height(p_height),
-        glFormat(p_glFormat),
-        ashmemSize(p_ashmemSize),
-        ashmemBase(NULL),
-        ashmemBasePid(0),
-        mappedPid(0),
-        lockedLeft(0),
-        lockedTop(0),
-        lockedWidth(0),
-        lockedHeight(0),
-        hostHandle(0)
-    {
-        version = sizeof(native_handle);
-        numFds = 1;
-        numInts = CB_HANDLE_NUM_INTS(numFds);
-    }
-
-    ~cb_handle_t() {
-        magic = 0;
-    }
-
-    bool validate() const {
-        return (version == sizeof(native_handle) &&
-                magic == BUFFER_HANDLE_MAGIC &&
-                numInts == CB_HANDLE_NUM_INTS(1) &&
-                numFds == 1);
-    }
-
-    bool canBePosted() {
-        return (0 != (usage & GRALLOC_USAGE_HW_FB));
-    }
-
-    // file-descriptors
-    int fd;  // ashmem fd (-1 of ashmem region did not allocated, i.e. no SW access needed)
-
-    // ints
-    int magic;              // magic number in order to validate a pointer to be a cb_handle_t
-    int usage;              // usage bits the buffer was created with
-    int width;              // buffer width
-    int height;             // buffer height
-    int glFormat;           // OpenGL format enum used for host h/w color buffer
-    int ashmemSize;         // ashmem region size for the buffer (0 unless is HW_FB buffer or
-                            //                                    s/w access is needed)
-    int ashmemBase;         // CPU address of the mapped ashmem region
-    int ashmemBasePid;      // process id which mapped the ashmem region
-    int mappedPid;          // process id which succeeded gralloc_register call
-    int lockedLeft;         // region of buffer locked for s/w write
-    int lockedTop;
-    int lockedWidth;
-    int lockedHeight;
-    uint32_t hostHandle;
-};
-
 static int map_buffer(cb_handle_t *cb, void **vaddr)
 {
     if (cb->fd < 0 || cb->ashmemSize <= 0) {
diff --git a/tools/emulator/opengl/system/renderControl_enc/README b/tools/emulator/opengl/system/renderControl_enc/README
index 41bb669..b8ffc49 100644
--- a/tools/emulator/opengl/system/renderControl_enc/README
+++ b/tools/emulator/opengl/system/renderControl_enc/README
@@ -39,6 +39,15 @@
        holding the attribute values for that config, the values are specified
        in the same order as the attribute vector.
 
+EGLint rcChooseConfig(EGLint *attribs, uint32_t attribs_size, uint32_t *configs, uint32_t configs_size)
+       This function triggers an eglChooseConfig on the host, to get a list of 
+       configs matching the given attribs values.
+ 	attribs - a list of attribute names followed by the desired values, terminated by EGL_NONE
+	attribs_size - the size of the list
+	configs - the returned matching configuration names (same names as familiar to the client in rcGetConfigs)
+	configs_size - the size of the configs buffers
+	returns - the actual number of matching configurations (<= configs_size) 
+
 EGLint rcGetFBParam(EGLint param);
        queries the host for framebuffer parameter, see renderControl_types.h
        for possible values of 'param'.
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl.attrib b/tools/emulator/opengl/system/renderControl_enc/renderControl.attrib
index 310d3d0..a77d21f 100644
--- a/tools/emulator/opengl/system/renderControl_enc/renderControl.attrib
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl.attrib
@@ -20,6 +20,12 @@
     dir buffer out
     len buffer bufSize
 
+rcChooseConfig
+    dir attribs in
+	len attribs attribs_size
+	dir configs out
+	len configs configs_size
+
 rcReadColorBuffer
     dir pixels out
     len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height)
diff --git a/tools/emulator/opengl/system/renderControl_enc/renderControl.in b/tools/emulator/opengl/system/renderControl_enc/renderControl.in
index db23c5b..c91a662 100644
--- a/tools/emulator/opengl/system/renderControl_enc/renderControl.in
+++ b/tools/emulator/opengl/system/renderControl_enc/renderControl.in
@@ -3,6 +3,7 @@
 GL_ENTRY(EGLint, rcQueryEGLString, EGLenum name, void *buffer, EGLint bufferSize)
 GL_ENTRY(EGLint, rcGetNumConfigs, uint32_t *numAttribs)
 GL_ENTRY(EGLint, rcGetConfigs, uint32_t bufSize, GLuint *buffer)
+GL_ENTRY(EGLint, rcChooseConfig, EGLint *attribs, uint32_t attribs_size, uint32_t *configs, uint32_t configs_size)
 GL_ENTRY(EGLint, rcGetFBParam, EGLint param)
 GL_ENTRY(uint32_t, rcCreateContext, uint32_t config, uint32_t share, uint32_t glVersion)
 GL_ENTRY(void, rcDestroyContext, uint32_t context)
diff --git a/tools/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk b/tools/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk
new file mode 100644
index 0000000..a411ccf
--- /dev/null
+++ b/tools/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk
@@ -0,0 +1,37 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+translator_path := $(LOCAL_PATH)/../../../host/libs/Translator
+
+PREBUILT := $(HOST_PREBUILT_TAG)
+SDL_CONFIG ?= prebuilt/$(PREBUILT)/sdl/bin/sdl-config
+SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
+SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
+
+LOCAL_SRC_FILES:= \
+        triangleCM.cpp
+
+
+LOCAL_SHARED_LIBRARIES := \
+    libEGL_translator     \
+    libGLES_CM_translator
+
+LOCAL_CFLAGS += $(SDL_CFLAGS) -g -O0
+LOCAL_LDLIBS += $(SDL_LDLIBS)
+
+
+LOCAL_MODULE:= triangleCM
+LOCAL_MODULE_TAGS := debug
+LOCAL_STATIC_LIBRARIES += libSDL libSDLmain 
+
+ifeq ($(HOST_OS),darwin)
+
+LOCAL_LDLIBS += -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit
+LOCAL_STATIC_LIBRARIES += libMac_view
+LOCAL_C_INCLUDES += \
+                 $(LOCAL_PATH)/../MacCommon \
+                 $(translator_path)/include 
+endif
+
+include $(BUILD_HOST_EXECUTABLE)
+
diff --git a/tools/emulator/opengl/tests/translator_tests/GLES_CM/triangleCM.cpp b/tools/emulator/opengl/tests/translator_tests/GLES_CM/triangleCM.cpp
new file mode 100644
index 0000000..56922c8
--- /dev/null
+++ b/tools/emulator/opengl/tests/translator_tests/GLES_CM/triangleCM.cpp
@@ -0,0 +1,395 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+//#define GL_API
+//#define GL_APIENTRY
+
+#undef ANDROID
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+
+#ifdef __APPLE__
+extern "C" void * createGLView(void *nsWindowPtr, int x, int y, int width, int height);
+#endif
+
+#undef HAVE_MALLOC_H
+#include <SDL.h>
+#include <SDL_syswm.h>
+
+
+#define WINDOW_WIDTH    500
+#define WINDOW_HEIGHT   500
+
+#define TEX_WIDTH 256
+#define TEX_HEIGHT 256
+
+
+#define F_to_X(d) ((d) > 32767.65535 ? 32767 * 65536 + 65535 :  \
+               (d) < -32768.65535 ? -32768 * 65536 + 65535 : \
+               ((GLfixed) ((d) * 65536)))
+#define X_to_F(x)  ((float)(x))/65536.0f
+
+static EGLint const attribute_list[] = {
+    EGL_RED_SIZE, 1,
+    EGL_GREEN_SIZE, 1,
+    EGL_BLUE_SIZE, 1,
+    EGL_NONE
+};
+
+unsigned char *genTexture(int width, int height, int comp)
+{
+    unsigned char *img = new unsigned char[width * height * comp];
+    unsigned char *ptr = img;
+    for (int i = 0; i < height; i++) {
+        for (int j = 0; j < width; j++) {
+            unsigned char col = ((i / 8 + j / 8) % 2) * 255 ;
+            for (int c = 0; c < comp; c++) {
+                *ptr = col; ptr++;
+            }
+        }
+    }
+    return img;
+}
+
+unsigned char *genRedTexture(int width, int height, int comp)
+{
+    unsigned char *img = new unsigned char[width * height * comp];
+        memset(img,0,width*height*comp);
+    unsigned char *ptr = img;
+    for (int i = 0; i < height; i++) {
+        for (int j = 0; j < width; j++) {
+            unsigned char col = ((i / 8 + j / 8) % 2) * 255 ;
+                        *ptr = col;
+                         ptr+=comp;
+        }
+    }
+    return img;
+}
+
+//mip 0;
+unsigned char *genPalette4_rgb8(int width, int height,int color)
+{
+        int size = width*height/2 + 16*3/*palette size*/;
+    unsigned char *img = new unsigned char[size];
+
+        memset(img,0,size);
+        img[0] = 255; img[1] = 0; img[2] = 0;     // red
+        img[3] = 0; img[4] = 0; img[5] = 255;    //blue
+        img[7] = 128; img[8] = 0; img[9] = 128;  //fucsia
+        //rest of the palette is empty
+
+    unsigned char *ptr = img+(16*3);
+    for (int i = 0; i < (height*width/2); i++) {
+             ptr[i] = (i%2)?0x0|color:0x11|color;
+    }
+    return img;
+}
+
+void usage(const char *progname)
+{
+    fprintf(stderr, "usage: %s [-n <nframes> -i -h]\n", progname);
+    fprintf(stderr, "\t-h: this message\n");
+    fprintf(stderr, "\t-i: immidate mode\n");
+    fprintf(stderr, "\t-n nframes: generate nframes\n");
+    fprintf(stderr, "\t-e: use index arrays\n");
+    fprintf(stderr, "\t-t: use texture\n");
+    fprintf(stderr, "\t-f: use fixed points\n");
+    fprintf(stderr, "\t-p: use point size OES extention\n");
+}
+
+#ifdef _WIN32
+int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
+#else
+int main(int argc, char **argv)
+#endif
+{
+    GLuint  ui32Vbo = 0; // Vertex buffer object handle
+    GLuint  ui32IndexVbo;
+    GLuint  ui32Texture;
+
+    int nframes = 100;
+    bool immidateMode     = true;
+    bool useIndices       = false;
+    bool useTexture       = false;
+    bool useCompTexture   = false;
+    bool useFixed         = false;
+    bool usePoints        = true;
+    bool useCopy          = false;
+    bool useSubCopy       = false;
+
+    int c;
+    extern char *optarg;
+
+    #ifdef _WIN32
+        HWND   windowId = NULL;
+    #elif __linux__
+        Window windowId = NULL;
+    #elif __APPLE__
+        void* windowId = NULL;
+    #endif
+
+        //      // Inialize SDL window
+        //
+        if (SDL_Init(SDL_INIT_NOPARACHUTE | SDL_INIT_VIDEO)) {
+            fprintf(stderr,"SDL init failed: %s\n", SDL_GetError());
+            return -1;
+        }
+
+        SDL_Surface *surface = SDL_SetVideoMode(WINDOW_WIDTH,WINDOW_HEIGHT, 32, SDL_HWSURFACE);
+        if (surface == NULL) {
+            fprintf(stderr,"Failed to set video mode: %s\n", SDL_GetError());
+            return -1;
+        }
+
+        SDL_SysWMinfo  wminfo;
+        memset(&wminfo, 0, sizeof(wminfo));
+        SDL_GetWMInfo(&wminfo);
+    #ifdef _WIN32
+        windowId = wminfo.window;
+    #elif __linux__
+        windowId = wminfo.info.x11.window;
+    #elif __APPLE__
+        windowId = createGLView(wminfo.nsWindowPtr,0,0,WINDOW_WIDTH,WINDOW_HEIGHT);
+
+    #endif
+
+        int major,minor,num_config;
+        EGLConfig configs[150];
+        EGLSurface egl_surface;
+        EGLContext ctx;
+        EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+        eglInitialize(d,&major,&minor);
+        printf("DISPLAY == %p major =%d minor = %d\n",d,major,minor);
+        eglChooseConfig(d, attribute_list, configs, 150, &num_config);
+        printf("config returned %d\n",num_config);
+        egl_surface = eglCreateWindowSurface(d,configs[0],windowId,NULL);
+        printf("before creating context..\n");
+        ctx = eglCreateContext(d,configs[0],EGL_NO_CONTEXT,NULL);
+        printf("SURFACE == %p CONTEXT == %p\n",egl_surface,ctx);
+        if(eglMakeCurrent(d,egl_surface,egl_surface,ctx)!= EGL_TRUE){
+            printf("make current failed\n");
+            return false;
+        }
+        printf("after make current\n");
+
+        GLenum err = glGetError();
+        if(err != GL_NO_ERROR) {
+        printf("error before drawing ->>> %d  \n",err);
+        } else {
+        printf("no error before drawing\n");
+        }
+
+    if (useTexture) {
+
+        glEnable(GL_TEXTURE_2D);
+        ui32Texture = 1;
+        glBindTexture(GL_TEXTURE_2D, ui32Texture);
+                GLenum err = glGetError();
+
+        unsigned char *pixels = NULL;
+                if(useCompTexture) {
+                        pixels = genPalette4_rgb8(TEX_WIDTH,TEX_HEIGHT,3);
+                        glCompressedTexImage2D(GL_TEXTURE_2D,0,GL_PALETTE4_RGB8_OES,TEX_WIDTH,TEX_HEIGHT,0,3*16+TEX_WIDTH*TEX_HEIGHT/2,pixels);
+
+                } else {
+                        pixels = genTexture(TEX_WIDTH, TEX_HEIGHT, 4);
+            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_WIDTH, TEX_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+                }
+
+        delete pixels;
+
+                err = glGetError();
+                if(err != GL_NO_ERROR)
+            printf("error %d after image \n",err);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+                err = glGetError();
+                if(err != GL_NO_ERROR)
+            printf("error after min filter \n");
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+                err = glGetError();
+                if(err != GL_NO_ERROR)
+            printf("error after mag filter \n");
+        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+                err = glGetError();
+                if(err != GL_NO_ERROR)
+            printf("error after env mode \n");
+
+                if(useCompTexture) {
+                    pixels = genPalette4_rgb8(TEX_WIDTH,TEX_HEIGHT,1);
+                    glCompressedTexSubImage2D(GL_TEXTURE_2D,0,TEX_WIDTH/4,TEX_HEIGHT/4,TEX_WIDTH/8,TEX_HEIGHT/8,GL_PALETTE4_RGB8_OES,3*16+(TEX_WIDTH*TEX_HEIGHT/128),pixels);
+                } else {
+            pixels = genRedTexture(TEX_WIDTH/8, TEX_HEIGHT/8, 4);
+                    glTexSubImage2D(GL_TEXTURE_2D,0,TEX_WIDTH/4,TEX_HEIGHT/4,TEX_WIDTH/8,TEX_HEIGHT/8,GL_RGBA,GL_UNSIGNED_BYTE,pixels);
+                }
+                 err = glGetError();
+                if(err != GL_NO_ERROR)
+            printf("error %d after subimage \n",err);
+        delete pixels;
+
+    }
+
+    glClearColor(0.6f, 0.8f, 1.0f, 1.0f); // clear blue
+
+    float afVertices[] = {  -0.4f,-0.4f,0.0f, // Position
+                 1.0f,0.0f,0.0f,1.0f, // Color
+                 0.0f, 0.0f, // texture
+                 12.f, //point size
+
+                 0.4f,-0.4f,0.0f,
+                 0.0f,1.0f,0.0f,1.0f,
+                 1.0f, 0.0f,
+                 47.0f,
+
+                 0.0f,0.4f,0.0f,
+                 0.0f,0.0f,1.0f,1.0f,
+                 0.5f, 1.0f,
+                 14.0f
+    };
+
+    GLfixed fixedVertices[] = { F_to_X(-0.4f),F_to_X(-0.4f),F_to_X(0.0f), // Position
+                    F_to_X(1.0f),F_to_X(0.0f),F_to_X(0.0f),F_to_X(1.0f), // Color
+                    F_to_X(0.0f),F_to_X(0.0f), // texture
+                    F_to_X(12.0f),//points size
+
+                    F_to_X(0.4f),F_to_X(-0.4f),F_to_X(0.0f),
+                    F_to_X(0.0f),F_to_X(1.0f),F_to_X(0.0f),F_to_X(1.0f),
+                    F_to_X(1.0f),F_to_X( 0.0f),
+                    F_to_X(30.0f),
+
+                    F_to_X(0.0f),F_to_X(0.4f),F_to_X(0.0f),
+                    F_to_X(0.0f),F_to_X(0.0f),F_to_X(1.0f),F_to_X(1.0f),
+                    F_to_X(0.5f), F_to_X(1.0f),
+                    F_to_X(30.0)
+    };
+
+    unsigned short indices[] = { 2, 1, 0 };
+
+    if (!immidateMode) {
+        glGenBuffers(1, &ui32Vbo);
+        ui32Vbo = 1;
+         printf("ui32Vbo = %d\n", ui32Vbo);
+
+        glBindBuffer(GL_ARRAY_BUFFER, ui32Vbo);
+        unsigned int uiSize = 3 * (sizeof(float) * 10);
+        glBufferData(GL_ARRAY_BUFFER, uiSize, useFixed?(void *)fixedVertices:(void*)afVertices, GL_STATIC_DRAW);
+
+        ui32IndexVbo = 2;
+        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ui32IndexVbo);
+        glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
+    }
+
+    // Draws a triangle for 800 frames
+    float angle = 0.0;
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    glMatrixMode(GL_MODELVIEW);
+    glLoadIdentity();
+
+    GLvoid* arr = NULL;
+    GLenum  type;
+    GLenum  drawType;
+    int     size_of;
+
+    if(useFixed)
+    {
+        arr = fixedVertices;
+        type = GL_FIXED;
+        size_of = sizeof(GLfixed);
+    }
+    else
+    {
+        arr = afVertices;
+        type = GL_FLOAT;
+        size_of = sizeof(float);
+    }
+
+    if(usePoints)
+    {
+        drawType = GL_POINTS;
+    }
+    else
+        drawType = GL_TRIANGLES;
+
+    for (int i = 0; i < 10000; i++) {
+
+        glClear(GL_COLOR_BUFFER_BIT);
+        glPushMatrix();
+        glRotatef(angle, 0.0, 0.0, 1.0);
+        angle += 360.0 / nframes;
+        // Enable vertex arrays
+        glEnableClientState(GL_VERTEX_ARRAY);
+        if (immidateMode) {
+            glVertexPointer(3,type, size_of * 10, arr);
+        } else {
+            glVertexPointer(3,type, size_of * 10, 0);
+        }
+
+        // Set color data in the same way
+        glEnableClientState(GL_COLOR_ARRAY);
+        if (immidateMode) {
+            glColorPointer(4, type, size_of * 10, useFixed?(GLvoid*)(fixedVertices+3):(GLvoid*)(afVertices+3));
+        } else {
+            glColorPointer(4,type,size_of * 10, (GLvoid*) (size_of * 3) );
+        }
+        if (useTexture) {
+            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+            if (immidateMode) {
+                glTexCoordPointer(2, type, size_of * 10, useFixed?(GLvoid*)(fixedVertices + 7):(GLvoid*)(afVertices+7));
+            } else {
+                glTexCoordPointer(2, type, size_of * 10, (GLvoid*)(size_of * 7));
+            }
+        }
+        if(usePoints)
+        {
+            glEnableClientState(GL_POINT_SIZE_ARRAY_OES);
+            if (immidateMode) {
+                glPointSizePointerOES(type,size_of * 10,useFixed?(GLvoid*)(fixedVertices + 9):(GLvoid*)(afVertices+9));
+                        } else {
+                glPointSizePointerOES(type,size_of * 10,(GLvoid*)(size_of * 9));
+                        }
+        }
+
+        if (useIndices) {
+            if (immidateMode) {
+                glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+                glDrawElements(drawType, 3, GL_UNSIGNED_SHORT, indices);
+            } else {
+                glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ui32IndexVbo);
+                glDrawElements(drawType, 3, GL_UNSIGNED_SHORT, 0);
+            }
+        } else {
+            glDrawArrays(drawType, 0, 3);
+        }
+
+                GLenum err = glGetError();
+                if(err != GL_NO_ERROR)
+            printf(" error %d has occured while drawing\n",err);
+
+
+        glPopMatrix();
+                eglSwapBuffers(d,egl_surface);
+
+                if(useTexture && useCopy)
+                    glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,0,0,256,256,0);
+                else if(useTexture && useSubCopy)
+                    glCopyTexSubImage2D(GL_TEXTURE_2D,0,100,100,WINDOW_WIDTH/2,WINDOW_HEIGHT/2,50,50);
+    }
+                err = glGetError();
+                if(err != GL_NO_ERROR)
+            printf("error ->>> %d  \n",err);
+        eglDestroySurface(d,egl_surface);
+        eglDestroyContext(d,ctx);
+
+// Just wait until the window is closed
+        SDL_Event ev;
+        while( SDL_WaitEvent(&ev) ) {
+            if (ev.type == SDL_QUIT) {
+                break;
+            }
+        }
+    return 0;
+}
+
+
diff --git a/tools/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk b/tools/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk
new file mode 100644
index 0000000..5cb5c4a
--- /dev/null
+++ b/tools/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk
@@ -0,0 +1,38 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+translator_path := $(LOCAL_PATH)/../../../host/libs/Translator
+
+PREBUILT := $(HOST_PREBUILT_TAG)
+SDL_CONFIG ?= prebuilt/$(PREBUILT)/sdl/bin/sdl-config
+SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
+SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
+
+LOCAL_SRC_FILES:= \
+        triangleV2.cpp
+
+
+LOCAL_SHARED_LIBRARIES := \
+    libEGL_translator     \
+    libGLES_V2_translator
+
+LOCAL_CFLAGS += $(SDL_CFLAGS) -g -O0
+LOCAL_LDLIBS += $(SDL_LDLIBS)
+
+
+LOCAL_MODULE:= triangleV2
+LOCAL_MODULE_TAGS := debug
+LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
+
+ifeq ($(HOST_OS),darwin)
+
+LOCAL_LDLIBS += -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit
+LOCAL_C_INCLUDES += \
+                 $(translator_path)/include \
+                 $(LOCAL_PATH)/../MacCommon
+LOCAL_STATIC_LIBRARIES += libMac_view
+
+endif
+
+include $(BUILD_HOST_EXECUTABLE)
+
diff --git a/tools/emulator/opengl/tests/translator_tests/GLES_V2/triangleV2.cpp b/tools/emulator/opengl/tests/translator_tests/GLES_V2/triangleV2.cpp
new file mode 100644
index 0000000..0321b7d
--- /dev/null
+++ b/tools/emulator/opengl/tests/translator_tests/GLES_V2/triangleV2.cpp
@@ -0,0 +1,323 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+//#define GL_API
+//#define GL_APIENTRY
+
+#undef ANDROID
+#include <EGL/egl.h>
+#include <GLES2/gl2.h>
+
+#ifdef __APPLE__
+extern "C" void * createGLView(void *nsWindowPtr, int x, int y, int width, int height);
+#endif
+
+#undef HAVE_MALLOC_H
+#include <SDL.h>
+#include <SDL_syswm.h>
+
+
+#define WINDOW_WIDTH    500
+#define WINDOW_HEIGHT   500
+
+#define TEX_WIDTH 256
+#define TEX_HEIGHT 256
+
+
+#define F_to_X(d) ((d) > 32767.65535 ? 32767 * 65536 + 65535 :  \
+               (d) < -32768.65535 ? -32768 * 65536 + 65535 : \
+               ((GLfixed) ((d) * 65536)))
+#define X_to_F(x)  ((float)(x))/65536.0f
+
+//#define __FIXED__
+
+static EGLint const attribute_list[] = {
+    EGL_RED_SIZE, 1,
+    EGL_GREEN_SIZE, 1,
+    EGL_BLUE_SIZE, 1,
+    EGL_NONE
+};
+
+unsigned char *genTexture(int width, int height, int comp)
+{
+    unsigned char *img = new unsigned char[width * height * comp];
+    unsigned char *ptr = img;
+    for (int i = 0; i < height; i++) {
+        for (int j = 0; j < width; j++) {
+            unsigned char col = ((i / 8 + j / 8) % 2) * 255 ;
+            for (int c = 0; c < comp; c++) {
+                *ptr = col; ptr++;
+            }
+        }
+    }
+    return img;
+}
+
+unsigned char *genRedTexture(int width, int height, int comp)
+{
+    unsigned char *img = new unsigned char[width * height * comp];
+        memset(img,0,width*height*comp);
+    unsigned char *ptr = img;
+    for (int i = 0; i < height; i++) {
+        for (int j = 0; j < width; j++) {
+            unsigned char col = ((i / 8 + j / 8) % 2) * 255 ;
+                        *ptr = col;
+                         ptr+=comp;
+        }
+    }
+    return img;
+}
+
+
+void usage(const char *progname)
+{
+    fprintf(stderr, "usage: %s [-n <nframes> -i -h]\n", progname);
+    fprintf(stderr, "\t-h: this message\n");
+    fprintf(stderr, "\t-i: immidate mode\n");
+    fprintf(stderr, "\t-n nframes: generate nframes\n");
+    fprintf(stderr, "\t-e: use index arrays\n");
+    fprintf(stderr, "\t-t: use texture\n");
+    fprintf(stderr, "\t-f: use fixed points\n");
+    fprintf(stderr, "\t-p: use point size OES extention\n");
+}
+
+
+
+GLuint LoadShader(GLenum type,const char *shaderSrc)
+{
+   GLuint shader;
+   GLint compiled;
+   // Create the shader object
+    shader = glCreateShader(type);
+   if(shader == 0)
+       return 0;
+   // Load the shader source
+   glShaderSource(shader, 1, &shaderSrc, NULL);
+    // Compile the shader
+   glCompileShader(shader);
+    // Check the compile status
+   glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
+   if(!compiled)
+   {
+       GLint infoLen = 0;
+       glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
+       if(infoLen > 1)
+       {
+          char* infoLog = (char*)malloc(sizeof(char) * infoLen);
+          glGetShaderInfoLog(shader, infoLen, NULL, infoLog);
+          printf("Error compiling shader:\n%s\n", infoLog);
+          free(infoLog);
+       }
+       glDeleteShader(shader);
+       return 0;
+   }
+   return shader;
+}
+///
+// Initialize the shader and program object
+//
+int Init()
+{
+   char vShaderStr[] =
+       "attribute vec4 vPosition;   \n"
+       "void main()                 \n"
+       "{                           \n"
+       "   gl_Position = vPosition; \n"
+       "}                           \n";
+   char fShaderStr[] =
+       "precision mediump float;                   \n"
+       "void main()                                \n"
+       "{                                          \n"
+#ifndef __FIXED__
+       " gl_FragColor = vec4(0.2, 0.5, 0.1, 1.0); \n"
+#else
+       " gl_FragColor = vec4(0.4, 0.3, 0.7, 1.0); \n"
+#endif
+       "}                                          \n";
+   GLuint vertexShader;
+   GLuint fragmentShader;
+   GLuint programObject;
+   GLint linked;
+  // Load the vertex/fragment shaders
+  vertexShader = LoadShader(GL_VERTEX_SHADER, vShaderStr);
+  fragmentShader = LoadShader(GL_FRAGMENT_SHADER, fShaderStr);
+  // Create the program object
+  programObject = glCreateProgram();
+  if(programObject == 0)
+     return -1;
+  glAttachShader(programObject, vertexShader);
+  glAttachShader(programObject, fragmentShader);
+  // Bind vPosition to attribute 0
+  glBindAttribLocation(programObject, 0, "vPosition");
+  // Link the program
+  glLinkProgram(programObject);
+  // Check the link status
+  glGetProgramiv(programObject, GL_LINK_STATUS, &linked);
+  if(!linked)
+  {
+     GLint infoLen = 0;
+     glGetProgramiv(programObject, GL_INFO_LOG_LENGTH, &infoLen);
+     if(infoLen > 1)
+     {
+        char* infoLog = (char*)malloc(sizeof(char) * infoLen);
+        glGetProgramInfoLog(programObject, infoLen, NULL, infoLog);
+        printf("Error linking program:\n%s\n", infoLog);
+        free(infoLog);
+     }
+     glDeleteProgram(programObject);
+     return -1;
+  }
+  // Store the program object
+#ifndef __FIXED__
+  glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
+#else
+  glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
+#endif
+  return programObject;
+}
+
+
+///
+// Draw a triangle using the shader pair created in Init()
+//
+void Draw(EGLDisplay display,EGLSurface surface,int width,int height,GLuint program)
+{
+#ifndef __FIXED__
+   GLfloat vVertices[] = {0.0f, 0.5f, 0.0f,
+                           -0.5f, -0.5f, 0.0f,
+                           0.5f, -0.5f, 0.0f};
+#else
+
+   GLfixed vVertices[] = {F_to_X(0.0f), F_to_X(0.5f),F_to_X(0.0f),
+                           F_to_X(-0.5f),F_to_X(-0.5f), F_to_X(0.0f),
+                           F_to_X(0.5f),F_to_X(-0.5f),F_to_X(0.0f)};
+#endif    
+   
+    // Set the viewport
+   glViewport(0, 0,width,height);
+    // Clear the color buffer
+   glClear(GL_COLOR_BUFFER_BIT);
+    // Use the program object
+   glUseProgram(program);
+   // Load the vertex data
+#ifndef __FIXED__
+   glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, vVertices);
+#else
+   glVertexAttribPointer(0, 3, GL_FIXED, GL_FALSE, 0, vVertices);
+#endif
+   glEnableVertexAttribArray(0);
+   glDrawArrays(GL_TRIANGLES, 0, 3);
+   eglSwapBuffers(display,surface);
+}
+
+#ifdef _WIN32
+int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
+#else
+int main(int argc, char **argv)
+#endif
+{
+    GLuint  ui32Vbo = 0; // Vertex buffer object handle
+    GLuint  ui32IndexVbo;
+    GLuint  ui32Texture;
+
+    int nframes = 100;
+    bool immidateMode     = false;
+    bool useIndices       = false;
+    bool useTexture       = true;
+    bool useCompTexture   = false;
+    bool useFixed         = true;
+    bool usePoints        = false;
+    bool useCopy          = false;
+    bool useSubCopy       = false;
+
+    int c;
+    extern char *optarg;
+
+    #ifdef _WIN32
+        HWND   windowId = NULL;
+    #elif __linux__
+        Window windowId = NULL;
+    #elif __APPLE__
+        void* windowId  = NULL;
+    #endif
+
+        //      // Inialize SDL window
+        //
+        if (SDL_Init(SDL_INIT_NOPARACHUTE | SDL_INIT_VIDEO)) {
+            fprintf(stderr,"SDL init failed: %s\n", SDL_GetError());
+            return -1;
+        }
+
+        SDL_Surface *surface = SDL_SetVideoMode(WINDOW_WIDTH,WINDOW_HEIGHT, 32, SDL_HWSURFACE);
+        if (surface == NULL) {
+            fprintf(stderr,"Failed to set video mode: %s\n", SDL_GetError());
+            return -1;
+        }
+
+        SDL_SysWMinfo  wminfo;
+        memset(&wminfo, 0, sizeof(wminfo));
+        SDL_GetWMInfo(&wminfo);
+    #ifdef _WIN32
+        windowId = wminfo.window;
+    #elif __linux__
+        windowId = wminfo.info.x11.window;
+    #elif __APPLE__
+        windowId = createGLView(wminfo.nsWindowPtr,0,0,WINDOW_WIDTH,WINDOW_HEIGHT);
+    #endif
+
+        int major,minor,num_config;
+        int attrib_list[] ={    
+                                EGL_CONTEXT_CLIENT_VERSION, 2,
+                                EGL_NONE
+                           };
+        EGLConfig configs[150];
+        EGLSurface egl_surface;
+        EGLContext ctx;
+        EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+        eglInitialize(d,&major,&minor);
+        printf("DISPLAY == %p major =%d minor = %d\n",d,major,minor);
+        eglChooseConfig(d, attribute_list, configs, 150, &num_config);
+        printf("config returned %d\n",num_config);
+        egl_surface = eglCreateWindowSurface(d,configs[0],windowId,NULL);
+        ctx = eglCreateContext(d,configs[0],EGL_NO_CONTEXT,attrib_list);
+        printf("SURFACE == %p CONTEXT == %p\n",egl_surface,ctx);
+        if(eglMakeCurrent(d,egl_surface,egl_surface,ctx)!= EGL_TRUE){
+            printf("make current failed\n");
+            return false;
+        }
+        printf("after make current\n");
+
+        GLenum err = glGetError();
+        if(err != GL_NO_ERROR) {
+        printf("error before drawing ->>> %d  \n",err);
+        } else {
+        printf("no error before drawing\n");
+        }
+
+        int program = Init();
+        if(program  < 0){
+            printf("failed init shaders\n");
+            return false;
+        }
+
+        Draw(d,egl_surface,WINDOW_WIDTH,WINDOW_HEIGHT,program);
+
+                err = glGetError();
+                if(err != GL_NO_ERROR)
+            printf("error ->>> %d  \n",err);
+        eglDestroySurface(d,egl_surface);
+        eglDestroyContext(d,ctx);
+
+// Just wait until the window is closed
+        SDL_Event ev;
+        while( SDL_WaitEvent(&ev) ) {
+            if (ev.type == SDL_QUIT) {
+                break;
+            }
+        }
+    return 0;
+}
+
+
diff --git a/tools/emulator/opengl/tests/translator_tests/MacCommon/Android.mk b/tools/emulator/opengl/tests/translator_tests/MacCommon/Android.mk
new file mode 100644
index 0000000..e72ed82
--- /dev/null
+++ b/tools/emulator/opengl/tests/translator_tests/MacCommon/Android.mk
@@ -0,0 +1,20 @@
+
+LOCAL_PATH := $(call my-dir)
+
+ifeq ($(HOST_OS),darwin)
+include $(CLEAR_VARS)
+
+
+LOCAL_LDLIBS := -Wl,-framework,AppKit
+
+LOCAL_SRC_FILES :=  setup_gl.m
+
+
+
+LOCAL_CFLAGS := -g -O0
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := libMac_view
+
+
+include $(BUILD_HOST_STATIC_LIBRARY)
+endif
diff --git a/tools/emulator/opengl/tests/translator_tests/MacCommon/setup_gl.m b/tools/emulator/opengl/tests/translator_tests/MacCommon/setup_gl.m
new file mode 100644
index 0000000..43b72ba
--- /dev/null
+++ b/tools/emulator/opengl/tests/translator_tests/MacCommon/setup_gl.m
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <Cocoa/Cocoa.h>
+
+ void * createGLView(void *nsWindowPtr, int x, int y, int width, int height)
+{
+	NSRect contentRect = NSMakeRect(x, y, width, height);
+	NSView *glView = [[NSView alloc] initWithFrame:contentRect];
+	if (glView == nil) {
+		printf("couldn't create opengl view\n");
+		return nil;
+	}
+	[glView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
+	NSWindow *win = (NSWindow *)nsWindowPtr;
+	[[win contentView] addSubview:glView];
+	[win makeKeyAndOrderFront:nil];
+	return (void *)glView;
+}
+
+