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

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

Issue 170783007: Re-land: cc: Cleanup internal::WorkerPoolTaskClient interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad DCHECK Created 6 years, 10 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
« no previous file with comments | « cc/resources/raster_worker_pool_unittest.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 void UnmapDirectRasterBuffer(ResourceId id); 324 void UnmapDirectRasterBuffer(ResourceId id);
325 325
326 // Returns a canvas backed by an image buffer. 326 // Returns a canvas backed by an image buffer.
327 // Rasterizing to the canvas writes the content into the image buffer, 327 // Rasterizing to the canvas writes the content into the image buffer,
328 // which is internally bound to the underlying resource when read. 328 // which is internally bound to the underlying resource when read.
329 // Call Unmap before the resource can be read or used for compositing. 329 // Call Unmap before the resource can be read or used for compositing.
330 // It is used by ImageRasterWorkerPool. 330 // It is used by ImageRasterWorkerPool.
331 SkCanvas* MapImageRasterBuffer(ResourceId id); 331 SkCanvas* MapImageRasterBuffer(ResourceId id);
332 void UnmapImageRasterBuffer(ResourceId id); 332 void UnmapImageRasterBuffer(ResourceId id);
333 333
334 // Returns a canvas backed by pixel buffer. 334 // Returns a canvas backed by pixel buffer. UnmapPixelRasterBuffer
335 // returns true if canvas was written to while mapped.
335 // The pixel buffer needs to be uploaded to the underlying resource 336 // The pixel buffer needs to be uploaded to the underlying resource
336 // using BeginSetPixels before the resouce can be used for compositing. 337 // using BeginSetPixels before the resouce can be used for compositing.
337 // It is used by PixelRasterWorkerPool. 338 // It is used by PixelRasterWorkerPool.
338 void AcquirePixelRasterBuffer(ResourceId id); 339 void AcquirePixelRasterBuffer(ResourceId id);
339 void ReleasePixelRasterBuffer(ResourceId id); 340 void ReleasePixelRasterBuffer(ResourceId id);
340 SkCanvas* MapPixelRasterBuffer(ResourceId id); 341 SkCanvas* MapPixelRasterBuffer(ResourceId id);
341 void UnmapPixelRasterBuffer(ResourceId id); 342 bool UnmapPixelRasterBuffer(ResourceId id);
342 343
343 // Asynchronously update pixels from acquired pixel buffer. 344 // Asynchronously update pixels from acquired pixel buffer.
344 void BeginSetPixels(ResourceId id); 345 void BeginSetPixels(ResourceId id);
345 void ForceSetPixelsToComplete(ResourceId id); 346 void ForceSetPixelsToComplete(ResourceId id);
346 bool DidSetPixelsComplete(ResourceId id); 347 bool DidSetPixelsComplete(ResourceId id);
347 348
348 // For tests only! This prevents detecting uninitialized reads. 349 // For tests only! This prevents detecting uninitialized reads.
349 // Use SetPixels or LockForWrite to allocate implicitly. 350 // Use SetPixels or LockForWrite to allocate implicitly.
350 void AllocateForTesting(ResourceId id); 351 void AllocateForTesting(ResourceId id);
351 352
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 linked_ptr<ImageRasterBuffer> image_raster_buffer; 444 linked_ptr<ImageRasterBuffer> image_raster_buffer;
444 linked_ptr<PixelRasterBuffer> pixel_raster_buffer; 445 linked_ptr<PixelRasterBuffer> pixel_raster_buffer;
445 }; 446 };
446 typedef base::hash_map<ResourceId, Resource> ResourceMap; 447 typedef base::hash_map<ResourceId, Resource> ResourceMap;
447 448
448 class RasterBuffer { 449 class RasterBuffer {
449 public: 450 public:
450 virtual ~RasterBuffer(); 451 virtual ~RasterBuffer();
451 452
452 SkCanvas* LockForWrite(); 453 SkCanvas* LockForWrite();
453 void UnlockForWrite(); 454 // Returns true if canvas was written to while locked.
455 bool UnlockForWrite();
454 456
455 protected: 457 protected:
456 RasterBuffer(const Resource* resource, ResourceProvider* resource_provider); 458 RasterBuffer(const Resource* resource, ResourceProvider* resource_provider);
457 const Resource* resource() const { return resource_; } 459 const Resource* resource() const { return resource_; }
458 ResourceProvider* resource_provider() const { return resource_provider_; } 460 ResourceProvider* resource_provider() const { return resource_provider_; }
459 461
460 virtual SkCanvas* DoLockForWrite() = 0; 462 virtual SkCanvas* DoLockForWrite() = 0;
461 virtual void DoUnlockForWrite() = 0; 463 virtual bool DoUnlockForWrite() = 0;
462 464
463 private: 465 private:
464 const Resource* resource_; 466 const Resource* resource_;
465 ResourceProvider* resource_provider_; 467 ResourceProvider* resource_provider_;
466 SkCanvas* locked_canvas_; 468 SkCanvas* locked_canvas_;
467 int canvas_save_count_; 469 int canvas_save_count_;
468 }; 470 };
469 471
470 class DirectRasterBuffer : public RasterBuffer { 472 class DirectRasterBuffer : public RasterBuffer {
471 public: 473 public:
472 DirectRasterBuffer(const Resource* resource, 474 DirectRasterBuffer(const Resource* resource,
473 ResourceProvider* resource_provider); 475 ResourceProvider* resource_provider);
474 virtual ~DirectRasterBuffer(); 476 virtual ~DirectRasterBuffer();
475 477
476 protected: 478 protected:
477 virtual SkCanvas* DoLockForWrite() OVERRIDE; 479 virtual SkCanvas* DoLockForWrite() OVERRIDE;
478 virtual void DoUnlockForWrite() OVERRIDE; 480 virtual bool DoUnlockForWrite() OVERRIDE;
479 skia::RefPtr<SkSurface> CreateSurface(); 481 skia::RefPtr<SkSurface> CreateSurface();
480 482
481 private: 483 private:
482 skia::RefPtr<SkSurface> surface_; 484 skia::RefPtr<SkSurface> surface_;
485 uint32_t surface_generation_id_;
486
483 DISALLOW_COPY_AND_ASSIGN(DirectRasterBuffer); 487 DISALLOW_COPY_AND_ASSIGN(DirectRasterBuffer);
484 }; 488 };
485 489
486 class BitmapRasterBuffer : public RasterBuffer { 490 class BitmapRasterBuffer : public RasterBuffer {
487 public: 491 public:
488 virtual ~BitmapRasterBuffer(); 492 virtual ~BitmapRasterBuffer();
489 493
490 protected: 494 protected:
491 BitmapRasterBuffer(const Resource* resource, 495 BitmapRasterBuffer(const Resource* resource,
492 ResourceProvider* resource_provider); 496 ResourceProvider* resource_provider);
493 497
494 virtual SkCanvas* DoLockForWrite() OVERRIDE; 498 virtual SkCanvas* DoLockForWrite() OVERRIDE;
495 virtual void DoUnlockForWrite() OVERRIDE; 499 virtual bool DoUnlockForWrite() OVERRIDE;
496 500
497 virtual uint8_t* MapBuffer(int* stride) = 0; 501 virtual uint8_t* MapBuffer(int* stride) = 0;
498 virtual void UnmapBuffer() = 0; 502 virtual void UnmapBuffer() = 0;
499 503
500 private: 504 private:
501 uint8_t* mapped_buffer_; 505 uint8_t* mapped_buffer_;
502 SkBitmap raster_bitmap_; 506 SkBitmap raster_bitmap_;
507 uint32_t raster_bitmap_generation_id_;
503 skia::RefPtr<SkCanvas> raster_canvas_; 508 skia::RefPtr<SkCanvas> raster_canvas_;
504 }; 509 };
505 510
506 class ImageRasterBuffer : public BitmapRasterBuffer { 511 class ImageRasterBuffer : public BitmapRasterBuffer {
507 public: 512 public:
508 ImageRasterBuffer(const Resource* resource, 513 ImageRasterBuffer(const Resource* resource,
509 ResourceProvider* resource_provider); 514 ResourceProvider* resource_provider);
510 virtual ~ImageRasterBuffer(); 515 virtual ~ImageRasterBuffer();
511 516
512 protected: 517 protected:
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 return format_gl_data_format[format]; 690 return format_gl_data_format[format];
686 } 691 }
687 692
688 inline GLenum GLInternalFormat(ResourceFormat format) { 693 inline GLenum GLInternalFormat(ResourceFormat format) {
689 return GLDataFormat(format); 694 return GLDataFormat(format);
690 } 695 }
691 696
692 } // namespace cc 697 } // namespace cc
693 698
694 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 699 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
OLDNEW
« no previous file with comments | « cc/resources/raster_worker_pool_unittest.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698