Use SCHEME_HTTP for HTTPS proxies on Android.
[chromium-blink-merge.git] / cc / bitmap_skpicture_content_layer_updater.cc
blob54d04fbdac2370abca7e6e2a5485fbebc0fb6e6d
1 // Copyright 2011 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/bitmap_skpicture_content_layer_updater.h"
7 #include "base/time.h"
8 #include "cc/layer_painter.h"
9 #include "cc/rendering_stats.h"
10 #include "cc/resource_update_queue.h"
11 #include "third_party/skia/include/core/SkCanvas.h"
12 #include "third_party/skia/include/core/SkDevice.h"
14 namespace cc {
16 BitmapSkPictureContentLayerUpdater::Resource::Resource(BitmapSkPictureContentLayerUpdater* updater, scoped_ptr<PrioritizedResource> texture)
17 : ContentLayerUpdater::Resource(texture.Pass())
18 , m_updater(updater)
22 void BitmapSkPictureContentLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats& stats)
24 m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, sourceRect.width(), sourceRect.height());
25 m_bitmap.allocPixels();
26 m_bitmap.setIsOpaque(m_updater->layerIsOpaque());
27 SkDevice device(m_bitmap);
28 SkCanvas canvas(&device);
29 base::TimeTicks paintBeginTime = base::TimeTicks::Now();
30 updater()->paintContentsRect(&canvas, sourceRect, stats);
31 stats.totalPaintTimeInSeconds += (base::TimeTicks::Now() - paintBeginTime).InSecondsF();
33 ResourceUpdate upload = ResourceUpdate::Create(
34 texture(), &m_bitmap, sourceRect, sourceRect, destOffset);
35 if (partialUpdate)
36 queue.appendPartialUpload(upload);
37 else
38 queue.appendFullUpload(upload);
41 scoped_refptr<BitmapSkPictureContentLayerUpdater> BitmapSkPictureContentLayerUpdater::create(scoped_ptr<LayerPainter> painter)
43 return make_scoped_refptr(new BitmapSkPictureContentLayerUpdater(painter.Pass()));
46 BitmapSkPictureContentLayerUpdater::BitmapSkPictureContentLayerUpdater(scoped_ptr<LayerPainter> painter)
47 : SkPictureContentLayerUpdater(painter.Pass())
51 BitmapSkPictureContentLayerUpdater::~BitmapSkPictureContentLayerUpdater()
55 scoped_ptr<LayerUpdater::Resource> BitmapSkPictureContentLayerUpdater::createResource(PrioritizedResourceManager* manager)
57 return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedResource::create(manager)));
60 void BitmapSkPictureContentLayerUpdater::paintContentsRect(SkCanvas* canvas, const gfx::Rect& sourceRect, RenderingStats& stats)
62 // Translate the origin of contentRect to that of sourceRect.
63 canvas->translate(contentRect().x() - sourceRect.x(),
64 contentRect().y() - sourceRect.y());
65 base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now();
66 drawPicture(canvas);
67 stats.totalRasterizeTimeInSeconds += (base::TimeTicks::Now() - rasterizeBeginTime).InSecondsF();
68 stats.totalPixelsRasterized += sourceRect.width() * sourceRect.height();
71 } // namespace cc