Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "cc/output/gl_frame_data.h" | 23 #include "cc/output/gl_frame_data.h" |
| 24 #include "cc/output/output_surface.h" | 24 #include "cc/output/output_surface.h" |
| 25 #include "cc/output/render_surface_filters.h" | 25 #include "cc/output/render_surface_filters.h" |
| 26 #include "cc/quads/picture_draw_quad.h" | 26 #include "cc/quads/picture_draw_quad.h" |
| 27 #include "cc/quads/render_pass.h" | 27 #include "cc/quads/render_pass.h" |
| 28 #include "cc/quads/stream_video_draw_quad.h" | 28 #include "cc/quads/stream_video_draw_quad.h" |
| 29 #include "cc/quads/texture_draw_quad.h" | 29 #include "cc/quads/texture_draw_quad.h" |
| 30 #include "cc/resources/layer_quad.h" | 30 #include "cc/resources/layer_quad.h" |
| 31 #include "cc/resources/priority_calculator.h" | 31 #include "cc/resources/priority_calculator.h" |
| 32 #include "cc/resources/scoped_resource.h" | 32 #include "cc/resources/scoped_resource.h" |
| 33 #include "cc/resources/sync_point_helper.h" | |
| 33 #include "cc/trees/damage_tracker.h" | 34 #include "cc/trees/damage_tracker.h" |
| 34 #include "cc/trees/proxy.h" | 35 #include "cc/trees/proxy.h" |
| 35 #include "cc/trees/single_thread_proxy.h" | 36 #include "cc/trees/single_thread_proxy.h" |
| 36 #include "gpu/GLES2/gl2extchromium.h" | 37 #include "gpu/GLES2/gl2extchromium.h" |
| 37 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" | 38 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" |
| 38 #include "third_party/khronos/GLES2/gl2.h" | 39 #include "third_party/khronos/GLES2/gl2.h" |
| 39 #include "third_party/khronos/GLES2/gl2ext.h" | 40 #include "third_party/khronos/GLES2/gl2ext.h" |
| 40 #include "third_party/skia/include/core/SkBitmap.h" | 41 #include "third_party/skia/include/core/SkBitmap.h" |
| 41 #include "third_party/skia/include/core/SkColor.h" | 42 #include "third_party/skia/include/core/SkColor.h" |
| 42 #include "third_party/skia/include/core/SkColorFilter.h" | 43 #include "third_party/skia/include/core/SkColorFilter.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 return false; | 81 return false; |
| 81 #endif | 82 #endif |
| 82 } | 83 } |
| 83 | 84 |
| 84 // Smallest unit that impact anti-aliasing output. We use this to | 85 // Smallest unit that impact anti-aliasing output. We use this to |
| 85 // determine when anti-aliasing is unnecessary. | 86 // determine when anti-aliasing is unnecessary. |
| 86 const float kAntiAliasingEpsilon = 1.0f / 1024.0f; | 87 const float kAntiAliasingEpsilon = 1.0f / 1024.0f; |
| 87 | 88 |
| 88 } // anonymous namespace | 89 } // anonymous namespace |
| 89 | 90 |
| 91 struct GLRenderer::PendingAsyncReadPixels { | |
| 92 PendingAsyncReadPixels() : buffer(0) {} | |
| 93 | |
| 94 CopyRenderPassCallback copy_callback; | |
| 95 base::CancelableClosure finished_read_pixels_callback; | |
| 96 unsigned buffer; | |
| 97 | |
| 98 private: | |
| 99 DISALLOW_COPY_AND_ASSIGN(PendingAsyncReadPixels); | |
| 100 }; | |
| 101 | |
| 90 scoped_ptr<GLRenderer> GLRenderer::Create(RendererClient* client, | 102 scoped_ptr<GLRenderer> GLRenderer::Create(RendererClient* client, |
| 91 OutputSurface* output_surface, | 103 OutputSurface* output_surface, |
| 92 ResourceProvider* resource_provider, | 104 ResourceProvider* resource_provider, |
| 93 int highp_threshold_min) { | 105 int highp_threshold_min) { |
| 94 scoped_ptr<GLRenderer> renderer(new GLRenderer( | 106 scoped_ptr<GLRenderer> renderer(new GLRenderer( |
| 95 client, output_surface, resource_provider, highp_threshold_min)); | 107 client, output_surface, resource_provider, highp_threshold_min)); |
| 96 if (!renderer->Initialize()) | 108 if (!renderer->Initialize()) |
| 97 return scoped_ptr<GLRenderer>(); | 109 return scoped_ptr<GLRenderer>(); |
| 98 | 110 |
| 99 return renderer.Pass(); | 111 return renderer.Pass(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 | 197 |
| 186 if (!InitializeSharedObjects()) | 198 if (!InitializeSharedObjects()) |
| 187 return false; | 199 return false; |
| 188 | 200 |
| 189 // Make sure the viewport and context gets initialized, even if it is to zero. | 201 // Make sure the viewport and context gets initialized, even if it is to zero. |
| 190 ViewportChanged(); | 202 ViewportChanged(); |
| 191 return true; | 203 return true; |
| 192 } | 204 } |
| 193 | 205 |
| 194 GLRenderer::~GLRenderer() { | 206 GLRenderer::~GLRenderer() { |
| 207 while (!pending_async_read_pixels_.empty()) { | |
| 208 pending_async_read_pixels_.back()->finished_read_pixels_callback.Cancel(); | |
| 209 pending_async_read_pixels_.back()->copy_callback.Run( | |
| 210 scoped_ptr<SkBitmap>()); | |
| 211 pending_async_read_pixels_.pop_back(); | |
| 212 } | |
| 213 | |
| 195 context_->setMemoryAllocationChangedCallbackCHROMIUM(NULL); | 214 context_->setMemoryAllocationChangedCallbackCHROMIUM(NULL); |
| 196 CleanupSharedObjects(); | 215 CleanupSharedObjects(); |
| 197 } | 216 } |
| 198 | 217 |
| 199 const RendererCapabilities& GLRenderer::Capabilities() const { | 218 const RendererCapabilities& GLRenderer::Capabilities() const { |
| 200 return capabilities_; | 219 return capabilities_; |
| 201 } | 220 } |
| 202 | 221 |
| 203 WebGraphicsContext3D* GLRenderer::Context() { return context_; } | 222 WebGraphicsContext3D* GLRenderer::Context() { return context_; } |
| 204 | 223 |
| (...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1770 | 1789 |
| 1771 void GLRenderer::EnsureScissorTestDisabled() { | 1790 void GLRenderer::EnsureScissorTestDisabled() { |
| 1772 if (!is_scissor_enabled_) | 1791 if (!is_scissor_enabled_) |
| 1773 return; | 1792 return; |
| 1774 | 1793 |
| 1775 FlushTextureQuadCache(); | 1794 FlushTextureQuadCache(); |
| 1776 GLC(context_, context_->disable(GL_SCISSOR_TEST)); | 1795 GLC(context_, context_->disable(GL_SCISSOR_TEST)); |
| 1777 is_scissor_enabled_ = false; | 1796 is_scissor_enabled_ = false; |
| 1778 } | 1797 } |
| 1779 | 1798 |
| 1780 void GLRenderer::CopyCurrentRenderPassToBitmap(DrawingFrame* frame, | 1799 void GLRenderer::CopyCurrentRenderPassToBitmap( |
| 1781 SkBitmap* bitmap) { | 1800 DrawingFrame* frame, |
| 1782 gfx::Size render_pass_size = frame->current_render_pass->output_rect.size(); | 1801 const CopyRenderPassCallback& callback) { |
| 1783 bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 1802 GetFramebufferPixelsAsync(frame->current_render_pass->output_rect, callback); |
| 1784 render_pass_size.width(), | |
| 1785 render_pass_size.height()); | |
| 1786 if (bitmap->allocPixels()) { | |
| 1787 bitmap->lockPixels(); | |
| 1788 GetFramebufferPixels(bitmap->getPixels(), gfx::Rect(render_pass_size)); | |
| 1789 bitmap->unlockPixels(); | |
| 1790 } | |
| 1791 } | 1803 } |
| 1792 | 1804 |
| 1793 void GLRenderer::ToGLMatrix(float* gl_matrix, const gfx::Transform& transform) { | 1805 void GLRenderer::ToGLMatrix(float* gl_matrix, const gfx::Transform& transform) { |
| 1794 transform.matrix().asColMajorf(gl_matrix); | 1806 transform.matrix().asColMajorf(gl_matrix); |
| 1795 } | 1807 } |
| 1796 | 1808 |
| 1797 void GLRenderer::SetShaderQuadF(const gfx::QuadF& quad, int quad_location) { | 1809 void GLRenderer::SetShaderQuadF(const gfx::QuadF& quad, int quad_location) { |
| 1798 if (quad_location == -1) | 1810 if (quad_location == -1) |
| 1799 return; | 1811 return; |
| 1800 | 1812 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1982 | 1994 |
| 1983 void GLRenderer::EnsureBackbuffer() { | 1995 void GLRenderer::EnsureBackbuffer() { |
| 1984 if (!is_backbuffer_discarded_) | 1996 if (!is_backbuffer_discarded_) |
| 1985 return; | 1997 return; |
| 1986 | 1998 |
| 1987 output_surface_->EnsureBackbuffer(); | 1999 output_surface_->EnsureBackbuffer(); |
| 1988 is_backbuffer_discarded_ = false; | 2000 is_backbuffer_discarded_ = false; |
| 1989 } | 2001 } |
| 1990 | 2002 |
| 1991 void GLRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) { | 2003 void GLRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) { |
| 2004 if (!pixels || rect.IsEmpty()) | |
| 2005 return; | |
| 2006 | |
| 2007 scoped_ptr<PendingAsyncReadPixels> pending_read(new PendingAsyncReadPixels); | |
| 2008 pending_async_read_pixels_.insert(pending_async_read_pixels_.begin(), | |
| 2009 pending_read.Pass()); | |
| 2010 | |
| 2011 // This is a syncronous call since the callback is null. | |
| 2012 DoGetFramebufferPixels(static_cast<uint8*>(pixels), | |
| 2013 rect, | |
| 2014 AsyncGetFramebufferPixelsCleanupCallback()); | |
| 2015 } | |
| 2016 | |
| 2017 void GLRenderer::GetFramebufferPixelsAsync(gfx::Rect rect, | |
| 2018 CopyRenderPassCallback callback) { | |
| 2019 if (callback.is_null()) | |
| 2020 return; | |
| 2021 if (rect.IsEmpty()) { | |
| 2022 callback.Run(scoped_ptr<SkBitmap>()); | |
| 2023 return; | |
| 2024 } | |
| 2025 | |
| 2026 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | |
| 2027 bitmap->setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); | |
| 2028 bitmap->allocPixels(); | |
| 2029 | |
| 2030 scoped_ptr<SkAutoLockPixels> lock(new SkAutoLockPixels(*bitmap)); | |
| 2031 | |
| 2032 // Save a pointer to the pixels, the bitmap is owned by the cleanup_callback. | |
| 2033 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); | |
| 2034 | |
| 2035 AsyncGetFramebufferPixelsCleanupCallback cleanup_callback = base::Bind( | |
| 2036 &GLRenderer::PassOnSkBitmap, | |
| 2037 base::Unretained(this), | |
| 2038 base::Passed(&bitmap), | |
| 2039 base::Passed(&lock), | |
| 2040 callback); | |
| 2041 | |
| 2042 scoped_ptr<PendingAsyncReadPixels> pending_read(new PendingAsyncReadPixels); | |
| 2043 pending_read->copy_callback = callback; | |
| 2044 pending_async_read_pixels_.insert(pending_async_read_pixels_.begin(), | |
| 2045 pending_read.Pass()); | |
| 2046 | |
| 2047 // This is an asyncronous call since the callback is not null. | |
| 2048 DoGetFramebufferPixels(pixels, rect, cleanup_callback); | |
| 2049 } | |
| 2050 | |
| 2051 void GLRenderer::DoGetFramebufferPixels( | |
| 2052 uint8* dest_pixels, | |
| 2053 gfx::Rect rect, | |
| 2054 const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback) { | |
| 1992 DCHECK(rect.right() <= ViewportWidth()); | 2055 DCHECK(rect.right() <= ViewportWidth()); |
| 1993 DCHECK(rect.bottom() <= ViewportHeight()); | 2056 DCHECK(rect.bottom() <= ViewportHeight()); |
| 1994 | 2057 |
| 1995 if (!pixels) | 2058 bool is_async = !cleanup_callback.is_null(); |
| 1996 return; | |
| 1997 | 2059 |
| 1998 MakeContextCurrent(); | 2060 MakeContextCurrent(); |
| 1999 | 2061 |
| 2000 bool do_workaround = NeedsIOSurfaceReadbackWorkaround(); | 2062 bool do_workaround = NeedsIOSurfaceReadbackWorkaround(); |
| 2001 | 2063 |
| 2002 GLuint temporary_texture = 0; | 2064 unsigned temporary_texture = 0; |
| 2003 GLuint temporary_fbo = 0; | 2065 unsigned temporary_fbo = 0; |
| 2004 | 2066 |
| 2005 if (do_workaround) { | 2067 if (do_workaround) { |
| 2006 // On Mac OS X, calling glReadPixels() against an FBO whose color attachment | 2068 // On Mac OS X, calling glReadPixels() against an FBO whose color attachment |
| 2007 // is an IOSurface-backed texture causes corruption of future glReadPixels() | 2069 // is an IOSurface-backed texture causes corruption of future glReadPixels() |
| 2008 // calls, even those on different OpenGL contexts. It is believed that this | 2070 // calls, even those on different OpenGL contexts. It is believed that this |
| 2009 // is the root cause of top crasher | 2071 // is the root cause of top crasher |
| 2010 // http://crbug.com/99393. <rdar://problem/10949687> | 2072 // http://crbug.com/99393. <rdar://problem/10949687> |
| 2011 | 2073 |
| 2012 temporary_texture = context_->createTexture(); | 2074 temporary_texture = context_->createTexture(); |
| 2013 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, temporary_texture)); | 2075 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, temporary_texture)); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 2041 context_->framebufferTexture2D(GL_FRAMEBUFFER, | 2103 context_->framebufferTexture2D(GL_FRAMEBUFFER, |
| 2042 GL_COLOR_ATTACHMENT0, | 2104 GL_COLOR_ATTACHMENT0, |
| 2043 GL_TEXTURE_2D, | 2105 GL_TEXTURE_2D, |
| 2044 temporary_texture, | 2106 temporary_texture, |
| 2045 0)); | 2107 0)); |
| 2046 | 2108 |
| 2047 DCHECK(context_->checkFramebufferStatus(GL_FRAMEBUFFER) == | 2109 DCHECK(context_->checkFramebufferStatus(GL_FRAMEBUFFER) == |
| 2048 GL_FRAMEBUFFER_COMPLETE); | 2110 GL_FRAMEBUFFER_COMPLETE); |
| 2049 } | 2111 } |
| 2050 | 2112 |
| 2051 scoped_ptr<uint8_t[]> src_pixels( | 2113 unsigned buffer = context_->createBuffer(); |
| 2052 new uint8_t[rect.width() * rect.height() * 4]); | 2114 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
| 2115 buffer)); | |
| 2116 GLC(context_, context_->bufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | |
| 2117 4 * rect.size().GetArea(), | |
| 2118 NULL, | |
| 2119 GL_STREAM_READ)); | |
| 2120 | |
| 2053 GLC(context_, | 2121 GLC(context_, |
| 2054 context_->readPixels(rect.x(), | 2122 context_->readPixels(rect.x(), |
| 2055 ViewportSize().height() - rect.bottom(), | 2123 ViewportSize().height() - rect.bottom(), |
| 2056 rect.width(), | 2124 rect.width(), |
| 2057 rect.height(), | 2125 rect.height(), |
| 2058 GL_RGBA, | 2126 GL_RGBA, |
| 2059 GL_UNSIGNED_BYTE, | 2127 GL_UNSIGNED_BYTE, |
| 2060 src_pixels.get())); | 2128 NULL)); |
| 2061 | 2129 |
| 2062 uint8_t* dest_pixels = static_cast<uint8_t*>(pixels); | 2130 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
| 2063 size_t row_bytes = rect.width() * 4; | 2131 0)); |
| 2064 int num_rows = rect.height(); | |
| 2065 size_t total_bytes = num_rows * row_bytes; | |
| 2066 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) { | |
| 2067 // Flip Y axis. | |
| 2068 size_t src_y = total_bytes - dest_y - row_bytes; | |
| 2069 // Swizzle BGRA -> RGBA. | |
| 2070 for (size_t x = 0; x < row_bytes; x += 4) { | |
| 2071 dest_pixels[dest_y + (x + 0)] = src_pixels.get()[src_y + (x + 2)]; | |
| 2072 dest_pixels[dest_y + (x + 1)] = src_pixels.get()[src_y + (x + 1)]; | |
| 2073 dest_pixels[dest_y + (x + 2)] = src_pixels.get()[src_y + (x + 0)]; | |
| 2074 dest_pixels[dest_y + (x + 3)] = src_pixels.get()[src_y + (x + 3)]; | |
| 2075 } | |
| 2076 } | |
| 2077 | 2132 |
| 2078 if (do_workaround) { | 2133 if (do_workaround) { |
| 2079 // Clean up. | 2134 // Clean up. |
| 2080 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); | 2135 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); |
| 2081 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); | 2136 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); |
| 2082 GLC(context_, context_->deleteFramebuffer(temporary_fbo)); | 2137 GLC(context_, context_->deleteFramebuffer(temporary_fbo)); |
| 2083 GLC(context_, context_->deleteTexture(temporary_texture)); | 2138 GLC(context_, context_->deleteTexture(temporary_texture)); |
| 2084 } | 2139 } |
| 2085 | 2140 |
| 2141 base::Closure finished_callback = | |
| 2142 base::Bind(&GLRenderer::FinishedReadback, | |
| 2143 base::Unretained(this), | |
| 2144 cleanup_callback, | |
| 2145 buffer, | |
| 2146 dest_pixels, | |
| 2147 rect.size()); | |
| 2148 // Save the finished_callback so it can be cancelled. | |
| 2149 pending_async_read_pixels_.front()->finished_read_pixels_callback.Reset( | |
| 2150 finished_callback); | |
| 2151 | |
| 2152 // Save the buffer to verify the callbacks happen in the expected order. | |
| 2153 pending_async_read_pixels_.front()->buffer = buffer; | |
| 2154 | |
| 2155 if (is_async) { | |
| 2156 unsigned sync_point = context_->insertSyncPoint(); | |
| 2157 SyncPointHelper::SignalSyncPoint( | |
| 2158 context_, | |
| 2159 sync_point, | |
| 2160 finished_callback); | |
| 2161 } else { | |
| 2162 resource_provider_->Finish(); | |
| 2163 finished_callback.Run(); | |
| 2164 } | |
| 2165 | |
| 2086 EnforceMemoryPolicy(); | 2166 EnforceMemoryPolicy(); |
| 2087 } | 2167 } |
| 2088 | 2168 |
| 2169 void GLRenderer::FinishedReadback( | |
| 2170 const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback, | |
| 2171 unsigned source_buffer, | |
| 2172 uint8* dest_pixels, | |
| 2173 gfx::Size size) { | |
| 2174 DCHECK(!pending_async_read_pixels_.empty()); | |
| 2175 DCHECK_EQ(source_buffer, pending_async_read_pixels_.back()->buffer); | |
| 2176 | |
| 2177 uint8* src_pixels = NULL; | |
| 2178 | |
| 2179 if (source_buffer != 0) { | |
| 2180 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | |
| 2181 source_buffer)); | |
| 2182 src_pixels = static_cast<uint8*>( | |
| 2183 context_->mapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | |
| 2184 GL_READ_ONLY)); | |
| 2185 | |
| 2186 if (src_pixels) { | |
| 2187 memcpy(dest_pixels, src_pixels, 4 * size.GetArea()); | |
| 2188 GLC(context_, context_->unmapBufferCHROMIUM( | |
| 2189 GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM)); | |
| 2190 } | |
| 2191 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | |
| 2192 0)); | |
| 2193 GLC(context_, context_->deleteBuffer(source_buffer)); | |
| 2194 } | |
| 2195 | |
| 2196 if (src_pixels) { | |
|
piman
2013/04/29 17:29:13
Mmh, you unmapped the buffer here. src_pixel isn't
danakj
2013/04/29 17:30:54
Oh.. right. This is silly. I will do this instead
| |
| 2197 size_t row_bytes = size.width() * 4; | |
| 2198 int num_rows = size.height(); | |
| 2199 size_t total_bytes = num_rows * row_bytes; | |
| 2200 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) { | |
| 2201 // Flip Y axis. | |
| 2202 size_t src_y = total_bytes - dest_y - row_bytes; | |
| 2203 // Swizzle BGRA -> RGBA. | |
| 2204 for (size_t x = 0; x < row_bytes; x += 4) { | |
| 2205 dest_pixels[dest_y + (x + 0)] = src_pixels[src_y + (x + 2)]; | |
|
piman
2013/04/29 17:29:13
Should all this be replacing the memcpy?
Why do th
danakj
2013/04/30 01:30:52
Done.
| |
| 2206 dest_pixels[dest_y + (x + 1)] = src_pixels[src_y + (x + 1)]; | |
| 2207 dest_pixels[dest_y + (x + 2)] = src_pixels[src_y + (x + 0)]; | |
| 2208 dest_pixels[dest_y + (x + 3)] = src_pixels[src_y + (x + 3)]; | |
| 2209 } | |
| 2210 } | |
| 2211 } | |
| 2212 | |
| 2213 // TODO(danakj): This can go away when synchronous readback is no more and its | |
| 2214 // contents can just move here. | |
| 2215 if (!cleanup_callback.is_null()) | |
| 2216 cleanup_callback.Run(src_pixels != NULL); | |
| 2217 | |
| 2218 pending_async_read_pixels_.pop_back(); | |
| 2219 } | |
| 2220 | |
| 2221 void GLRenderer::PassOnSkBitmap( | |
| 2222 scoped_ptr<SkBitmap> bitmap, | |
| 2223 scoped_ptr<SkAutoLockPixels> lock, | |
| 2224 const CopyRenderPassCallback& callback, | |
| 2225 bool success) { | |
| 2226 DCHECK(callback.Equals(pending_async_read_pixels_.back()->copy_callback)); | |
| 2227 | |
| 2228 lock.reset(); | |
| 2229 if (success) | |
| 2230 callback.Run(bitmap.Pass()); | |
| 2231 else | |
| 2232 callback.Run(scoped_ptr<SkBitmap>()); | |
| 2233 } | |
| 2234 | |
| 2089 bool GLRenderer::GetFramebufferTexture(ScopedResource* texture, | 2235 bool GLRenderer::GetFramebufferTexture(ScopedResource* texture, |
| 2090 gfx::Rect device_rect) { | 2236 gfx::Rect device_rect) { |
| 2091 DCHECK(!texture->id() || (texture->size() == device_rect.size() && | 2237 DCHECK(!texture->id() || (texture->size() == device_rect.size() && |
| 2092 texture->format() == GL_RGB)); | 2238 texture->format() == GL_RGB)); |
| 2093 | 2239 |
| 2094 if (!texture->id() && !texture->Allocate(device_rect.size(), | 2240 if (!texture->id() && !texture->Allocate(device_rect.size(), |
| 2095 GL_RGB, | 2241 GL_RGB, |
| 2096 ResourceProvider::TextureUsageAny)) | 2242 ResourceProvider::TextureUsageAny)) |
| 2097 return false; | 2243 return false; |
| 2098 | 2244 |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2635 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 2781 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
| 2636 | 2782 |
| 2637 ReleaseRenderPassTextures(); | 2783 ReleaseRenderPassTextures(); |
| 2638 } | 2784 } |
| 2639 | 2785 |
| 2640 bool GLRenderer::IsContextLost() { | 2786 bool GLRenderer::IsContextLost() { |
| 2641 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2787 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
| 2642 } | 2788 } |
| 2643 | 2789 |
| 2644 } // namespace cc | 2790 } // namespace cc |
| OLD | NEW |