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

Side by Side Diff: cc/picture_image_layer.cc

Issue 11516005: cc: Handle directly composited images in impl-side painting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows Created 8 years 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') | webkit/compositor_bindings/web_image_layer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "cc/picture_image_layer.h"
6
7 #include "third_party/skia/include/core/SkCanvas.h"
8
9 namespace cc {
10
11 scoped_refptr<PictureImageLayer> PictureImageLayer::create()
12 {
13 return make_scoped_refptr(new PictureImageLayer());
14 }
15
16 PictureImageLayer::PictureImageLayer()
17 : PictureLayer(this)
18 {
19 }
20
21 PictureImageLayer::~PictureImageLayer()
22 {
23 clearClient();
24 }
25
26 void PictureImageLayer::setBitmap(const SkBitmap& bitmap)
27 {
28 // setBitmap() currently gets called whenever there is any
29 // style change that affects the layer even if that change doesn't
30 // affect the actual contents of the image (e.g. a CSS animation).
31 // With this check in place we avoid unecessary texture uploads.
32 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef())
33 return;
34
35 bitmap_ = bitmap;
36 setNeedsDisplay();
37 }
38
39 void PictureImageLayer::update(
40 ResourceUpdateQueue& queue,
41 const OcclusionTracker* tracker,
42 RenderingStats& stats) {
43 if (bounds() != bounds_) {
44 // Pictures are recorded in layer space, so if the layer size changes,
45 // then the picture needs to be re-scaled, as a directly composited image
46 // always fills its entire layer bounds. This could be improved by
47 // recording pictures of images at their actual resolution somehow.
48 bounds_ = bounds();
49 setNeedsDisplay();
50 }
51 PictureLayer::update(queue, tracker, stats);
52 }
53
54 void PictureImageLayer::paintContents(
55 SkCanvas* canvas,
56 const gfx::Rect& clip,
57 gfx::RectF& opaque) {
58 if (!bitmap_.width() || !bitmap_.height())
59 return;
60
61 SkScalar content_to_layer_scale_x = SkFloatToScalar(
62 static_cast<float>(bounds().width()) / bitmap_.width());
63 SkScalar content_to_layer_scale_y = SkFloatToScalar(
64 static_cast<float>(bounds().height()) / bitmap_.height());
65 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y);
66
67 canvas->drawBitmap(bitmap_, 0, 0);
68 }
69
70 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture_image_layer.h ('k') | webkit/compositor_bindings/web_image_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698