Expose EXT_discard_framebuffer

R=viettrungluu@chromium.org

Review URL: https://codereview.chromium.org/1317123004 .
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 8f0491c..e0e34f6 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -39,6 +39,7 @@
                             "CHROMIUM_sync_point",
                             "CHROMIUM_texture_mailbox",
                             "EXT_debug_marker",
+                            "EXT_discard_framebuffer",
                             "EXT_texture_storage",
                             "KHR_blend_equation_advanced",
                             "OES_vertex_array_object",
diff --git a/mojo/gles2/gles2_impl.cc b/mojo/gles2/gles2_impl.cc
index 9c50abc..e4de3f2 100644
--- a/mojo/gles2/gles2_impl.cc
+++ b/mojo/gles2/gles2_impl.cc
@@ -62,6 +62,7 @@
 #include "mojo/public/platform/native/gles2/call_visitor_chromium_sync_point_autogen.h"
 #include "mojo/public/platform/native/gles2/call_visitor_chromium_texture_mailbox_autogen.h"
 #include "mojo/public/platform/native/gles2/call_visitor_ext_debug_marker_autogen.h"
+#include "mojo/public/platform/native/gles2/call_visitor_ext_discard_framebuffer_autogen.h"
 #include "mojo/public/platform/native/gles2/call_visitor_ext_texture_storage_autogen.h"
 #include "mojo/public/platform/native/gles2/call_visitor_khr_blend_equation_advanced_autogen.h"
 #include "mojo/public/platform/native/gles2/call_visitor_occlusion_query_ext_autogen.h"
