[Android] Add a device-side test HTTP server via ChromeInstrumentationTestRunner.
[chromium-blink-merge.git] / cc / layers / picture_image_layer.cc
blobcebc8b77cdb0386f90c89093e7c47b323d35dfb4
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/layers/picture_image_layer.h"
7 #include "cc/layers/picture_image_layer_impl.h"
8 #include "third_party/skia/include/core/SkCanvas.h"
10 namespace cc {
12 scoped_refptr<PictureImageLayer> PictureImageLayer::Create() {
13 return make_scoped_refptr(new PictureImageLayer());
16 PictureImageLayer::PictureImageLayer() : PictureLayer(this) {}
18 PictureImageLayer::~PictureImageLayer() {
19 ClearClient();
22 scoped_ptr<LayerImpl> PictureImageLayer::CreateLayerImpl(
23 LayerTreeImpl* tree_impl) {
24 return PictureImageLayerImpl::Create(tree_impl, id(), is_mask());
27 bool PictureImageLayer::HasDrawableContent() const {
28 return !bitmap_.isNull() && PictureLayer::HasDrawableContent();
31 void PictureImageLayer::SetBitmap(const SkBitmap& bitmap) {
32 // SetBitmap() currently gets called whenever there is any
33 // style change that affects the layer even if that change doesn't
34 // affect the actual contents of the image (e.g. a CSS animation).
35 // With this check in place we avoid unecessary texture uploads.
36 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef())
37 return;
39 bitmap_ = bitmap;
40 UpdateDrawsContent(HasDrawableContent());
41 SetNeedsDisplay();
44 void PictureImageLayer::PaintContents(
45 SkCanvas* canvas,
46 const gfx::Rect& clip,
47 ContentLayerClient::GraphicsContextStatus gc_status) {
48 if (!bitmap_.width() || !bitmap_.height())
49 return;
51 SkScalar content_to_layer_scale_x =
52 SkFloatToScalar(static_cast<float>(bounds().width()) / bitmap_.width());
53 SkScalar content_to_layer_scale_y =
54 SkFloatToScalar(static_cast<float>(bounds().height()) / bitmap_.height());
55 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y);
57 // Because Android WebView resourceless software draw mode rasters directly
58 // to the root canvas, this draw must use the kSrcOver_Mode so that
59 // transparent images blend correctly.
60 canvas->drawBitmap(bitmap_, 0, 0);
63 scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList(
64 const gfx::Rect& clip,
65 GraphicsContextStatus gc_status) {
66 NOTIMPLEMENTED();
67 return DisplayItemList::Create();
70 bool PictureImageLayer::FillsBoundsCompletely() const {
71 return false;
74 } // namespace cc