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

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: address more of the feedback 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 bool UnlockForWrite();
alokp 2014/02/19 19:12:12 Add a comment what the bool means.
reveman 2014/02/19 22:53:09 Done.
454 455
455 protected: 456 protected:
456 RasterBuffer(const Resource* resource, ResourceProvider* resource_provider); 457 RasterBuffer(const Resource* resource, ResourceProvider* resource_provider);
457 const Resource* resource() const { return resource_; } 458 const Resource* resource() const { return resource_; }
458 ResourceProvider* resource_provider() const { return resource_provider_; } 459 ResourceProvider* resource_provider() const { return resource_provider_; }
459 460
460 virtual SkCanvas* DoLockForWrite() = 0; 461 virtual SkCanvas* DoLockForWrite() = 0;
461 virtual void DoUnlockForWrite() = 0; 462 virtual bool DoUnlockForWrite() = 0;
462 463
463 private: 464 private:
464 const Resource* resource_; 465 const Resource* resource_;
465 ResourceProvider* resource_provider_; 466 ResourceProvider* resource_provider_;
466 SkCanvas* locked_canvas_; 467 SkCanvas* locked_canvas_;
467 int canvas_save_count_; 468 int canvas_save_count_;
468 }; 469 };
469 470
470 class DirectRasterBuffer : public RasterBuffer { 471 class DirectRasterBuffer : public RasterBuffer {
471 public: 472 public:
472 DirectRasterBuffer(const Resource* resource, 473 DirectRasterBuffer(const Resource* resource,
473 ResourceProvider* resource_provider); 474 ResourceProvider* resource_provider);
474 virtual ~DirectRasterBuffer(); 475 virtual ~DirectRasterBuffer();
475 476
476 protected: 477 protected:
477 virtual SkCanvas* DoLockForWrite() OVERRIDE; 478 virtual SkCanvas* DoLockForWrite() OVERRIDE;
478 virtual void DoUnlockForWrite() OVERRIDE; 479 virtual bool DoUnlockForWrite() OVERRIDE;
479 skia::RefPtr<SkSurface> CreateSurface(); 480 skia::RefPtr<SkSurface> CreateSurface();
480 481
481 private: 482 private:
482 skia::RefPtr<SkSurface> surface_; 483 skia::RefPtr<SkSurface> surface_;
484 uint32_t surface_generation_id_;
485
483 DISALLOW_COPY_AND_ASSIGN(DirectRasterBuffer); 486 DISALLOW_COPY_AND_ASSIGN(DirectRasterBuffer);
484 }; 487 };
485 488
486 class BitmapRasterBuffer : public RasterBuffer { 489 class BitmapRasterBuffer : public RasterBuffer {
487 public: 490 public:
488 virtual ~BitmapRasterBuffer(); 491 virtual ~BitmapRasterBuffer();
489 492
490 protected: 493 protected:
491 BitmapRasterBuffer(const Resource* resource, 494 BitmapRasterBuffer(const Resource* resource,
492 ResourceProvider* resource_provider); 495 ResourceProvider* resource_provider);
493 496
494 virtual SkCanvas* DoLockForWrite() OVERRIDE; 497 virtual SkCanvas* DoLockForWrite() OVERRIDE;
495 virtual void DoUnlockForWrite() OVERRIDE; 498 virtual bool DoUnlockForWrite() OVERRIDE;
496 499
497 virtual uint8_t* MapBuffer(int* stride) = 0; 500 virtual uint8_t* MapBuffer(int* stride) = 0;
498 virtual void UnmapBuffer() = 0; 501 virtual void UnmapBuffer() = 0;
499 502
500 private: 503 private:
501 uint8_t* mapped_buffer_; 504 uint8_t* mapped_buffer_;
502 SkBitmap raster_bitmap_; 505 SkBitmap raster_bitmap_;
506 uint32_t raster_bitmap_generation_id_;
503 skia::RefPtr<SkCanvas> raster_canvas_; 507 skia::RefPtr<SkCanvas> raster_canvas_;
504 }; 508 };
505 509
506 class ImageRasterBuffer : public BitmapRasterBuffer { 510 class ImageRasterBuffer : public BitmapRasterBuffer {
507 public: 511 public:
508 ImageRasterBuffer(const Resource* resource, 512 ImageRasterBuffer(const Resource* resource,
509 ResourceProvider* resource_provider); 513 ResourceProvider* resource_provider);
510 virtual ~ImageRasterBuffer(); 514 virtual ~ImageRasterBuffer();
511 515
512 protected: 516 protected:
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 return format_gl_data_format[format]; 689 return format_gl_data_format[format];
686 } 690 }
687 691
688 inline GLenum GLInternalFormat(ResourceFormat format) { 692 inline GLenum GLInternalFormat(ResourceFormat format) {
689 return GLDataFormat(format); 693 return GLDataFormat(format);
690 } 694 }
691 695
692 } // namespace cc 696 } // namespace cc
693 697
694 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 698 #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