diff options
author | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-08 06:22:35 +0000 |
---|---|---|
committer | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-08 06:22:35 +0000 |
commit | d98c0240810b6164cc46eb62ff670912a4ac28ba (patch) | |
tree | 9744ef4a7d07bae5330348f17986883dbeb8ce10 /cc | |
parent | a7259fb7e7d3ce696f0f3af91f7672c5ec551668 (diff) | |
download | chromium_src-d98c0240810b6164cc46eb62ff670912a4ac28ba.zip chromium_src-d98c0240810b6164cc46eb62ff670912a4ac28ba.tar.gz chromium_src-d98c0240810b6164cc46eb62ff670912a4ac28ba.tar.bz2 |
cc: Add some impl-side painting stub classes and APIs
BUG=155209
Review URL: https://chromiumcodereview.appspot.com/11265046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166615 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/cc.gyp | 8 | ||||
-rw-r--r-- | cc/picture.cc | 17 | ||||
-rw-r--r-- | cc/picture.h | 41 | ||||
-rw-r--r-- | cc/picture_layer.cc | 36 | ||||
-rw-r--r-- | cc/picture_layer.h | 37 | ||||
-rw-r--r-- | cc/picture_layer_impl.cc | 18 | ||||
-rw-r--r-- | cc/picture_layer_impl.h | 32 | ||||
-rw-r--r-- | cc/picture_pile.cc | 36 | ||||
-rw-r--r-- | cc/picture_pile.h | 51 |
9 files changed, 276 insertions, 0 deletions
@@ -111,6 +111,14 @@ 'overdraw_metrics.h', 'page_scale_animation.cc', 'page_scale_animation.h', + 'picture.cc', + 'picture.h', + 'picture_layer.cc', + 'picture_layer.h', + 'picture_layer_impl.cc', + 'picture_layer_impl.h', + 'picture_pile.cc', + 'picture_pile.h', 'platform_color.h', 'prioritized_resource.cc', 'prioritized_resource.h', diff --git a/cc/picture.cc b/cc/picture.cc new file mode 100644 index 0000000..3fac26e --- /dev/null +++ b/cc/picture.cc @@ -0,0 +1,17 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" + +#include "cc/picture.h" + +namespace cc { + +Picture::Picture() { +} + +Picture::~Picture() { +} + +} // namespace cc diff --git a/cc/picture.h b/cc/picture.h new file mode 100644 index 0000000..86a2dd8 --- /dev/null +++ b/cc/picture.h @@ -0,0 +1,41 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_PICTURE_H_ +#define CC_PICTURE_H_ + +#include "base/basictypes.h" +#include "base/memory/ref_counted.h" +#include "cc/cc_export.h" +#include "third_party/skia/include/core/SkPicture.h" +#include "ui/gfx/rect.h" + +namespace cc { + +class ContentLayerClient; + +class CC_EXPORT Picture + : public base::RefCountedThreadSafe<Picture> { +public: + scoped_refptr<Picture> create(ContentLayerClient*, gfx::Rect); + + const gfx::Rect& rect(); + scoped_refptr<Picture> clone(); + +protected: + Picture(); + ~Picture(); + + gfx::Rect m_rect; + SkPicture m_picture; + +private: + friend class base::RefCountedThreadSafe<Picture>; + + DISALLOW_COPY_AND_ASSIGN(Picture); +}; + +} // namespace cc + +#endif // CC_PICTURE_H_ diff --git a/cc/picture_layer.cc b/cc/picture_layer.cc new file mode 100644 index 0000000..ff69a2c --- /dev/null +++ b/cc/picture_layer.cc @@ -0,0 +1,36 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" + +#include "cc/picture_layer.h" +#include "cc/picture_layer_impl.h" + +namespace cc { + +scoped_refptr<PictureLayer> PictureLayer::create(ContentLayerClient* client) { + return make_scoped_refptr(new PictureLayer(client)); +} + +PictureLayer::PictureLayer(ContentLayerClient* client) : + client_(client) { +} + +PictureLayer::~PictureLayer() { +} + +bool PictureLayer::drawsContent() const { + return Layer::drawsContent() && client_; +} + +scoped_ptr<LayerImpl> PictureLayer::createLayerImpl() { + return PictureLayerImpl::create(id()).PassAs<LayerImpl>(); +} + +void PictureLayer::pushPropertiesTo(LayerImpl* baseLayerImpl) { + PictureLayerImpl* layerImpl = static_cast<PictureLayerImpl*>(baseLayerImpl); + pile_.pushPropertiesTo(layerImpl->pile_); +} + +} // namespace cc diff --git a/cc/picture_layer.h b/cc/picture_layer.h new file mode 100644 index 0000000..d22d9c2 --- /dev/null +++ b/cc/picture_layer.h @@ -0,0 +1,37 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_PICTURE_LAYER_H_ +#define CC_PICTURE_LAYER_H_ + +#include "cc/layer.h" +#include "cc/picture_pile.h" + +namespace cc { + +class ContentLayerClient; + +class CC_EXPORT PictureLayer : public Layer { +public: + static scoped_refptr<PictureLayer> create(ContentLayerClient*); + + void clearClient() { client_ = 0; } + + // Implement Layer interface + virtual bool drawsContent() const OVERRIDE; + virtual scoped_ptr<LayerImpl> createLayerImpl() OVERRIDE; + virtual void pushPropertiesTo(LayerImpl*) OVERRIDE; + +protected: + explicit PictureLayer(ContentLayerClient*); + virtual ~PictureLayer(); + +private: + ContentLayerClient* client_; + PicturePile pile_; +}; + +} // namespace cc + +#endif // CC_PICTURE_LAYER_H_ diff --git a/cc/picture_layer_impl.cc b/cc/picture_layer_impl.cc new file mode 100644 index 0000000..0da0d20 --- /dev/null +++ b/cc/picture_layer_impl.cc @@ -0,0 +1,18 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" + +#include "cc/picture_layer_impl.h" + +namespace cc { + +PictureLayerImpl::PictureLayerImpl(int id) : + LayerImpl(id) { +} + +PictureLayerImpl::~PictureLayerImpl() { +} + +} // namespace cc diff --git a/cc/picture_layer_impl.h b/cc/picture_layer_impl.h new file mode 100644 index 0000000..53ecec1 --- /dev/null +++ b/cc/picture_layer_impl.h @@ -0,0 +1,32 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_PICTURE_LAYER_IMPL_H_ +#define CC_PICTURE_LAYER_IMPL_H_ + +#include "cc/layer_impl.h" +#include "cc/picture_pile.h" + +namespace cc { + +class CC_EXPORT PictureLayerImpl : public LayerImpl { +public: + static scoped_ptr<PictureLayerImpl> create(int id) + { + return make_scoped_ptr(new PictureLayerImpl(id)); + } + virtual ~PictureLayerImpl(); + +protected: + PictureLayerImpl(int id); + + PicturePile pile_; + + friend class PictureLayer; + DISALLOW_COPY_AND_ASSIGN(PictureLayerImpl); +}; + +} + +#endif // CC_PICTURE_LAYER_IMPL_H_ diff --git a/cc/picture_pile.cc b/cc/picture_pile.cc new file mode 100644 index 0000000..a33147b --- /dev/null +++ b/cc/picture_pile.cc @@ -0,0 +1,36 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" + +#include "cc/picture_pile.h" + +namespace cc { + +PicturePile::PicturePile() { +} + +PicturePile::~PicturePile() { +} + +void PicturePile::invalidate(gfx::Rect rect) { + // TODO(enne) +} + +void PicturePile::resize(gfx::Size size) { + // TODO(enne) +} + +void PicturePile::update(ContentLayerClient* painter) { + // TODO(enne) +} + +void PicturePile::pushPropertiesTo(PicturePile& other) { + other.size_ = size_; + other.pile_.resize(pile_.size()); + for (size_t i = 0; i < pile_.size(); ++i) + other.pile_[i] = pile_[i]; +} + +} // namespace cc diff --git a/cc/picture_pile.h b/cc/picture_pile.h new file mode 100644 index 0000000..5d53974 --- /dev/null +++ b/cc/picture_pile.h @@ -0,0 +1,51 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_PICTURE_PILE_H_ +#define CC_PICTURE_PILE_H_ + +#include "base/basictypes.h" +#include "cc/cc_export.h" +#include "cc/picture.h" +#include "cc/scoped_ptr_vector.h" +#include "ui/gfx/rect.h" +#include "ui/gfx/size.h" + +namespace cc { + +class CC_EXPORT PicturePile { +public: + PicturePile(); + ~PicturePile(); + + // Mark a portion of the PicturePile as invalid and needing to be re-recorded + // the next time update is called. + void invalidate(gfx::Rect); + + // Resize the PicturePile, invalidating / dropping recorded pictures as necessary. + void resize(gfx::Size); + + // Rerecord parts of the picture that are invalid. + void update(ContentLayerClient* painter); + + // Update other with a shallow copy of this (main => compositor thread commit) + void pushPropertiesTo(PicturePile& other); + + // Clone a paint-safe version of this picture (with cloned PicturePileRecords) + scoped_ptr<PicturePile> cloneForDrawing(gfx::Rect rect); + + // Raster a subrect of this PicturePile into the given canvas. + // It's only safe to call paint on a cloned version. + void paint(SkCanvas* canvas, gfx::Rect rect); + +protected: + std::vector<scoped_refptr<Picture> > pile_; + gfx::Size size_; + + DISALLOW_COPY_AND_ASSIGN(PicturePile); +}; + +} // namespace cc + +#endif // CC_PICTURE_PILE_H_ |