Index: cc/resources/resource_provider.h |
diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h |
index e44b75e87649912d184477cce6b70879d9adc03a..13d711f85d8124c29b1d622c2d6ebef40697c433 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" |
@@ -313,29 +314,29 @@ class CC_EXPORT ResourceProvider { |
DISALLOW_COPY_AND_ASSIGN(Fence); |
}; |
- // Returns a canvas for gpu rasterization. |
- // Call Unmap before the resource can be read or used for compositing. |
+ // Returns a RasterBuffer for gpu rasterization. |
+ // Call Release before the resource can be read or used for compositing. |
// It is used for direct gpu rasterization. |
- SkCanvas* MapGpuRasterBuffer(ResourceId id); |
- void UnmapGpuRasterBuffer(ResourceId id); |
+ RasterBuffer* AcquireGpuRasterBuffer(ResourceId id); |
+ void ReleaseGpuRasterBuffer(ResourceId id); |
- // Returns a canvas backed by an image buffer. UnmapImageRasterBuffer |
- // returns true if canvas was written to while mapped. |
- // Rasterizing to the canvas writes the content into the image buffer, |
+ // Returns a RasterBuffer backed by an image buffer. ReleaseImageRasterBuffer |
+ // returns true if RasterBuffer was written to while acquired. |
+ // Rasterizing to the RasterBuffer writes the content into the image buffer, |
// which is internally bound to the underlying resource when read. |
- // Call Unmap before the resource can be read or used for compositing. |
+ // Call Release before the resource can be read or used for compositing. |
// It is used by ImageRasterWorkerPool. |
- SkCanvas* MapImageRasterBuffer(ResourceId id); |
- bool UnmapImageRasterBuffer(ResourceId id); |
+ RasterBuffer* AcquireImageRasterBuffer(ResourceId id); |
+ bool ReleaseImageRasterBuffer(ResourceId id); |
- // Returns a canvas backed by pixel buffer. UnmapPixelRasterBuffer |
- // returns true if canvas was written to while mapped. |
+ // Returns a RasterBuffer backed by pixel buffer. UnmapPixelRasterBuffer |
+ // returns true if RasterBuffer was written to while acquired. |
// The pixel buffer needs to be uploaded to the underlying resource |
// using BeginSetPixels before the resouce can be used for compositing. |
// 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); |
reveman
2014/08/12 14:31:26
Can we refactor this to be consistent with
{Acquir
auygun
2014/08/12 15:24:01
I don't think Map/UnmapPixelBuffer can be called f
reveman
2014/08/12 15:54:28
Right. That doesn't work at the moment but we like
auygun
2014/08/13 14:18:53
This involves some more change. PixelBufferRasterW
|
// 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(); |
reveman
2014/08/12 14:31:27
Do we need these functions or can we just handle t
auygun
2014/08/12 15:24:01
Can GpuRasterBuffer::CreateSurface() be called fro
reveman
2014/08/12 15:54:28
Good point. I'm not sure that will work so let's n
auygun
2014/08/13 14:18:53
We can move GpuRasterBuffer::CreateSurface() to Re
|
protected: |
- RasterBuffer(const Resource* resource, ResourceProvider* resource_provider); |
const Resource* resource() const { return resource_; } |
ResourceProvider* resource_provider() const { return resource_provider_; } |
reveman
2014/08/12 14:31:27
do we really need these functions?
auygun
2014/08/13 14:18:53
Acknowledged.
|
- virtual SkCanvas* DoLockForWrite() = 0; |
- virtual bool DoUnlockForWrite() = 0; |
+ skia::RefPtr<SkSurface> CreateSurface(); |
+ |
+ virtual SkCanvas* AcquireSkCanvas() OVERRIDE; |
+ virtual void ReleaseSkCanvas() OVERRIDE; |
private: |
const Resource* resource_; |
ResourceProvider* resource_provider_; |
SkCanvas* locked_canvas_; |
reveman
2014/08/12 14:31:26
If the canvas is passed to ReleaseSkCanvas? Can we
auygun
2014/08/13 14:18:54
Acknowledged.
|
int canvas_save_count_; |
reveman
2014/08/12 14:31:26
I'd like to remove this. If we create a new SkCanv
auygun
2014/08/13 14:18:53
Acknowledged.
|
- }; |
- |
- 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,20 +482,32 @@ class CC_EXPORT ResourceProvider { |
public: |
virtual ~BitmapRasterBuffer(); |
+ void LockForWrite(); |
+ // Returns true if canvas was written to while locked. |
+ bool UnlockForWrite(); |
reveman
2014/08/12 14:31:27
I prefer if we just handle this as part of
Acquire
auygun
2014/08/12 15:24:01
I think Lock/UnlockForWrite need to be called from
reveman
2014/08/12 15:54:28
I prefer if we remove the BitmapRasterBuffer class
auygun
2014/08/13 14:18:53
Acknowledged.
|
+ |
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* AcquireSkCanvas() OVERRIDE; |
+ virtual void ReleaseSkCanvas() 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_; |
+ bool raster_bitmap_changed_; |
+ int stride_; |
skia::RefPtr<SkCanvas> raster_canvas_; |
}; |