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 #ifndef CC_RESOURCES_RESOURCE_PROVIDER_H_ | 5 #ifndef CC_RESOURCES_RESOURCE_PROVIDER_H_ |
6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_ | 6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 bool CanLockForWrite(ResourceId id); | 307 bool CanLockForWrite(ResourceId id); |
308 | 308 |
309 cc::ContextProvider* offscreen_context_provider() { | 309 cc::ContextProvider* offscreen_context_provider() { |
310 return offscreen_context_provider_.get(); | 310 return offscreen_context_provider_.get(); |
311 } | 311 } |
312 void set_offscreen_context_provider( | 312 void set_offscreen_context_provider( |
313 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { | 313 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { |
314 offscreen_context_provider_ = offscreen_context_provider; | 314 offscreen_context_provider_ = offscreen_context_provider; |
315 } | 315 } |
316 | 316 |
| 317 // Sets if zero-copy GPU memory buffers should be used. |
| 318 void SetUseGpuMemoryBuffers(bool use_gpu_memory_buffers); |
| 319 |
317 private: | 320 private: |
318 struct Resource { | 321 struct Resource { |
319 Resource(); | 322 Resource(); |
320 ~Resource(); | 323 ~Resource(); |
321 Resource(unsigned texture_id, gfx::Size size, GLenum format, GLenum filter); | 324 Resource(unsigned texture_id, gfx::Size size, GLenum format, GLenum filter, |
| 325 bool use_gpu_memory_buffer); |
322 Resource(uint8_t* pixels, gfx::Size size, GLenum format, GLenum filter); | 326 Resource(uint8_t* pixels, gfx::Size size, GLenum format, GLenum filter); |
323 | 327 |
324 unsigned gl_id; | 328 unsigned gl_id; |
325 // Pixel buffer used for set pixels without unnecessary copying. | 329 // Pixel buffer used for set pixels without unnecessary copying. |
326 unsigned gl_pixel_buffer_id; | 330 unsigned gl_pixel_buffer_id; |
327 // Query used to determine when asynchronous set pixels complete. | 331 // Query used to determine when asynchronous set pixels complete. |
328 unsigned gl_upload_query_id; | 332 unsigned gl_upload_query_id; |
329 TextureMailbox mailbox; | 333 TextureMailbox mailbox; |
330 uint8_t* pixels; | 334 uint8_t* pixels; |
331 uint8_t* pixel_buffer; | 335 uint8_t* pixel_buffer; |
332 int lock_for_read_count; | 336 int lock_for_read_count; |
333 bool locked_for_write; | 337 bool locked_for_write; |
334 bool external; | 338 bool external; |
335 bool exported; | 339 bool exported; |
336 bool marked_for_deletion; | 340 bool marked_for_deletion; |
337 bool pending_set_pixels; | 341 bool pending_set_pixels; |
338 bool set_pixels_completion_forced; | 342 bool set_pixels_completion_forced; |
339 bool allocated; | 343 bool allocated; |
340 bool enable_read_lock_fences; | 344 bool enable_read_lock_fences; |
341 scoped_refptr<Fence> read_lock_fence; | 345 scoped_refptr<Fence> read_lock_fence; |
342 gfx::Size size; | 346 gfx::Size size; |
343 GLenum format; | 347 GLenum format; |
344 // TODO(skyostil): Use a separate sampler object for filter state. | 348 // TODO(skyostil): Use a separate sampler object for filter state. |
345 GLenum filter; | 349 GLenum filter; |
346 ResourceType type; | 350 ResourceType type; |
| 351 bool use_gpu_memory_buffer; |
347 }; | 352 }; |
348 typedef base::hash_map<ResourceId, Resource> ResourceMap; | 353 typedef base::hash_map<ResourceId, Resource> ResourceMap; |
349 struct Child { | 354 struct Child { |
350 Child(); | 355 Child(); |
351 ~Child(); | 356 ~Child(); |
352 | 357 |
353 ResourceIdMap child_to_parent_map; | 358 ResourceIdMap child_to_parent_map; |
354 ResourceIdMap parent_to_child_map; | 359 ResourceIdMap parent_to_child_map; |
355 }; | 360 }; |
356 typedef base::hash_map<int, Child> ChildMap; | 361 typedef base::hash_map<int, Child> ChildMap; |
(...skipping 15 matching lines...) Expand all Loading... |
372 | 377 |
373 bool TransferResource(WebKit::WebGraphicsContext3D* context, | 378 bool TransferResource(WebKit::WebGraphicsContext3D* context, |
374 ResourceId id, | 379 ResourceId id, |
375 TransferableResource* resource); | 380 TransferableResource* resource); |
376 enum DeleteStyle { | 381 enum DeleteStyle { |
377 Normal, | 382 Normal, |
378 ForShutdown, | 383 ForShutdown, |
379 }; | 384 }; |
380 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); | 385 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); |
381 void LazyAllocate(Resource* resource); | 386 void LazyAllocate(Resource* resource); |
| 387 GLenum GetTargetGivenResource(Resource* resource); |
382 | 388 |
383 OutputSurface* output_surface_; | 389 OutputSurface* output_surface_; |
384 bool lost_output_surface_; | 390 bool lost_output_surface_; |
385 ResourceId next_id_; | 391 ResourceId next_id_; |
386 ResourceMap resources_; | 392 ResourceMap resources_; |
387 int next_child_; | 393 int next_child_; |
388 ChildMap children_; | 394 ChildMap children_; |
389 | 395 |
390 ResourceType default_resource_type_; | 396 ResourceType default_resource_type_; |
391 bool use_texture_storage_ext_; | 397 bool use_texture_storage_ext_; |
392 bool use_texture_usage_hint_; | 398 bool use_texture_usage_hint_; |
393 bool use_shallow_flush_; | 399 bool use_shallow_flush_; |
394 scoped_ptr<TextureUploader> texture_uploader_; | 400 scoped_ptr<TextureUploader> texture_uploader_; |
395 scoped_ptr<AcceleratedTextureCopier> texture_copier_; | 401 scoped_ptr<AcceleratedTextureCopier> texture_copier_; |
396 int max_texture_size_; | 402 int max_texture_size_; |
397 GLenum best_texture_format_; | 403 GLenum best_texture_format_; |
398 | 404 |
399 scoped_refptr<cc::ContextProvider> offscreen_context_provider_; | 405 scoped_refptr<cc::ContextProvider> offscreen_context_provider_; |
400 | 406 |
401 base::ThreadChecker thread_checker_; | 407 base::ThreadChecker thread_checker_; |
402 | 408 |
403 scoped_refptr<Fence> current_read_lock_fence_; | 409 scoped_refptr<Fence> current_read_lock_fence_; |
404 | 410 |
| 411 bool use_gpu_memory_buffers_; |
| 412 |
405 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 413 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
406 }; | 414 }; |
407 | 415 |
408 } // namespace cc | 416 } // namespace cc |
409 | 417 |
410 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 418 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |