| OLD | NEW |
| (Empty) |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_ | |
| 6 #define CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_ | |
| 7 | |
| 8 #include "cc/base/cc_export.h" | |
| 9 #include "cc/resources/content_layer_updater.h" | |
| 10 #include "skia/ext/refptr.h" | |
| 11 #include "third_party/skia/include/core/SkBitmap.h" | |
| 12 | |
| 13 class SkCanvas; | |
| 14 | |
| 15 namespace cc { | |
| 16 | |
| 17 class LayerPainter; | |
| 18 class RenderingStatsInstrumenation; | |
| 19 | |
| 20 // This class rasterizes the content_rect into a skia bitmap canvas. It then | |
| 21 // creates a ResourceUpdate with this bitmap canvas and inserts the | |
| 22 // ResourceBundle to the provided ResourceUpdateQueue. Actual texture uploading | |
| 23 // is done by ResourceUpdateController. | |
| 24 class CC_EXPORT BitmapContentLayerUpdater : public ContentLayerUpdater { | |
| 25 public: | |
| 26 class Resource : public LayerUpdater::Resource { | |
| 27 public: | |
| 28 Resource(BitmapContentLayerUpdater* updater, | |
| 29 scoped_ptr<PrioritizedResource> resource); | |
| 30 ~Resource() override; | |
| 31 | |
| 32 void Update(ResourceUpdateQueue* queue, | |
| 33 const gfx::Rect& source_rect, | |
| 34 const gfx::Vector2d& dest_offset, | |
| 35 bool partial_update) override; | |
| 36 | |
| 37 private: | |
| 38 BitmapContentLayerUpdater* updater_; | |
| 39 | |
| 40 DISALLOW_COPY_AND_ASSIGN(Resource); | |
| 41 }; | |
| 42 | |
| 43 static scoped_refptr<BitmapContentLayerUpdater> Create( | |
| 44 scoped_ptr<LayerPainter> painter, | |
| 45 int layer_id); | |
| 46 | |
| 47 scoped_ptr<LayerUpdater::Resource> CreateResource( | |
| 48 PrioritizedResourceManager* manager) override; | |
| 49 void PrepareToUpdate(const gfx::Size& content_size, | |
| 50 const gfx::Rect& paint_rect, | |
| 51 const gfx::Size& tile_size, | |
| 52 float contents_width_scale, | |
| 53 float contents_height_scale) override; | |
| 54 void UpdateTexture(ResourceUpdateQueue* queue, | |
| 55 PrioritizedResource* resource, | |
| 56 const gfx::Rect& source_rect, | |
| 57 const gfx::Vector2d& dest_offset, | |
| 58 bool partial_update); | |
| 59 void SetOpaque(bool opaque) override; | |
| 60 void ReduceMemoryUsage() override; | |
| 61 | |
| 62 protected: | |
| 63 BitmapContentLayerUpdater( | |
| 64 scoped_ptr<LayerPainter> painter, | |
| 65 int layer_id); | |
| 66 ~BitmapContentLayerUpdater() override; | |
| 67 | |
| 68 SkBitmap bitmap_backing_; | |
| 69 skia::RefPtr<SkCanvas> canvas_; | |
| 70 gfx::Size canvas_size_; | |
| 71 | |
| 72 private: | |
| 73 DISALLOW_COPY_AND_ASSIGN(BitmapContentLayerUpdater); | |
| 74 }; | |
| 75 | |
| 76 } // namespace cc | |
| 77 | |
| 78 #endif // CC_RESOURCES_BITMAP_CONTENT_LAYER_UPDATER_H_ | |
| OLD | NEW |