Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: cc/layers/picture_image_layer.cc

Issue 373113003: Keeping track of descendants that draw content instead of recalcualting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/picture_image_layer.h ('k') | cc/layers/picture_layer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/picture_image_layer.h" 5 #include "cc/layers/picture_image_layer.h"
6 6
7 #include "cc/layers/picture_image_layer_impl.h" 7 #include "cc/layers/picture_image_layer_impl.h"
8 #include "third_party/skia/include/core/SkCanvas.h" 8 #include "third_party/skia/include/core/SkCanvas.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 scoped_refptr<PictureImageLayer> PictureImageLayer::Create() { 12 scoped_refptr<PictureImageLayer> PictureImageLayer::Create() {
13 return make_scoped_refptr(new PictureImageLayer()); 13 return make_scoped_refptr(new PictureImageLayer());
14 } 14 }
15 15
16 PictureImageLayer::PictureImageLayer() : PictureLayer(this) {} 16 PictureImageLayer::PictureImageLayer() : PictureLayer(this) {}
17 17
18 PictureImageLayer::~PictureImageLayer() { 18 PictureImageLayer::~PictureImageLayer() {
19 ClearClient(); 19 ClearClient();
20 } 20 }
21 21
22 scoped_ptr<LayerImpl> PictureImageLayer::CreateLayerImpl( 22 scoped_ptr<LayerImpl> PictureImageLayer::CreateLayerImpl(
23 LayerTreeImpl* tree_impl) { 23 LayerTreeImpl* tree_impl) {
24 return PictureImageLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); 24 return PictureImageLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>();
25 } 25 }
26 26
27 bool PictureImageLayer::DrawsContent() const { 27 bool PictureImageLayer::HasDrawableContent() const {
28 return !bitmap_.isNull() && PictureLayer::DrawsContent(); 28 return !bitmap_.isNull() && PictureLayer::HasDrawableContent();
29 } 29 }
30 30
31 void PictureImageLayer::SetBitmap(const SkBitmap& bitmap) { 31 void PictureImageLayer::SetBitmap(const SkBitmap& bitmap) {
32 // SetBitmap() currently gets called whenever there is any 32 // SetBitmap() currently gets called whenever there is any
33 // style change that affects the layer even if that change doesn't 33 // style change that affects the layer even if that change doesn't
34 // affect the actual contents of the image (e.g. a CSS animation). 34 // affect the actual contents of the image (e.g. a CSS animation).
35 // With this check in place we avoid unecessary texture uploads. 35 // With this check in place we avoid unecessary texture uploads.
36 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef()) 36 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef())
37 return; 37 return;
38 38
39 bitmap_ = bitmap; 39 bitmap_ = bitmap;
40 UpdateDrawsContent(HasDrawableContent());
40 SetNeedsDisplay(); 41 SetNeedsDisplay();
41 } 42 }
42 43
43 void PictureImageLayer::PaintContents( 44 void PictureImageLayer::PaintContents(
44 SkCanvas* canvas, 45 SkCanvas* canvas,
45 const gfx::Rect& clip, 46 const gfx::Rect& clip,
46 gfx::RectF* opaque, 47 gfx::RectF* opaque,
47 ContentLayerClient::GraphicsContextStatus gc_status) { 48 ContentLayerClient::GraphicsContextStatus gc_status) {
48 if (!bitmap_.width() || !bitmap_.height()) 49 if (!bitmap_.width() || !bitmap_.height())
49 return; 50 return;
(...skipping 11 matching lines...) Expand all
61 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 62 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
62 canvas->drawBitmap(bitmap_, 0, 0, &paint); 63 canvas->drawBitmap(bitmap_, 0, 0, &paint);
63 } 64 }
64 65
65 bool PictureImageLayer::FillsBoundsCompletely() const { 66 bool PictureImageLayer::FillsBoundsCompletely() const {
66 // PictureImageLayer will always paint to the entire layer bounds. 67 // PictureImageLayer will always paint to the entire layer bounds.
67 return true; 68 return true;
68 } 69 }
69 70
70 } // namespace cc 71 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_image_layer.h ('k') | cc/layers/picture_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698