Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / cc / layers / io_surface_layer.cc
blobc2e35304b60699b5cc6c54ce8ab23135fa48d090
1 // Copyright 2012 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/io_surface_layer.h"
7 #include "cc/layers/io_surface_layer_impl.h"
9 namespace cc {
11 scoped_refptr<IOSurfaceLayer> IOSurfaceLayer::Create(
12 const LayerSettings& settings) {
13 return make_scoped_refptr(new IOSurfaceLayer(settings));
16 IOSurfaceLayer::IOSurfaceLayer(const LayerSettings& settings)
17 : Layer(settings), io_surface_id_(0) {
20 IOSurfaceLayer::~IOSurfaceLayer() {}
22 void IOSurfaceLayer::SetIOSurfaceProperties(uint32_t io_surface_id,
23 const gfx::Size& size) {
24 io_surface_id_ = io_surface_id;
25 io_surface_size_ = size;
26 UpdateDrawsContent(HasDrawableContent());
27 SetNeedsCommit();
30 scoped_ptr<LayerImpl> IOSurfaceLayer::CreateLayerImpl(
31 LayerTreeImpl* tree_impl) {
32 return IOSurfaceLayerImpl::Create(tree_impl, layer_id_);
35 bool IOSurfaceLayer::HasDrawableContent() const {
36 return io_surface_id_ && Layer::HasDrawableContent();
39 void IOSurfaceLayer::PushPropertiesTo(LayerImpl* layer) {
40 Layer::PushPropertiesTo(layer);
42 IOSurfaceLayerImpl* io_surface_layer =
43 static_cast<IOSurfaceLayerImpl*>(layer);
44 io_surface_layer->SetIOSurfaceProperties(io_surface_id_, io_surface_size_);
47 bool IOSurfaceLayer::Update() {
48 bool updated = Layer::Update();
49 // This layer doesn't update any resources from the main thread side,
50 // but repaint rects need to be sent to the layer impl via commit.
51 return updated || !update_rect_.IsEmpty();
54 } // namespace cc