| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 200 |
| 201 gpu::gles2::GLES2Interface* gl_; | 201 gpu::gles2::GLES2Interface* gl_; |
| 202 unsigned query_id_; | 202 unsigned query_id_; |
| 203 | 203 |
| 204 DISALLOW_COPY_AND_ASSIGN(QueryFence); | 204 DISALLOW_COPY_AND_ASSIGN(QueryFence); |
| 205 }; | 205 }; |
| 206 | 206 |
| 207 } // namespace | 207 } // namespace |
| 208 | 208 |
| 209 ResourceProvider::Resource::Resource() | 209 ResourceProvider::Resource::Resource() |
| 210 : child_id(0), | 210 : dirty_image(false), |
| 211 gl_id(0), | |
| 212 gl_pixel_buffer_id(0), | |
| 213 gl_upload_query_id(0), | |
| 214 gl_read_lock_query_id(0), | |
| 215 pixels(NULL), | |
| 216 lock_for_read_count(0), | |
| 217 imported_count(0), | |
| 218 exported_count(0), | |
| 219 dirty_image(false), | |
| 220 locked_for_write(false), | 211 locked_for_write(false), |
| 221 lost(false), | 212 lost(false), |
| 222 marked_for_deletion(false), | 213 marked_for_deletion(false), |
| 223 pending_set_pixels(false), | 214 pending_set_pixels(false), |
| 224 set_pixels_completion_forced(false), | 215 set_pixels_completion_forced(false), |
| 225 allocated(false), | 216 allocated(false), |
| 226 read_lock_fences_enabled(false), | 217 read_lock_fences_enabled(false), |
| 227 has_shared_bitmap_id(false), | 218 has_shared_bitmap_id(false), |
| 228 allow_overlay(false), | 219 allow_overlay(false), |
| 229 read_lock_fence(NULL), | |
| 230 size(), | |
| 231 origin(Internal), | 220 origin(Internal), |
| 232 target(0), | |
| 233 original_filter(0), | |
| 234 filter(0), | |
| 235 image_id(0), | |
| 236 bound_image_id(0), | |
| 237 texture_pool(0), | |
| 238 wrap_mode(0), | |
| 239 hint(TextureHintImmutable), | 221 hint(TextureHintImmutable), |
| 240 type(InvalidType), | 222 type(InvalidType), |
| 241 format(RGBA_8888), | 223 format(RGBA_8888) { |
| 242 shared_bitmap(NULL) { | |
| 243 } | 224 } |
| 244 | 225 |
| 245 ResourceProvider::Resource::~Resource() {} | 226 ResourceProvider::Resource::~Resource() {} |
| 246 | 227 |
| 247 ResourceProvider::Resource::Resource(GLuint texture_id, | 228 ResourceProvider::Resource::Resource(GLuint texture_id, |
| 248 const gfx::Size& size, | 229 const gfx::Size& size, |
| 249 Origin origin, | 230 Origin origin, |
| 250 GLenum target, | 231 GLenum target, |
| 251 GLenum filter, | 232 GLenum filter, |
| 252 GLenum texture_pool, | 233 GLenum texture_pool, |
| 253 GLint wrap_mode, | 234 GLint wrap_mode, |
| 254 TextureHint hint, | 235 TextureHint hint, |
| 255 ResourceFormat format) | 236 ResourceFormat format) |
| 256 : child_id(0), | 237 : gl_id(texture_id), |
| 257 gl_id(texture_id), | |
| 258 gl_pixel_buffer_id(0), | |
| 259 gl_upload_query_id(0), | |
| 260 gl_read_lock_query_id(0), | |
| 261 pixels(NULL), | |
| 262 lock_for_read_count(0), | |
| 263 imported_count(0), | |
| 264 exported_count(0), | |
| 265 dirty_image(false), | 238 dirty_image(false), |
| 266 locked_for_write(false), | 239 locked_for_write(false), |
| 267 lost(false), | 240 lost(false), |
| 268 marked_for_deletion(false), | 241 marked_for_deletion(false), |
| 269 pending_set_pixels(false), | 242 pending_set_pixels(false), |
| 270 set_pixels_completion_forced(false), | 243 set_pixels_completion_forced(false), |
| 271 allocated(false), | 244 allocated(false), |
| 272 read_lock_fences_enabled(false), | 245 read_lock_fences_enabled(false), |
| 273 has_shared_bitmap_id(false), | 246 has_shared_bitmap_id(false), |
| 274 allow_overlay(false), | 247 allow_overlay(false), |
| 275 read_lock_fence(NULL), | |
| 276 size(size), | 248 size(size), |
| 277 origin(origin), | 249 origin(origin), |
| 278 target(target), | 250 target(target), |
| 279 original_filter(filter), | 251 original_filter(filter), |
| 280 filter(filter), | 252 filter(filter), |
| 281 image_id(0), | |
| 282 bound_image_id(0), | |
| 283 texture_pool(texture_pool), | 253 texture_pool(texture_pool), |
| 284 wrap_mode(wrap_mode), | 254 wrap_mode(wrap_mode), |
| 285 hint(hint), | 255 hint(hint), |
| 286 type(GLTexture), | 256 type(GLTexture), |
| 287 format(format), | 257 format(format) { |
| 288 shared_bitmap(NULL) { | |
| 289 DCHECK(wrap_mode == GL_CLAMP_TO_EDGE || wrap_mode == GL_REPEAT); | 258 DCHECK(wrap_mode == GL_CLAMP_TO_EDGE || wrap_mode == GL_REPEAT); |
| 290 DCHECK_EQ(origin == Internal, !!texture_pool); | 259 DCHECK_EQ(origin == Internal, !!texture_pool); |
| 291 } | 260 } |
| 292 | 261 |
| 293 ResourceProvider::Resource::Resource(uint8_t* pixels, | 262 ResourceProvider::Resource::Resource(uint8_t* pixels, |
| 294 SharedBitmap* bitmap, | 263 SharedBitmap* bitmap, |
| 295 const gfx::Size& size, | 264 const gfx::Size& size, |
| 296 Origin origin, | 265 Origin origin, |
| 297 GLenum filter, | 266 GLenum filter, |
| 298 GLint wrap_mode) | 267 GLint wrap_mode) |
| 299 : child_id(0), | 268 : pixels(pixels), |
| 300 gl_id(0), | |
| 301 gl_pixel_buffer_id(0), | |
| 302 gl_upload_query_id(0), | |
| 303 gl_read_lock_query_id(0), | |
| 304 pixels(pixels), | |
| 305 lock_for_read_count(0), | |
| 306 imported_count(0), | |
| 307 exported_count(0), | |
| 308 dirty_image(false), | 269 dirty_image(false), |
| 309 locked_for_write(false), | 270 locked_for_write(false), |
| 310 lost(false), | 271 lost(false), |
| 311 marked_for_deletion(false), | 272 marked_for_deletion(false), |
| 312 pending_set_pixels(false), | 273 pending_set_pixels(false), |
| 313 set_pixels_completion_forced(false), | 274 set_pixels_completion_forced(false), |
| 314 allocated(false), | 275 allocated(false), |
| 315 read_lock_fences_enabled(false), | 276 read_lock_fences_enabled(false), |
| 316 has_shared_bitmap_id(!!bitmap), | 277 has_shared_bitmap_id(!!bitmap), |
| 317 allow_overlay(false), | 278 allow_overlay(false), |
| 318 read_lock_fence(NULL), | |
| 319 size(size), | 279 size(size), |
| 320 origin(origin), | 280 origin(origin), |
| 321 target(0), | |
| 322 original_filter(filter), | 281 original_filter(filter), |
| 323 filter(filter), | 282 filter(filter), |
| 324 image_id(0), | |
| 325 bound_image_id(0), | |
| 326 texture_pool(0), | |
| 327 wrap_mode(wrap_mode), | 283 wrap_mode(wrap_mode), |
| 328 hint(TextureHintImmutable), | 284 hint(TextureHintImmutable), |
| 329 type(Bitmap), | 285 type(Bitmap), |
| 330 format(RGBA_8888), | 286 format(RGBA_8888), |
| 331 shared_bitmap(bitmap) { | 287 shared_bitmap(bitmap) { |
| 332 DCHECK(wrap_mode == GL_CLAMP_TO_EDGE || wrap_mode == GL_REPEAT); | 288 DCHECK(wrap_mode == GL_CLAMP_TO_EDGE || wrap_mode == GL_REPEAT); |
| 333 DCHECK(origin == Delegated || pixels); | 289 DCHECK(origin == Delegated || pixels); |
| 334 if (bitmap) | 290 if (bitmap) |
| 335 shared_bitmap_id = bitmap->id(); | 291 shared_bitmap_id = bitmap->id(); |
| 336 } | 292 } |
| 337 | 293 |
| 338 ResourceProvider::Resource::Resource(const SharedBitmapId& bitmap_id, | 294 ResourceProvider::Resource::Resource(const SharedBitmapId& bitmap_id, |
| 339 const gfx::Size& size, | 295 const gfx::Size& size, |
| 340 Origin origin, | 296 Origin origin, |
| 341 GLenum filter, | 297 GLenum filter, |
| 342 GLint wrap_mode) | 298 GLint wrap_mode) |
| 343 : child_id(0), | 299 : dirty_image(false), |
| 344 gl_id(0), | |
| 345 gl_pixel_buffer_id(0), | |
| 346 gl_upload_query_id(0), | |
| 347 gl_read_lock_query_id(0), | |
| 348 pixels(NULL), | |
| 349 lock_for_read_count(0), | |
| 350 imported_count(0), | |
| 351 exported_count(0), | |
| 352 dirty_image(false), | |
| 353 locked_for_write(false), | 300 locked_for_write(false), |
| 354 lost(false), | 301 lost(false), |
| 355 marked_for_deletion(false), | 302 marked_for_deletion(false), |
| 356 pending_set_pixels(false), | 303 pending_set_pixels(false), |
| 357 set_pixels_completion_forced(false), | 304 set_pixels_completion_forced(false), |
| 358 allocated(false), | 305 allocated(false), |
| 359 read_lock_fences_enabled(false), | 306 read_lock_fences_enabled(false), |
| 360 has_shared_bitmap_id(true), | 307 has_shared_bitmap_id(true), |
| 361 allow_overlay(false), | 308 allow_overlay(false), |
| 362 read_lock_fence(NULL), | |
| 363 size(size), | 309 size(size), |
| 364 origin(origin), | 310 origin(origin), |
| 365 target(0), | |
| 366 original_filter(filter), | 311 original_filter(filter), |
| 367 filter(filter), | 312 filter(filter), |
| 368 image_id(0), | |
| 369 bound_image_id(0), | |
| 370 texture_pool(0), | |
| 371 wrap_mode(wrap_mode), | 313 wrap_mode(wrap_mode), |
| 372 hint(TextureHintImmutable), | 314 hint(TextureHintImmutable), |
| 373 type(Bitmap), | 315 type(Bitmap), |
| 374 format(RGBA_8888), | 316 format(RGBA_8888), |
| 375 shared_bitmap_id(bitmap_id), | 317 shared_bitmap_id(bitmap_id) { |
| 376 shared_bitmap(NULL) { | |
| 377 DCHECK(wrap_mode == GL_CLAMP_TO_EDGE || wrap_mode == GL_REPEAT); | 318 DCHECK(wrap_mode == GL_CLAMP_TO_EDGE || wrap_mode == GL_REPEAT); |
| 378 } | 319 } |
| 379 | 320 |
| 380 ResourceProvider::Child::Child() : marked_for_deletion(false) {} | 321 ResourceProvider::Child::Child() : marked_for_deletion(false) {} |
| 381 | 322 |
| 382 ResourceProvider::Child::~Child() {} | 323 ResourceProvider::Child::~Child() {} |
| 383 | 324 |
| 384 scoped_ptr<ResourceProvider> ResourceProvider::Create( | 325 scoped_ptr<ResourceProvider> ResourceProvider::Create( |
| 385 OutputSurface* output_surface, | 326 OutputSurface* output_surface, |
| 386 SharedBitmapManager* shared_bitmap_manager, | 327 SharedBitmapManager* shared_bitmap_manager, |
| (...skipping 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2073 ContextProvider* context_provider = output_surface_->context_provider(); | 2014 ContextProvider* context_provider = output_surface_->context_provider(); |
| 2074 return context_provider ? context_provider->ContextGL() : NULL; | 2015 return context_provider ? context_provider->ContextGL() : NULL; |
| 2075 } | 2016 } |
| 2076 | 2017 |
| 2077 class GrContext* ResourceProvider::GrContext() const { | 2018 class GrContext* ResourceProvider::GrContext() const { |
| 2078 ContextProvider* context_provider = output_surface_->context_provider(); | 2019 ContextProvider* context_provider = output_surface_->context_provider(); |
| 2079 return context_provider ? context_provider->GrContext() : NULL; | 2020 return context_provider ? context_provider->GrContext() : NULL; |
| 2080 } | 2021 } |
| 2081 | 2022 |
| 2082 } // namespace cc | 2023 } // namespace cc |
| OLD | NEW |