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

Side by Side Diff: cc/picture_image_layer.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « cc/picture_image_layer.h ('k') | cc/picture_image_layer_impl.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/picture_image_layer.h" 5 #include "cc/picture_image_layer.h"
6 6
7 #include "cc/picture_image_layer_impl.h" 7 #include "cc/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 { 13 {
14 return make_scoped_refptr(new PictureImageLayer()); 14 return make_scoped_refptr(new PictureImageLayer());
15 } 15 }
16 16
17 PictureImageLayer::PictureImageLayer() 17 PictureImageLayer::PictureImageLayer()
18 : PictureLayer(this) 18 : PictureLayer(this)
19 { 19 {
20 } 20 }
21 21
22 PictureImageLayer::~PictureImageLayer() 22 PictureImageLayer::~PictureImageLayer()
23 { 23 {
24 clearClient(); 24 clearClient();
25 } 25 }
26 26
27 scoped_ptr<LayerImpl> PictureImageLayer::createLayerImpl( 27 scoped_ptr<LayerImpl> PictureImageLayer::CreateLayerImpl(
28 LayerTreeImpl* treeImpl) { 28 LayerTreeImpl* treeImpl) {
29 return PictureImageLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>(); 29 return PictureImageLayerImpl::Create(treeImpl, id()).PassAs<LayerImpl>();
30 } 30 }
31 31
32 bool PictureImageLayer::drawsContent() const { 32 bool PictureImageLayer::DrawsContent() const {
33 return !bitmap_.isNull() && PictureLayer::drawsContent(); 33 return !bitmap_.isNull() && PictureLayer::DrawsContent();
34 } 34 }
35 35
36 void PictureImageLayer::setBitmap(const SkBitmap& bitmap) 36 void PictureImageLayer::setBitmap(const SkBitmap& bitmap)
37 { 37 {
38 // setBitmap() currently gets called whenever there is any 38 // setBitmap() currently gets called whenever there is any
39 // style change that affects the layer even if that change doesn't 39 // style change that affects the layer even if that change doesn't
40 // affect the actual contents of the image (e.g. a CSS animation). 40 // affect the actual contents of the image (e.g. a CSS animation).
41 // With this check in place we avoid unecessary texture uploads. 41 // With this check in place we avoid unecessary texture uploads.
42 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef()) 42 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef())
43 return; 43 return;
44 44
45 bitmap_ = bitmap; 45 bitmap_ = bitmap;
46 setNeedsDisplay(); 46 SetNeedsDisplay();
47 } 47 }
48 48
49 void PictureImageLayer::paintContents( 49 void PictureImageLayer::paintContents(
50 SkCanvas* canvas, 50 SkCanvas* canvas,
51 const gfx::Rect& clip, 51 const gfx::Rect& clip,
52 gfx::RectF& opaque) { 52 gfx::RectF& opaque) {
53 if (!bitmap_.width() || !bitmap_.height()) 53 if (!bitmap_.width() || !bitmap_.height())
54 return; 54 return;
55 55
56 SkScalar content_to_layer_scale_x = SkFloatToScalar( 56 SkScalar content_to_layer_scale_x = SkFloatToScalar(
57 static_cast<float>(bounds().width()) / bitmap_.width()); 57 static_cast<float>(bounds().width()) / bitmap_.width());
58 SkScalar content_to_layer_scale_y = SkFloatToScalar( 58 SkScalar content_to_layer_scale_y = SkFloatToScalar(
59 static_cast<float>(bounds().height()) / bitmap_.height()); 59 static_cast<float>(bounds().height()) / bitmap_.height());
60 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); 60 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y);
61 61
62 canvas->drawBitmap(bitmap_, 0, 0); 62 canvas->drawBitmap(bitmap_, 0, 0);
63 } 63 }
64 64
65 } // namespace cc 65 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture_image_layer.h ('k') | cc/picture_image_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698