Avoid resending lots of D3D state

This change uses trivial caching to determines whether to reset shaders, the viewport, and the currently set vertex declaration. It also caches the render target desc to avoid rereading that. Serial numbers are added to vertex and index buffers, so resending those can be avoided.

These changes can give a big speedup (30% has been measured) on simple content, particularly when used directly or through pepper/native client.

BUG=
TEST=bunch of pages using webgl

Review URL: http://codereview.appspot.com/4964057

git-svn-id: https://angleproject.googlecode.com/svn/trunk@743 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/IndexDataManager.h b/src/libGLESv2/IndexDataManager.h
index c076b90..04db4be 100644
--- a/src/libGLESv2/IndexDataManager.h
+++ b/src/libGLESv2/IndexDataManager.h
@@ -28,6 +28,7 @@
     UINT startIndex;
 
     IDirect3DIndexBuffer9 *indexBuffer;
+    unsigned int serial;
 };
 
 class IndexBuffer
@@ -42,6 +43,7 @@
     virtual void reserveSpace(UINT requiredSpace, GLenum type) = 0;
 
     IDirect3DIndexBuffer9 *getBuffer() const;
+    unsigned int getSerial() const;
 
   protected:
     IDirect3DDevice9 *const mDevice;
@@ -49,6 +51,10 @@
     IDirect3DIndexBuffer9 *mIndexBuffer;
     UINT mBufferSize;
 
+    unsigned int mSerial;
+    static unsigned int issueSerial();
+    static unsigned int mCurrentSerial;
+
   private:
     DISALLOW_COPY_AND_ASSIGN(IndexBuffer);
 };