Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1591)

Unified Diff: cc/surfaces/surface_factory.cc

Issue 1531403002: Revert "Delete CC." (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_factory_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/surface_factory.cc
diff --git a/cc/surfaces/surface_factory.cc b/cc/surfaces/surface_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..aead4f68201830655340b3ee3507d9f9ed7b229a
--- /dev/null
+++ b/cc/surfaces/surface_factory.cc
@@ -0,0 +1,84 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/surfaces/surface_factory.h"
+
+#include "cc/output/compositor_frame.h"
+#include "cc/output/copy_output_request.h"
+#include "cc/surfaces/surface.h"
+#include "cc/surfaces/surface_manager.h"
+#include "ui/gfx/geometry/size.h"
+
+namespace cc {
+SurfaceFactory::SurfaceFactory(SurfaceManager* manager,
+ SurfaceFactoryClient* client)
+ : manager_(manager), client_(client), holder_(client) {
+}
+
+SurfaceFactory::~SurfaceFactory() {
+ if (!surface_map_.empty()) {
+ LOG(ERROR) << "SurfaceFactory has " << surface_map_.size()
+ << " entries in map on destruction.";
+ }
+ DestroyAll();
+}
+
+void SurfaceFactory::DestroyAll() {
+ for (auto it = surface_map_.begin(); it != surface_map_.end(); ++it)
+ manager_->Destroy(surface_map_.take(it));
+ surface_map_.clear();
+}
+
+void SurfaceFactory::Create(SurfaceId surface_id) {
+ scoped_ptr<Surface> surface(new Surface(surface_id, this));
+ manager_->RegisterSurface(surface.get());
+ DCHECK(!surface_map_.count(surface_id));
+ surface_map_.add(surface_id, surface.Pass());
+}
+
+void SurfaceFactory::Destroy(SurfaceId surface_id) {
+ OwningSurfaceMap::iterator it = surface_map_.find(surface_id);
+ DCHECK(it != surface_map_.end());
+ DCHECK(it->second->factory().get() == this);
+ manager_->Destroy(surface_map_.take_and_erase(it));
+}
+
+void SurfaceFactory::SubmitFrame(SurfaceId surface_id,
+ scoped_ptr<CompositorFrame> frame,
+ const DrawCallback& callback) {
+ OwningSurfaceMap::iterator it = surface_map_.find(surface_id);
+ DCHECK(it != surface_map_.end());
+ DCHECK(it->second->factory().get() == this);
+ it->second->QueueFrame(frame.Pass(), callback);
+ if (!manager_->SurfaceModified(surface_id))
+ it->second->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED);
+}
+
+void SurfaceFactory::RequestCopyOfSurface(
+ SurfaceId surface_id,
+ scoped_ptr<CopyOutputRequest> copy_request) {
+ OwningSurfaceMap::iterator it = surface_map_.find(surface_id);
+ if (it == surface_map_.end()) {
+ copy_request->SendEmptyResult();
+ return;
+ }
+ DCHECK(it->second->factory().get() == this);
+ it->second->RequestCopyOfOutput(copy_request.Pass());
+ manager_->SurfaceModified(surface_id);
+}
+
+void SurfaceFactory::ReceiveFromChild(
+ const TransferableResourceArray& resources) {
+ holder_.ReceiveFromChild(resources);
+}
+
+void SurfaceFactory::RefResources(const TransferableResourceArray& resources) {
+ holder_.RefResources(resources);
+}
+
+void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) {
+ holder_.UnrefResources(resources);
+}
+
+} // namespace cc
« no previous file with comments | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_factory_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698