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/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2142 | 2142 |
2143 uint8_t* ResourceProvider::MapImage(const Resource* resource, int* stride) { | 2143 uint8_t* ResourceProvider::MapImage(const Resource* resource, int* stride) { |
2144 DCHECK(ReadLockFenceHasPassed(resource)); | 2144 DCHECK(ReadLockFenceHasPassed(resource)); |
2145 DCHECK(resource->origin == Resource::Internal); | 2145 DCHECK(resource->origin == Resource::Internal); |
2146 DCHECK_EQ(resource->exported_count, 0); | 2146 DCHECK_EQ(resource->exported_count, 0); |
2147 | 2147 |
2148 if (resource->type == GLTexture) { | 2148 if (resource->type == GLTexture) { |
2149 DCHECK(resource->image_id); | 2149 DCHECK(resource->image_id); |
2150 GLES2Interface* gl = ContextGL(); | 2150 GLES2Interface* gl = ContextGL(); |
2151 DCHECK(gl); | 2151 DCHECK(gl); |
| 2152 // MapImageCHROMIUM should be called prior to GetImageParameterivCHROMIUM. |
| 2153 uint8_t* pixels = static_cast<uint8_t*>( |
| 2154 gl->MapImageCHROMIUM(resource->image_id, GL_READ_WRITE)); |
2152 gl->GetImageParameterivCHROMIUM( | 2155 gl->GetImageParameterivCHROMIUM( |
2153 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, stride); | 2156 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, stride); |
2154 return static_cast<uint8_t*>( | 2157 return pixels; |
2155 gl->MapImageCHROMIUM(resource->image_id, GL_READ_WRITE)); | |
2156 } | 2158 } |
2157 DCHECK_EQ(Bitmap, resource->type); | 2159 DCHECK_EQ(Bitmap, resource->type); |
2158 *stride = 0; | 2160 *stride = 0; |
2159 return resource->pixels; | 2161 return resource->pixels; |
2160 } | 2162 } |
2161 | 2163 |
2162 void ResourceProvider::UnmapImage(const Resource* resource) { | 2164 void ResourceProvider::UnmapImage(const Resource* resource) { |
2163 DCHECK(resource->origin == Resource::Internal); | 2165 DCHECK(resource->origin == Resource::Internal); |
2164 DCHECK_EQ(resource->exported_count, 0); | 2166 DCHECK_EQ(resource->exported_count, 0); |
2165 | 2167 |
(...skipping 14 matching lines...) Expand all Loading... |
2180 ContextProvider* context_provider = output_surface_->context_provider(); | 2182 ContextProvider* context_provider = output_surface_->context_provider(); |
2181 return context_provider ? context_provider->ContextGL() : NULL; | 2183 return context_provider ? context_provider->ContextGL() : NULL; |
2182 } | 2184 } |
2183 | 2185 |
2184 class GrContext* ResourceProvider::GrContext() const { | 2186 class GrContext* ResourceProvider::GrContext() const { |
2185 ContextProvider* context_provider = output_surface_->context_provider(); | 2187 ContextProvider* context_provider = output_surface_->context_provider(); |
2186 return context_provider ? context_provider->GrContext() : NULL; | 2188 return context_provider ? context_provider->GrContext() : NULL; |
2187 } | 2189 } |
2188 | 2190 |
2189 } // namespace cc | 2191 } // namespace cc |
OLD | NEW |