Chromium Code Reviews| Index: cc/resources/resource_provider.h |
| diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h |
| index e44b75e87649912d184477cce6b70879d9adc03a..dcdabcf15f9e6ae882286754595ba50a55dcbb38 100644 |
| --- a/cc/resources/resource_provider.h |
| +++ b/cc/resources/resource_provider.h |
| @@ -20,6 +20,7 @@ |
| #include "cc/base/cc_export.h" |
| #include "cc/output/context_provider.h" |
| #include "cc/output/output_surface.h" |
| +#include "cc/resources/raster_buffer.h" |
| #include "cc/resources/release_callback.h" |
| #include "cc/resources/resource_format.h" |
| #include "cc/resources/return_callback.h" |
| @@ -316,7 +317,7 @@ class CC_EXPORT ResourceProvider { |
| // Returns a canvas for gpu rasterization. |
| // Call Unmap before the resource can be read or used for compositing. |
| // It is used for direct gpu rasterization. |
| - SkCanvas* MapGpuRasterBuffer(ResourceId id); |
| + RasterBuffer* MapGpuRasterBuffer(ResourceId id); |
| void UnmapGpuRasterBuffer(ResourceId id); |
|
reveman
2014/08/11 20:32:36
Map/Unmap doesn't make much sense in the GPU raste
auygun
2014/08/12 13:36:35
Done.
|
| // Returns a canvas backed by an image buffer. UnmapImageRasterBuffer |
| @@ -325,7 +326,7 @@ class CC_EXPORT ResourceProvider { |
| // which is internally bound to the underlying resource when read. |
| // Call Unmap before the resource can be read or used for compositing. |
| // It is used by ImageRasterWorkerPool. |
| - SkCanvas* MapImageRasterBuffer(ResourceId id); |
| + RasterBuffer* MapImageRasterBuffer(ResourceId id); |
| bool UnmapImageRasterBuffer(ResourceId id); |
| // Returns a canvas backed by pixel buffer. UnmapPixelRasterBuffer |
| @@ -335,7 +336,7 @@ class CC_EXPORT ResourceProvider { |
| // It is used by PixelRasterWorkerPool. |
| void AcquirePixelRasterBuffer(ResourceId id); |
| void ReleasePixelRasterBuffer(ResourceId id); |
| - SkCanvas* MapPixelRasterBuffer(ResourceId id); |
| + RasterBuffer* MapPixelRasterBuffer(ResourceId id); |
| bool UnmapPixelRasterBuffer(ResourceId id); |
| // Asynchronously update pixels from acquired pixel buffer. |
| @@ -445,42 +446,31 @@ class CC_EXPORT ResourceProvider { |
| }; |
| typedef base::hash_map<ResourceId, Resource> ResourceMap; |
| - class RasterBuffer { |
| + class GpuRasterBuffer : public RasterBuffer { |
| public: |
| - virtual ~RasterBuffer(); |
| + GpuRasterBuffer(const Resource* resource, |
| + ResourceProvider* resource_provider, |
| + bool use_distance_field_text); |
| + virtual ~GpuRasterBuffer(); |
| - SkCanvas* LockForWrite(); |
| + void LockForWrite(); |
| // Returns true if canvas was written to while locked. |
| bool UnlockForWrite(); |
| protected: |
| - RasterBuffer(const Resource* resource, ResourceProvider* resource_provider); |
| const Resource* resource() const { return resource_; } |
| ResourceProvider* resource_provider() const { return resource_provider_; } |
| - virtual SkCanvas* DoLockForWrite() = 0; |
| - virtual bool DoUnlockForWrite() = 0; |
| + skia::RefPtr<SkSurface> CreateSurface(); |
| + |
| + virtual SkCanvas* GetSkCanvas() OVERRIDE; |
| + virtual void Flush() OVERRIDE {} |
| private: |
| const Resource* resource_; |
| ResourceProvider* resource_provider_; |
| SkCanvas* locked_canvas_; |
| int canvas_save_count_; |
| - }; |
| - |
| - class GpuRasterBuffer : public RasterBuffer { |
| - public: |
| - GpuRasterBuffer(const Resource* resource, |
| - ResourceProvider* resource_provider, |
| - bool use_distance_field_text); |
| - virtual ~GpuRasterBuffer(); |
| - |
| - protected: |
| - virtual SkCanvas* DoLockForWrite() OVERRIDE; |
| - virtual bool DoUnlockForWrite() OVERRIDE; |
| - skia::RefPtr<SkSurface> CreateSurface(); |
| - |
| - private: |
| skia::RefPtr<SkSurface> surface_; |
| uint32_t surface_generation_id_; |
| const bool use_distance_field_text_; |
| @@ -492,17 +482,27 @@ class CC_EXPORT ResourceProvider { |
| public: |
| virtual ~BitmapRasterBuffer(); |
| + void LockForWrite(); |
| + // Returns true if canvas was written to while locked. |
| + bool UnlockForWrite(); |
| + |
| protected: |
| BitmapRasterBuffer(const Resource* resource, |
| ResourceProvider* resource_provider); |
| - virtual SkCanvas* DoLockForWrite() OVERRIDE; |
| - virtual bool DoUnlockForWrite() OVERRIDE; |
| + const Resource* resource() const { return resource_; } |
| + ResourceProvider* resource_provider() const { return resource_provider_; } |
| + |
| + virtual SkCanvas* GetSkCanvas() OVERRIDE; |
| + virtual void Flush() OVERRIDE; |
| virtual uint8_t* MapBuffer(int* stride) = 0; |
| virtual void UnmapBuffer() = 0; |
| private: |
| + const Resource* resource_; |
| + ResourceProvider* resource_provider_; |
| + int canvas_save_count_; |
| uint8_t* mapped_buffer_; |
| SkBitmap raster_bitmap_; |
| uint32_t raster_bitmap_generation_id_; |