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_LAYER_UPDATER_H_ 6#define CC_RESOURCES_LAYER_UPDATER_H_ 7 8#include "base/memory/ref_counted.h" 9#include "base/memory/scoped_ptr.h" 10#include "cc/base/cc_export.h" 11#include "third_party/skia/include/core/SkColor.h" 12#include "ui/gfx/rect.h" 13#include "ui/gfx/vector2d.h" 14 15namespace cc { 16 17class PrioritizedResource; 18class PrioritizedResourceManager; 19class ResourceUpdateQueue; 20class TextureManager; 21 22class CC_EXPORT LayerUpdater : public base::RefCounted<LayerUpdater> { 23 public: 24 // Allows updaters to store per-resource update properties. 25 class CC_EXPORT Resource { 26 public: 27 virtual ~Resource(); 28 29 PrioritizedResource* texture() { return texture_.get(); } 30 // TODO(reveman): partial_update should be a property of this class 31 // instead of an argument passed to Update(). 32 virtual void Update(ResourceUpdateQueue* queue, 33 const gfx::Rect& source_rect, 34 const gfx::Vector2d& dest_offset, 35 bool partial_update) = 0; 36 37 protected: 38 explicit Resource(scoped_ptr<PrioritizedResource> texture); 39 40 private: 41 scoped_ptr<PrioritizedResource> texture_; 42 43 DISALLOW_COPY_AND_ASSIGN(Resource); 44 }; 45 46 LayerUpdater() {} 47 48 virtual scoped_ptr<Resource> CreateResource( 49 PrioritizedResourceManager* manager) = 0; 50 virtual void PrepareToUpdate(const gfx::Size& content_size, 51 const gfx::Rect& paint_rect, 52 const gfx::Size& tile_size, 53 float contents_width_scale, 54 float contents_height_scale) {} 55 virtual void ReduceMemoryUsage() {} 56 57 // Set true by the layer when it is known that the entire output is going to 58 // be opaque. 59 virtual void SetOpaque(bool opaque) {} 60 // Set true by the layer when it is known that the entire output bounds will 61 // be rasterized. 62 virtual void SetFillsBoundsCompletely(bool fills_bounds) {} 63 virtual void SetBackgroundColor(SkColor background_color) {} 64 65 protected: 66 virtual ~LayerUpdater() {} 67 68 private: 69 friend class base::RefCounted<LayerUpdater>; 70 71 DISALLOW_COPY_AND_ASSIGN(LayerUpdater); 72}; 73 74} // namespace cc 75 76#endif // CC_RESOURCES_LAYER_UPDATER_H_ 77