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/Blit.cpp b/src/libGLESv2/Blit.cpp
index f056d2b..2cec8c2 100644
--- a/src/libGLESv2/Blit.cpp
+++ b/src/libGLESv2/Blit.cpp
@@ -370,6 +370,7 @@
 
 IDirect3DTexture9 *Blit::copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &sourceRect)
 {
+    egl::Display *display = getDisplay();
     IDirect3DDevice9 *device = getDevice();
 
     D3DSURFACE_DESC sourceDesc;
@@ -401,6 +402,7 @@
     d3dSourceRect.top = sourceRect.top;
     d3dSourceRect.bottom = sourceRect.bottom;
 
+    display->endScene();
     result = device->StretchRect(surface, &d3dSourceRect, textureSurface, NULL, D3DTEXF_NONE);
 
     textureSurface->Release();
@@ -456,14 +458,14 @@
 
 void Blit::render()
 {
+    egl::Display *display = getDisplay();
     IDirect3DDevice9 *device = getDevice();
 
     HRESULT hr = device->SetStreamSource(0, mQuadVertexBuffer, 0, 2 * sizeof(float));
     hr = device->SetVertexDeclaration(mQuadVertexDeclaration);
 
-    device->BeginScene();
+    display->startScene();
     hr = device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
-    device->EndScene();
 }
 
 }