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. 4 5 #include "cc/layers/io_surface_layer.h" 6 7 #include "cc/layers/io_surface_layer_impl.h" 8 9 namespace cc { 10 Create()11scoped_refptr<IOSurfaceLayer> IOSurfaceLayer::Create() { 12 return make_scoped_refptr(new IOSurfaceLayer()); 13 } 14 IOSurfaceLayer()15IOSurfaceLayer::IOSurfaceLayer() : Layer(), io_surface_id_(0) {} 16 ~IOSurfaceLayer()17IOSurfaceLayer::~IOSurfaceLayer() {} 18 SetIOSurfaceProperties(uint32_t io_surface_id,const gfx::Size & size)19void IOSurfaceLayer::SetIOSurfaceProperties(uint32_t io_surface_id, 20 const gfx::Size& size) { 21 io_surface_id_ = io_surface_id; 22 io_surface_size_ = size; 23 UpdateDrawsContent(HasDrawableContent()); 24 SetNeedsCommit(); 25 } 26 CreateLayerImpl(LayerTreeImpl * tree_impl)27scoped_ptr<LayerImpl> IOSurfaceLayer::CreateLayerImpl( 28 LayerTreeImpl* tree_impl) { 29 return IOSurfaceLayerImpl::Create(tree_impl, layer_id_).PassAs<LayerImpl>(); 30 } 31 HasDrawableContent() const32bool IOSurfaceLayer::HasDrawableContent() const { 33 return io_surface_id_ && Layer::HasDrawableContent(); 34 } 35 PushPropertiesTo(LayerImpl * layer)36void IOSurfaceLayer::PushPropertiesTo(LayerImpl* layer) { 37 Layer::PushPropertiesTo(layer); 38 39 IOSurfaceLayerImpl* io_surface_layer = 40 static_cast<IOSurfaceLayerImpl*>(layer); 41 io_surface_layer->SetIOSurfaceProperties(io_surface_id_, io_surface_size_); 42 } 43 Update(ResourceUpdateQueue * queue,const OcclusionTracker<Layer> * occlusion)44bool IOSurfaceLayer::Update(ResourceUpdateQueue* queue, 45 const OcclusionTracker<Layer>* occlusion) { 46 bool updated = Layer::Update(queue, occlusion); 47 48 // This layer doesn't update any resources from the main thread side, 49 // but repaint rects need to be sent to the layer impl via commit. 50 return updated || !update_rect_.IsEmpty(); 51 } 52 53 } // namespace cc 54