OLD | NEW |
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/content_layer.h" | 5 #include "cc/layers/content_layer.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "cc/layers/content_layer_client.h" | 10 #include "cc/layers/content_layer_client.h" |
11 #include "cc/resources/bitmap_content_layer_updater.h" | 11 #include "cc/resources/bitmap_content_layer_updater.h" |
12 #include "cc/resources/bitmap_skpicture_content_layer_updater.h" | 12 #include "cc/resources/bitmap_skpicture_content_layer_updater.h" |
13 #include "cc/resources/layer_painter.h" | 13 #include "cc/resources/layer_painter.h" |
14 #include "cc/trees/layer_tree_host.h" | 14 #include "cc/trees/layer_tree_host.h" |
15 #include "third_party/skia/include/core/SkPictureRecorder.h" | 15 #include "third_party/skia/include/core/SkPictureRecorder.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
19 ContentLayerPainter::ContentLayerPainter(ContentLayerClient* client) | 19 ContentLayerPainter::ContentLayerPainter(ContentLayerClient* client) |
20 : client_(client) {} | 20 : client_(client) {} |
21 | 21 |
22 scoped_ptr<ContentLayerPainter> ContentLayerPainter::Create( | 22 scoped_ptr<ContentLayerPainter> ContentLayerPainter::Create( |
23 ContentLayerClient* client) { | 23 ContentLayerClient* client) { |
24 return make_scoped_ptr(new ContentLayerPainter(client)); | 24 return make_scoped_ptr(new ContentLayerPainter(client)); |
25 } | 25 } |
26 | 26 |
27 void ContentLayerPainter::Paint(SkCanvas* canvas, | 27 void ContentLayerPainter::Paint(SkCanvas* canvas, |
28 const gfx::Rect& content_rect) { | 28 const gfx::Rect& content_rect) { |
29 client_->PaintContents(canvas, | 29 client_->PaintContents(canvas, content_rect, |
30 content_rect, | 30 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
31 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); | |
32 } | 31 } |
33 | 32 |
34 scoped_refptr<ContentLayer> ContentLayer::Create(ContentLayerClient* client) { | 33 scoped_refptr<ContentLayer> ContentLayer::Create(ContentLayerClient* client) { |
35 return make_scoped_refptr(new ContentLayer(client)); | 34 return make_scoped_refptr(new ContentLayer(client)); |
36 } | 35 } |
37 | 36 |
38 ContentLayer::ContentLayer(ContentLayerClient* client) | 37 ContentLayer::ContentLayer(ContentLayerClient* client) |
39 : TiledLayer(), client_(client) { | 38 : TiledLayer(), client_(client) { |
40 } | 39 } |
41 | 40 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 120 |
122 skia::RefPtr<SkPicture> ContentLayer::GetPicture() const { | 121 skia::RefPtr<SkPicture> ContentLayer::GetPicture() const { |
123 if (!DrawsContent()) | 122 if (!DrawsContent()) |
124 return skia::RefPtr<SkPicture>(); | 123 return skia::RefPtr<SkPicture>(); |
125 | 124 |
126 int width = bounds().width(); | 125 int width = bounds().width(); |
127 int height = bounds().height(); | 126 int height = bounds().height(); |
128 | 127 |
129 SkPictureRecorder recorder; | 128 SkPictureRecorder recorder; |
130 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); | 129 SkCanvas* canvas = recorder.beginRecording(width, height, nullptr, 0); |
131 client_->PaintContents(canvas, | 130 client_->PaintContents(canvas, gfx::Rect(width, height), |
132 gfx::Rect(width, height), | 131 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
133 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); | |
134 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); | 132 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); |
135 return picture; | 133 return picture; |
136 } | 134 } |
137 | 135 |
138 void ContentLayer::OnOutputSurfaceCreated() { | 136 void ContentLayer::OnOutputSurfaceCreated() { |
139 SetTextureFormat( | 137 SetTextureFormat( |
140 layer_tree_host()->GetRendererCapabilities().best_texture_format); | 138 layer_tree_host()->GetRendererCapabilities().best_texture_format); |
141 TiledLayer::OnOutputSurfaceCreated(); | 139 TiledLayer::OnOutputSurfaceCreated(); |
142 } | 140 } |
143 | 141 |
144 } // namespace cc | 142 } // namespace cc |
OLD | NEW |