Minimize BeginScene / EndScene calls
TRAC #12139
Signed-off-by: Shannon Woods
Signed-off-by: Daniel Koch

Author:    Nicolas Capens

git-svn-id: https://angleproject.googlecode.com/svn/trunk@231 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index 86a89dc..2257c03 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -681,6 +681,7 @@
 
     if (mWidth != 0 && mHeight != 0)
     {
+        egl::Display *display = getDisplay();
         IDirect3DDevice9 *device = getDevice();
         D3DFORMAT format = selectFormat(mImageArray[0].format);
 
@@ -722,6 +723,7 @@
                     return error(GL_OUT_OF_MEMORY, (IDirect3DBaseTexture9*)NULL);
                 }
 
+                display->endScene();
                 result = device->StretchRect(source, NULL, dest, NULL, D3DTEXF_NONE);
 
                 if (FAILED(result))
@@ -1056,6 +1058,7 @@
 
     if (mWidth != 0)
     {
+        egl::Display *display = getDisplay();
         IDirect3DDevice9 *device = getDevice();
         D3DFORMAT format = selectFormat(mImageArray[0][0].format);
 
@@ -1099,6 +1102,7 @@
                         return error(GL_OUT_OF_MEMORY, (IDirect3DBaseTexture9*)NULL);
                     }
 
+                    display->endScene();
                     result = device->StretchRect(source, NULL, dest, NULL, D3DTEXF_NONE);
 
                     if (FAILED(result))