| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/layers/io_surface_layer.h" | 5 #include "cc/layers/io_surface_layer.h" |
| 6 | 6 |
| 7 #include "cc/layers/io_surface_layer_impl.h" | 7 #include "cc/layers/io_surface_layer_impl.h" |
| 8 | 8 |
| 9 namespace cc { | 9 namespace cc { |
| 10 | 10 |
| 11 scoped_refptr<IOSurfaceLayer> IOSurfaceLayer::Create() { | 11 scoped_refptr<IOSurfaceLayer> IOSurfaceLayer::Create() { |
| 12 return make_scoped_refptr(new IOSurfaceLayer()); | 12 return make_scoped_refptr(new IOSurfaceLayer()); |
| 13 } | 13 } |
| 14 | 14 |
| 15 IOSurfaceLayer::IOSurfaceLayer() : Layer(), io_surface_id_(0) {} | 15 IOSurfaceLayer::IOSurfaceLayer() : Layer(), io_surface_id_(0) {} |
| 16 | 16 |
| 17 IOSurfaceLayer::~IOSurfaceLayer() {} | 17 IOSurfaceLayer::~IOSurfaceLayer() {} |
| 18 | 18 |
| 19 void IOSurfaceLayer::SetIOSurfaceProperties(uint32_t io_surface_id, | 19 void IOSurfaceLayer::SetIOSurfaceProperties(uint32_t io_surface_id, |
| 20 const gfx::Size& size) { | 20 const gfx::Size& size) { |
| 21 io_surface_id_ = io_surface_id; | 21 io_surface_id_ = io_surface_id; |
| 22 io_surface_size_ = size; | 22 io_surface_size_ = size; |
| 23 UpdateDrawsContent(true); |
| 23 SetNeedsCommit(); | 24 SetNeedsCommit(); |
| 24 } | 25 } |
| 25 | 26 |
| 26 scoped_ptr<LayerImpl> IOSurfaceLayer::CreateLayerImpl( | 27 scoped_ptr<LayerImpl> IOSurfaceLayer::CreateLayerImpl( |
| 27 LayerTreeImpl* tree_impl) { | 28 LayerTreeImpl* tree_impl) { |
| 28 return IOSurfaceLayerImpl::Create(tree_impl, layer_id_).PassAs<LayerImpl>(); | 29 return IOSurfaceLayerImpl::Create(tree_impl, layer_id_).PassAs<LayerImpl>(); |
| 29 } | 30 } |
| 30 | 31 |
| 31 bool IOSurfaceLayer::DrawsContent() const { | 32 void IOSurfaceLayer::UpdateDrawsContent(bool draws_content) { |
| 32 return io_surface_id_ && Layer::DrawsContent(); | 33 Layer::UpdateDrawsContent(draws_content && io_surface_id_); |
| 33 } | 34 } |
| 34 | 35 |
| 35 void IOSurfaceLayer::PushPropertiesTo(LayerImpl* layer) { | 36 void IOSurfaceLayer::PushPropertiesTo(LayerImpl* layer) { |
| 36 Layer::PushPropertiesTo(layer); | 37 Layer::PushPropertiesTo(layer); |
| 37 | 38 |
| 38 IOSurfaceLayerImpl* io_surface_layer = | 39 IOSurfaceLayerImpl* io_surface_layer = |
| 39 static_cast<IOSurfaceLayerImpl*>(layer); | 40 static_cast<IOSurfaceLayerImpl*>(layer); |
| 40 io_surface_layer->SetIOSurfaceProperties(io_surface_id_, io_surface_size_); | 41 io_surface_layer->SetIOSurfaceProperties(io_surface_id_, io_surface_size_); |
| 41 } | 42 } |
| 42 | 43 |
| 43 bool IOSurfaceLayer::Update(ResourceUpdateQueue* queue, | 44 bool IOSurfaceLayer::Update(ResourceUpdateQueue* queue, |
| 44 const OcclusionTracker<Layer>* occlusion) { | 45 const OcclusionTracker<Layer>* occlusion) { |
| 45 bool updated = Layer::Update(queue, occlusion); | 46 bool updated = Layer::Update(queue, occlusion); |
| 46 | 47 |
| 47 // This layer doesn't update any resources from the main thread side, | 48 // This layer doesn't update any resources from the main thread side, |
| 48 // but repaint rects need to be sent to the layer impl via commit. | 49 // but repaint rects need to be sent to the layer impl via commit. |
| 49 return updated || !update_rect_.IsEmpty(); | 50 return updated || !update_rect_.IsEmpty(); |
| 50 } | 51 } |
| 51 | 52 |
| 52 } // namespace cc | 53 } // namespace cc |
| OLD | NEW |