Revert "Revert "Make the default framebuffer owned by Surface""

Reland the commit after fixing a bug in FramebufferAttachment.

This reverts commit 18fdcbcf1d02d3b3b4b5c712f05058f2e8d629c6.

BUG=angleproject:891

Change-Id: I07e08de52bfce8d84d070fc7bc15883009298a4d
Reviewed-on: https://chromium-review.googlesource.com/294831
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index 75abf3b..73aafab 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -605,7 +605,7 @@
             GLenum readInternalFormat = readColorBuffer->getInternalFormat();
             const InternalFormat &readFormatInfo = GetInternalFormatInfo(readInternalFormat);
 
-            for (GLuint i = 0; i < context->getCaps().maxColorAttachments; i++)
+            for (size_t i = 0; i < drawFramebuffer->getNumColorBuffers(); i++)
             {
                 if (drawFramebuffer->isEnabledColorAttachment(i))
                 {
@@ -661,7 +661,8 @@
                     return false;
                 }
 
-                for (GLuint colorAttachment = 0; colorAttachment < context->getCaps().maxColorAttachments; ++colorAttachment)
+                for (size_t colorAttachment = 0;
+                     colorAttachment < drawFramebuffer->getNumColorBuffers(); ++colorAttachment)
                 {
                     if (drawFramebuffer->isEnabledColorAttachment(colorAttachment))
                     {