Use SCHEME_HTTP for HTTPS proxies on Android.
[chromium-blink-merge.git] / cc / content_layer.cc
blobb34ce107e0ced197af3d767f4dc3b8c67f74016f
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.
5 #include "cc/content_layer.h"
7 #include "base/metrics/histogram.h"
8 #include "base/time.h"
9 #include "cc/bitmap_content_layer_updater.h"
10 #include "cc/bitmap_skpicture_content_layer_updater.h"
11 #include "cc/content_layer_client.h"
12 #include "cc/layer_painter.h"
13 #include "cc/layer_tree_host.h"
15 namespace cc {
17 ContentLayerPainter::ContentLayerPainter(ContentLayerClient* client)
18 : m_client(client)
22 scoped_ptr<ContentLayerPainter> ContentLayerPainter::create(ContentLayerClient* client)
24 return make_scoped_ptr(new ContentLayerPainter(client));
27 void ContentLayerPainter::paint(SkCanvas* canvas, const gfx::Rect& contentRect, gfx::RectF& opaque)
29 base::TimeTicks paintStart = base::TimeTicks::HighResNow();
30 m_client->paintContents(canvas, contentRect, opaque);
31 base::TimeTicks paintEnd = base::TimeTicks::HighResNow();
32 double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintEnd - paintStart).InSecondsF();
33 HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintDurationMS", (paintEnd - paintStart).InMilliseconds(), 0, 120, 30);
34 HISTOGRAM_CUSTOM_COUNTS("Renderer4.AccelContentPaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30);
37 scoped_refptr<ContentLayer> ContentLayer::create(ContentLayerClient* client)
39 return make_scoped_refptr(new ContentLayer(client));
42 ContentLayer::ContentLayer(ContentLayerClient* client)
43 : TiledLayer()
44 , m_client(client)
48 ContentLayer::~ContentLayer()
52 bool ContentLayer::drawsContent() const
54 return TiledLayer::drawsContent() && m_client;
57 void ContentLayer::setTexturePriorities(const PriorityCalculator& priorityCalc)
59 // Update the tile data before creating all the layer's tiles.
60 updateTileSizeAndTilingOption();
62 TiledLayer::setTexturePriorities(priorityCalc);
65 void ContentLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats)
67 createUpdaterIfNeeded();
68 TiledLayer::update(queue, occlusion, stats);
69 m_needsDisplay = false;
72 bool ContentLayer::needMoreUpdates()
74 return needsIdlePaint();
77 LayerUpdater* ContentLayer::updater() const
79 return m_updater.get();
82 void ContentLayer::createUpdaterIfNeeded()
84 if (m_updater)
85 return;
86 scoped_ptr<LayerPainter> painter = ContentLayerPainter::create(m_client).PassAs<LayerPainter>();
87 if (layerTreeHost()->settings().acceleratePainting)
88 m_updater = SkPictureContentLayerUpdater::create(painter.Pass());
89 else if (layerTreeHost()->settings().perTilePaintingEnabled)
90 m_updater = BitmapSkPictureContentLayerUpdater::create(painter.Pass());
91 else
92 m_updater = BitmapContentLayerUpdater::create(painter.Pass());
93 m_updater->setOpaque(contentsOpaque());
95 GLenum textureFormat = layerTreeHost()->rendererCapabilities().bestTextureFormat;
96 setTextureFormat(textureFormat);
99 void ContentLayer::setContentsOpaque(bool opaque)
101 Layer::setContentsOpaque(opaque);
102 if (m_updater)
103 m_updater->setOpaque(opaque);
106 } // namespace cc