OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 WebGraphicsContext3D* context3d = output_surface_->context3d(); | 974 WebGraphicsContext3D* context3d = output_surface_->context3d(); |
975 DCHECK(context3d); | 975 DCHECK(context3d); |
976 DCHECK(resource->gl_pixel_buffer_id); | 976 DCHECK(resource->gl_pixel_buffer_id); |
977 context3d->bindBuffer( | 977 context3d->bindBuffer( |
978 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, | 978 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, |
979 resource->gl_pixel_buffer_id); | 979 resource->gl_pixel_buffer_id); |
980 uint8_t* image = static_cast<uint8_t*>( | 980 uint8_t* image = static_cast<uint8_t*>( |
981 context3d->mapBufferCHROMIUM( | 981 context3d->mapBufferCHROMIUM( |
982 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, GL_WRITE_ONLY)); | 982 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, GL_WRITE_ONLY)); |
983 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); | 983 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); |
| 984 // Buffer is required to be 4-byte aligned. |
| 985 CHECK(!(reinterpret_cast<intptr_t>(image) & 3)); |
984 return image; | 986 return image; |
985 } | 987 } |
986 | 988 |
987 if (resource->pixels) | 989 if (resource->pixels) |
988 return resource->pixel_buffer; | 990 return resource->pixel_buffer; |
989 | 991 |
990 return NULL; | 992 return NULL; |
991 } | 993 } |
992 | 994 |
993 void ResourceProvider::UnmapPixelBuffer(ResourceId id) { | 995 void ResourceProvider::UnmapPixelBuffer(ResourceId id) { |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 WebGraphicsContext3D* context3d = output_surface_->context3d(); | 1367 WebGraphicsContext3D* context3d = output_surface_->context3d(); |
1366 DCHECK(context3d); | 1368 DCHECK(context3d); |
1367 int stride = 0; | 1369 int stride = 0; |
1368 context3d->getImageParameterivCHROMIUM( | 1370 context3d->getImageParameterivCHROMIUM( |
1369 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, &stride); | 1371 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, &stride); |
1370 return stride; | 1372 return stride; |
1371 } | 1373 } |
1372 | 1374 |
1373 | 1375 |
1374 } // namespace cc | 1376 } // namespace cc |
OLD | NEW |