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 gfx::RectF* opaque) { | |
30 client_->PaintContents(canvas, | 29 client_->PaintContents(canvas, |
31 content_rect, | 30 content_rect, |
32 opaque, | |
33 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); | 31 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); |
34 } | 32 } |
35 | 33 |
36 scoped_refptr<ContentLayer> ContentLayer::Create(ContentLayerClient* client) { | 34 scoped_refptr<ContentLayer> ContentLayer::Create(ContentLayerClient* client) { |
37 return make_scoped_refptr(new ContentLayer(client)); | 35 return make_scoped_refptr(new ContentLayer(client)); |
38 } | 36 } |
39 | 37 |
40 ContentLayer::ContentLayer(ContentLayerClient* client) | 38 ContentLayer::ContentLayer(ContentLayerClient* client) |
41 : TiledLayer(), | 39 : TiledLayer(), |
42 client_(client), | 40 client_(client), |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 bool ContentLayer::SupportsLCDText() const { | 138 bool ContentLayer::SupportsLCDText() const { |
141 return true; | 139 return true; |
142 } | 140 } |
143 | 141 |
144 skia::RefPtr<SkPicture> ContentLayer::GetPicture() const { | 142 skia::RefPtr<SkPicture> ContentLayer::GetPicture() const { |
145 if (!DrawsContent()) | 143 if (!DrawsContent()) |
146 return skia::RefPtr<SkPicture>(); | 144 return skia::RefPtr<SkPicture>(); |
147 | 145 |
148 int width = bounds().width(); | 146 int width = bounds().width(); |
149 int height = bounds().height(); | 147 int height = bounds().height(); |
150 gfx::RectF opaque; | |
151 | 148 |
152 SkPictureRecorder recorder; | 149 SkPictureRecorder recorder; |
153 SkCanvas* canvas = recorder.beginRecording(width, height, NULL, 0); | 150 SkCanvas* canvas = recorder.beginRecording(width, height, NULL, 0); |
154 client_->PaintContents(canvas, | 151 client_->PaintContents(canvas, |
155 gfx::Rect(width, height), | 152 gfx::Rect(width, height), |
156 &opaque, | |
157 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); | 153 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); |
158 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); | 154 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); |
159 return picture; | 155 return picture; |
160 } | 156 } |
161 | 157 |
162 void ContentLayer::OnOutputSurfaceCreated() { | 158 void ContentLayer::OnOutputSurfaceCreated() { |
163 SetTextureFormat( | 159 SetTextureFormat( |
164 layer_tree_host()->GetRendererCapabilities().best_texture_format); | 160 layer_tree_host()->GetRendererCapabilities().best_texture_format); |
165 TiledLayer::OnOutputSurfaceCreated(); | 161 TiledLayer::OnOutputSurfaceCreated(); |
166 } | 162 } |
167 | 163 |
168 } // namespace cc | 164 } // namespace cc |
OLD | NEW |