OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/compositing_iosurface_mac.h" | 5 #include "content/browser/renderer_host/compositing_iosurface_mac.h" |
6 | 6 |
7 #include <OpenGL/OpenGL.h> | 7 #include <OpenGL/OpenGL.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 CHECK_GL_ERROR(); | 858 CHECK_GL_ERROR(); |
859 | 859 |
860 if (buf) { | 860 if (buf) { |
861 SkAutoLockPixels bitmap_lock(copy_context_.out_buf); | 861 SkAutoLockPixels bitmap_lock(copy_context_.out_buf); |
862 memcpy(copy_context_.out_buf.getPixels(), buf, | 862 memcpy(copy_context_.out_buf.getPixels(), buf, |
863 copy_context_.dest_size.GetArea() * 4); | 863 copy_context_.dest_size.GetArea() * 4); |
864 glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB); CHECK_GL_ERROR(); | 864 glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB); CHECK_GL_ERROR(); |
865 } | 865 } |
866 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); CHECK_GL_ERROR(); | 866 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); CHECK_GL_ERROR(); |
867 | 867 |
| 868 // Ref so they don't get deleted in CleanupResourcesForCopy. |
868 base::Callback<void(bool, const SkBitmap&)> callback = copy_context_.callback; | 869 base::Callback<void(bool, const SkBitmap&)> callback = copy_context_.callback; |
| 870 SkBitmap out_buf = copy_context_.out_buf; |
| 871 |
869 CleanupResourcesForCopy(); | 872 CleanupResourcesForCopy(); |
870 CGLSetCurrentContext(0); | 873 CGLSetCurrentContext(0); |
871 | 874 |
872 callback.Run(buf != NULL, copy_context_.out_buf); | 875 callback.Run(buf != NULL, out_buf); |
873 } | 876 } |
874 | 877 |
875 void CompositingIOSurfaceMac::CleanupResourcesForCopy() { | 878 void CompositingIOSurfaceMac::CleanupResourcesForCopy() { |
876 if (!copy_context_.started) | 879 if (!copy_context_.started) |
877 return; | 880 return; |
878 | 881 |
879 glDeleteFramebuffersEXT(1, ©_context_.frame_buffer); CHECK_GL_ERROR(); | 882 glDeleteFramebuffersEXT(1, ©_context_.frame_buffer); CHECK_GL_ERROR(); |
880 glDeleteTextures(1, ©_context_.frame_buffer_texture); CHECK_GL_ERROR(); | 883 glDeleteTextures(1, ©_context_.frame_buffer_texture); CHECK_GL_ERROR(); |
881 glDeleteBuffers(1, ©_context_.pixel_buffer); CHECK_GL_ERROR(); | 884 glDeleteBuffers(1, ©_context_.pixel_buffer); CHECK_GL_ERROR(); |
882 if (copy_context_.use_fence) { | 885 if (copy_context_.use_fence) { |
883 glDeleteFencesAPPLE(1, ©_context_.fence); CHECK_GL_ERROR(); | 886 glDeleteFencesAPPLE(1, ©_context_.fence); CHECK_GL_ERROR(); |
884 } | 887 } |
885 copy_context_.Reset(); | 888 copy_context_.Reset(); |
886 } | 889 } |
887 | 890 |
888 } // namespace content | 891 } // namespace content |
OLD | NEW |