Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: cc/resources/resource_provider.cc

Issue 255713008: Change glimage to accept a type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2139 matching lines...) Expand 10 before | Expand all | Expand 10 after
2150 2150
2151 if (resource->image_id) 2151 if (resource->image_id)
2152 return; 2152 return;
2153 2153
2154 resource->allocated = true; 2154 resource->allocated = true;
2155 GLES2Interface* gl = ContextGL(); 2155 GLES2Interface* gl = ContextGL();
2156 DCHECK(gl); 2156 DCHECK(gl);
2157 resource->image_id = 2157 resource->image_id =
2158 gl->CreateImageCHROMIUM(resource->size.width(), 2158 gl->CreateImageCHROMIUM(resource->size.width(),
2159 resource->size.height(), 2159 resource->size.height(),
2160 TextureToStorageFormat(resource->format)); 2160 TextureToStorageFormat(resource->format),
2161 GL_IMAGE_MAP_CHROMIUM);
2161 DCHECK(resource->image_id); 2162 DCHECK(resource->image_id);
2162 } 2163 }
2163 2164
2164 void ResourceProvider::ReleaseImage(Resource* resource) { 2165 void ResourceProvider::ReleaseImage(Resource* resource) {
2165 DCHECK(resource->origin == Resource::Internal); 2166 DCHECK(resource->origin == Resource::Internal);
2166 DCHECK_EQ(resource->exported_count, 0); 2167 DCHECK_EQ(resource->exported_count, 0);
2167 2168
2168 if (!resource->image_id) 2169 if (!resource->image_id)
2169 return; 2170 return;
2170 2171
2171 GLES2Interface* gl = ContextGL(); 2172 GLES2Interface* gl = ContextGL();
2172 DCHECK(gl); 2173 DCHECK(gl);
2173 gl->DestroyImageCHROMIUM(resource->image_id); 2174 gl->DestroyImageCHROMIUM(resource->image_id);
2174 resource->image_id = 0; 2175 resource->image_id = 0;
2175 resource->bound_image_id = 0; 2176 resource->bound_image_id = 0;
2176 resource->dirty_image = false; 2177 resource->dirty_image = false;
2177 resource->allocated = false; 2178 resource->allocated = false;
2178 } 2179 }
2179 2180
2180 uint8_t* ResourceProvider::MapImage(const Resource* resource, int* stride) { 2181 uint8_t* ResourceProvider::MapImage(const Resource* resource, int* stride) {
2181 DCHECK(ReadLockFenceHasPassed(resource)); 2182 DCHECK(ReadLockFenceHasPassed(resource));
2182 DCHECK(resource->origin == Resource::Internal); 2183 DCHECK(resource->origin == Resource::Internal);
2183 DCHECK_EQ(resource->exported_count, 0); 2184 DCHECK_EQ(resource->exported_count, 0);
2184 2185
2185 if (resource->type == GLTexture) { 2186 if (resource->type == GLTexture) {
2186 DCHECK(resource->image_id); 2187 DCHECK(resource->image_id);
2187 GLES2Interface* gl = ContextGL(); 2188 GLES2Interface* gl = ContextGL();
2188 DCHECK(gl); 2189 DCHECK(gl);
2189 // MapImageCHROMIUM should be called prior to GetImageParameterivCHROMIUM. 2190 // MapImageCHROMIUM should be called prior to GetImageParameterivCHROMIUM.
2190 uint8_t* pixels = static_cast<uint8_t*>( 2191 uint8_t* pixels =
2191 gl->MapImageCHROMIUM(resource->image_id, GL_READ_WRITE)); 2192 static_cast<uint8_t*>(gl->MapImageCHROMIUM(resource->image_id));
2192 gl->GetImageParameterivCHROMIUM( 2193 gl->GetImageParameterivCHROMIUM(
2193 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, stride); 2194 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, stride);
2194 return pixels; 2195 return pixels;
2195 } 2196 }
2196 DCHECK_EQ(Bitmap, resource->type); 2197 DCHECK_EQ(Bitmap, resource->type);
2197 *stride = 0; 2198 *stride = 0;
2198 return resource->pixels; 2199 return resource->pixels;
2199 } 2200 }
2200 2201
2201 void ResourceProvider::UnmapImage(const Resource* resource) { 2202 void ResourceProvider::UnmapImage(const Resource* resource) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 ContextProvider* context_provider = output_surface_->context_provider(); 2276 ContextProvider* context_provider = output_surface_->context_provider();
2276 return context_provider ? context_provider->ContextGL() : NULL; 2277 return context_provider ? context_provider->ContextGL() : NULL;
2277 } 2278 }
2278 2279
2279 class GrContext* ResourceProvider::GrContext() const { 2280 class GrContext* ResourceProvider::GrContext() const {
2280 ContextProvider* context_provider = output_surface_->context_provider(); 2281 ContextProvider* context_provider = output_surface_->context_provider();
2281 return context_provider ? context_provider->GrContext() : NULL; 2282 return context_provider ? context_provider->GrContext() : NULL;
2282 } 2283 }
2283 2284
2284 } // namespace cc 2285 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698