| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/surfaces/surface.h" | 5 #include "cc/surfaces/surface.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 | 11 |
| 12 #include "cc/base/container_util.h" | 12 #include "cc/base/container_util.h" |
| 13 #include "cc/output/compositor_frame.h" | 13 #include "cc/output/compositor_frame.h" |
| 14 #include "cc/output/copy_output_request.h" | 14 #include "cc/output/copy_output_request.h" |
| 15 #include "cc/surfaces/surface_factory.h" | 15 #include "cc/surfaces/surface_factory.h" |
| 16 #include "cc/surfaces/surface_id_allocator.h" | 16 #include "cc/surfaces/surface_id_allocator.h" |
| 17 #include "cc/surfaces/surface_manager.h" | 17 #include "cc/surfaces/surface_manager.h" |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 | 20 |
| 21 // The frame index starts at 2 so that empty frames will be treated as | 21 // The frame index starts at 2 so that empty frames will be treated as |
| 22 // completely damaged the first time they're drawn from. | 22 // completely damaged the first time they're drawn from. |
| 23 static const int kFrameIndexStart = 2; | 23 static const int kFrameIndexStart = 2; |
| 24 | 24 |
| 25 Surface::Surface(const SurfaceId& id, SurfaceFactory* factory) | 25 Surface::Surface(const SurfaceId& id, base::WeakPtr<SurfaceFactory> factory) |
| 26 : surface_id_(id), | 26 : surface_id_(id), |
| 27 previous_frame_surface_id_(id), | 27 previous_frame_surface_id_(id), |
| 28 factory_(factory->AsWeakPtr()), | 28 factory_(factory), |
| 29 frame_index_(kFrameIndexStart), | 29 frame_index_(kFrameIndexStart), |
| 30 destroyed_(false) {} | 30 destroyed_(false) {} |
| 31 | 31 |
| 32 Surface::~Surface() { | 32 Surface::~Surface() { |
| 33 ClearCopyRequests(); | 33 ClearCopyRequests(); |
| 34 if (current_frame_ && factory_) { | 34 if (current_frame_ && factory_) { |
| 35 UnrefFrameResources(*current_frame_); | 35 UnrefFrameResources(*current_frame_); |
| 36 } | 36 } |
| 37 if (!draw_callback_.is_null()) | 37 if (!draw_callback_.is_null()) |
| 38 draw_callback_.Run(); | 38 draw_callback_.Run(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 void Surface::ClearCopyRequests() { | 182 void Surface::ClearCopyRequests() { |
| 183 if (current_frame_) { | 183 if (current_frame_) { |
| 184 for (const auto& render_pass : current_frame_->render_pass_list) { | 184 for (const auto& render_pass : current_frame_->render_pass_list) { |
| 185 for (const auto& copy_request : render_pass->copy_requests) | 185 for (const auto& copy_request : render_pass->copy_requests) |
| 186 copy_request->SendEmptyResult(); | 186 copy_request->SendEmptyResult(); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // namespace cc | 191 } // namespace cc |
| OLD | NEW |