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 <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2187 context_->mapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 2187 context_->mapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
2188 GL_READ_ONLY)); | 2188 GL_READ_ONLY)); |
2189 | 2189 |
2190 if (src_pixels) { | 2190 if (src_pixels) { |
2191 size_t row_bytes = size.width() * 4; | 2191 size_t row_bytes = size.width() * 4; |
2192 int num_rows = size.height(); | 2192 int num_rows = size.height(); |
2193 size_t total_bytes = num_rows * row_bytes; | 2193 size_t total_bytes = num_rows * row_bytes; |
2194 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) { | 2194 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) { |
2195 // Flip Y axis. | 2195 // Flip Y axis. |
2196 size_t src_y = total_bytes - dest_y - row_bytes; | 2196 size_t src_y = total_bytes - dest_y - row_bytes; |
2197 // Swizzle BGRA -> RGBA. | 2197 // Swizzle OpenGL -> Skia byte order. |
2198 for (size_t x = 0; x < row_bytes; x += 4) { | 2198 for (size_t x = 0; x < row_bytes; x += 4) { |
2199 dest_pixels[dest_y + (x + 0)] = src_pixels[src_y + (x + 2)]; | 2199 dest_pixels[dest_y + x + SK_R32_SHIFT/8] = src_pixels[src_y + x + 0]; |
2200 dest_pixels[dest_y + (x + 1)] = src_pixels[src_y + (x + 1)]; | 2200 dest_pixels[dest_y + x + SK_G32_SHIFT/8] = src_pixels[src_y + x + 1]; |
2201 dest_pixels[dest_y + (x + 2)] = src_pixels[src_y + (x + 0)]; | 2201 dest_pixels[dest_y + x + SK_B32_SHIFT/8] = src_pixels[src_y + x + 2]; |
2202 dest_pixels[dest_y + (x + 3)] = src_pixels[src_y + (x + 3)]; | 2202 dest_pixels[dest_y + x + SK_A32_SHIFT/8] = src_pixels[src_y + x + 3]; |
2203 } | 2203 } |
2204 } | 2204 } |
2205 | 2205 |
2206 GLC(context_, context_->unmapBufferCHROMIUM( | 2206 GLC(context_, context_->unmapBufferCHROMIUM( |
2207 GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM)); | 2207 GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM)); |
2208 } | 2208 } |
2209 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 2209 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
2210 0)); | 2210 0)); |
2211 GLC(context_, context_->deleteBuffer(source_buffer)); | 2211 GLC(context_, context_->deleteBuffer(source_buffer)); |
2212 } | 2212 } |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2782 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 2782 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
2783 | 2783 |
2784 ReleaseRenderPassTextures(); | 2784 ReleaseRenderPassTextures(); |
2785 } | 2785 } |
2786 | 2786 |
2787 bool GLRenderer::IsContextLost() { | 2787 bool GLRenderer::IsContextLost() { |
2788 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2788 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
2789 } | 2789 } |
2790 | 2790 |
2791 } // namespace cc | 2791 } // namespace cc |
OLD | NEW |