diff --git a/mojo/gpu/mojo_gles2_impl_autogen.cc b/mojo/gpu/mojo_gles2_impl_autogen.cc
index 7842a3a..2fb812e 100644
--- a/mojo/gpu/mojo_gles2_impl_autogen.cc
+++ b/mojo/gpu/mojo_gles2_impl_autogen.cc
@@ -1542,7 +1542,8 @@
 void MojoGLES2Impl::DiscardFramebufferEXT(GLenum target,
                                           GLsizei count,
                                           const GLenum* attachments) {
-  NOTREACHED() << "Unimplemented DiscardFramebufferEXT.";
+  MojoGLES2MakeCurrent(context_);
+  glDiscardFramebufferEXT(target, count, attachments);
 }
 void MojoGLES2Impl::LoseContextCHROMIUM(GLenum current, GLenum other) {
   NOTREACHED() << "Unimplemented LoseContextCHROMIUM.";
diff --git a/mojo/public/platform/native/BUILD.gn b/mojo/public/platform/native/BUILD.gn
index eee3f0c..a0d6891 100644
--- a/mojo/public/platform/native/BUILD.gn
+++ b/mojo/public/platform/native/BUILD.gn
@@ -76,6 +76,8 @@
     "gles2_impl_chromium_texture_mailbox_thunks.h",
     "gles2_impl_ext_debug_marker_thunks.cc",
     "gles2_impl_ext_debug_marker_thunks.h",
+    "gles2_impl_ext_discard_framebuffer_thunks.cc",
+    "gles2_impl_ext_discard_framebuffer_thunks.h",
     "gles2_impl_ext_texture_storage_thunks.cc",
     "gles2_impl_ext_texture_storage_thunks.h",
     "gles2_impl_khr_blend_equation_advanced_thunks.cc",
diff --git a/mojo/public/platform/native/gles2/call_visitor_ext_discard_framebuffer_autogen.h b/mojo/public/platform/native/gles2/call_visitor_ext_discard_framebuffer_autogen.h
new file mode 100644
index 0000000..2b080ab
--- /dev/null
+++ b/mojo/public/platform/native/gles2/call_visitor_ext_discard_framebuffer_autogen.h
@@ -0,0 +1,14 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is auto-generated from
+// gpu/command_buffer/build_gles2_cmd_buffer.py
+// It's formatted by clang-format using chromium coding style:
+//    clang-format -i -style=chromium filename
+// DO NOT EDIT!
+
+VISIT_GL_CALL(DiscardFramebufferEXT,
+              void,
+              (GLenum target, GLsizei count, const GLenum* attachments),
+              (target, count, attachments))
diff --git a/mojo/public/platform/native/gles2_impl_ext_discard_framebuffer_thunks.cc b/mojo/public/platform/native/gles2_impl_ext_discard_framebuffer_thunks.cc
new file mode 100644
index 0000000..902aafc
--- /dev/null
+++ b/mojo/public/platform/native/gles2_impl_ext_discard_framebuffer_thunks.cc
@@ -0,0 +1,40 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is auto-generated from
+// gpu/command_buffer/build_gles2_cmd_buffer.py
+// It's formatted by clang-format using chromium coding style:
+//    clang-format -i -style=chromium filename
+// DO NOT EDIT!
+
+#include "mojo/public/platform/native/gles2_impl_ext_discard_framebuffer_thunks.h"
+
+#include <assert.h>
+
+#include "mojo/public/platform/native/thunk_export.h"
+
+extern "C" {
+
+static MojoGLES2ImplEXTDiscardFramebufferThunks
+    g_impl_ext_discard_framebuffer_thunks = {0};
+
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS)   \
+  ReturnType GL_APIENTRY gl##Function PARAMETERS {                   \
+    assert(g_impl_ext_discard_framebuffer_thunks.Function);          \
+    return g_impl_ext_discard_framebuffer_thunks.Function ARGUMENTS; \
+  }
+#include "mojo/public/platform/native/gles2/call_visitor_ext_discard_framebuffer_autogen.h"
+#undef VISIT_GL_CALL
+
+extern "C" THUNK_EXPORT size_t MojoSetGLES2ImplEXTDiscardFramebufferThunks(
+    const MojoGLES2ImplEXTDiscardFramebufferThunks*
+        gles2_impl_ext_discard_framebuffer_thunks) {
+  if (gles2_impl_ext_discard_framebuffer_thunks->size >=
+      sizeof(g_impl_ext_discard_framebuffer_thunks))
+    g_impl_ext_discard_framebuffer_thunks =
+        *gles2_impl_ext_discard_framebuffer_thunks;
+  return sizeof(g_impl_ext_discard_framebuffer_thunks);
+}
+
+}  // extern "C"
diff --git a/mojo/public/platform/native/gles2_impl_ext_discard_framebuffer_thunks.h b/mojo/public/platform/native/gles2_impl_ext_discard_framebuffer_thunks.h
new file mode 100644
index 0000000..25d681f
--- /dev/null
+++ b/mojo/public/platform/native/gles2_impl_ext_discard_framebuffer_thunks.h
@@ -0,0 +1,54 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is auto-generated from
+// gpu/command_buffer/build_gles2_cmd_buffer.py
+// It's formatted by clang-format using chromium coding style:
+//    clang-format -i -style=chromium filename
+// DO NOT EDIT!
+
+#ifndef MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_IMPL_EXT_DISCARD_FRAMEBUFFER_THUNKS_H_
+#define MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_IMPL_EXT_DISCARD_FRAMEBUFFER_THUNKS_H_
+
+#include <stddef.h>
+
+#define GL_GLEXT_PROTOTYPES
+#include "mojo/public/c/gpu/GLES2/gl2extmojo.h"
+
+// Specifies the frozen API for the EXT_discard_framebuffer extension.
+#pragma pack(push, 8)
+struct MojoGLES2ImplEXTDiscardFramebufferThunks {
+  size_t size;  // Should be set to sizeof(*this).
+
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) \
+  ReturnType(GL_APIENTRY* Function) PARAMETERS;
+#include "mojo/public/platform/native/gles2/call_visitor_ext_discard_framebuffer_autogen.h"
+#undef VISIT_GL_CALL
+};
+#pragma pack(pop)
+
+#ifdef __cplusplus
+// Intended to be called from the embedder to get the embedder's implementation
+// of ext_discard_framebuffer.
+inline MojoGLES2ImplEXTDiscardFramebufferThunks
+MojoMakeGLES2ImplEXTDiscardFramebufferThunks() {
+  MojoGLES2ImplEXTDiscardFramebufferThunks
+      gles2_impl_ext_discard_framebuffer_thunks = {
+          sizeof(MojoGLES2ImplEXTDiscardFramebufferThunks),
+#define VISIT_GL_CALL(Function, ReturnType, PARAMETERS, ARGUMENTS) gl##Function,
+#include "mojo/public/platform/native/gles2/call_visitor_ext_discard_framebuffer_autogen.h"
+#undef VISIT_GL_CALL
+      };
+
+  return gles2_impl_ext_discard_framebuffer_thunks;
+}
+#endif  // __cplusplus
+
+// Use this type for the function found by dynamically discovering it in
+// a DSO linked with mojo_system.
+// The contents of |gles2_impl_ext_discard_framebuffer_thunks| are copied.
+typedef size_t (*MojoSetGLES2ImplEXTDiscardFramebufferThunksFn)(
+    const MojoGLES2ImplEXTDiscardFramebufferThunks* thunks);
+
+#endif  // MOJO_PUBLIC_PLATFORM_NATIVE_GLES2_IMPL_EXT_DISCARD_FRAMEBUFFER_THUNKS_H_
diff --git a/shell/native_application_support.cc b/shell/native_application_support.cc
index 35b280e..a27456d 100644
--- a/shell/native_application_support.cc
+++ b/shell/native_application_support.cc
@@ -14,6 +14,7 @@
 #include "mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.h"
 #include "mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks.h"
 #include "mojo/public/platform/native/gles2_impl_ext_debug_marker_thunks.h"
+#include "mojo/public/platform/native/gles2_impl_ext_discard_framebuffer_thunks.h"
 #include "mojo/public/platform/native/gles2_impl_ext_texture_storage_thunks.h"
 #include "mojo/public/platform/native/gles2_impl_khr_blend_equation_advanced_thunks.h"
 #include "mojo/public/platform/native/gles2_impl_occlusion_query_ext_thunks.h"
@@ -84,6 +85,8 @@
             app_library);
   SetThunks(MojoMakeGLES2ImplEXTDebugMarkerThunks,
             "MojoSetGLES2ImplEXTDebugMarkerThunks", app_library);
+  SetThunks(MojoMakeGLES2ImplEXTDiscardFramebufferThunks,
+            "MojoSetGLES2ImplEXTDiscardFramebufferThunks", app_library);
   SetThunks(MojoMakeGLES2ImplEXTTextureStorageThunks,
             "MojoSetGLES2ImplEXTTextureStorageThunks", app_library);
   SetThunks(MojoMakeGLES2ImplKHRBlendEquationAdvancedThunks,