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

Unified Diff: ui/surface/transport_dib_mac.cc

Issue 13582008: Simplify the transport dib situation across our various platforms, as a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 months 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
Index: ui/surface/transport_dib_mac.cc
===================================================================
--- ui/surface/transport_dib_mac.cc (revision 192091)
+++ ui/surface/transport_dib_mac.cc (working copy)
@@ -1,97 +0,0 @@
-// Copyright (c) 2012 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 "ui/surface/transport_dib.h"
-
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/shared_memory.h"
-#include "base/posix/eintr_wrapper.h"
-#include "skia/ext/platform_canvas.h"
-
-TransportDIB::TransportDIB()
- : size_(0) {
-}
-
-TransportDIB::TransportDIB(TransportDIB::Handle dib)
- : shared_memory_(dib, false /* read write */),
- size_(0) {
-}
-
-TransportDIB::~TransportDIB() {
-}
-
-// static
-TransportDIB* TransportDIB::Create(size_t size, uint32 sequence_num) {
- TransportDIB* dib = new TransportDIB;
- if (!dib->shared_memory_.CreateAndMapAnonymous(size)) {
- delete dib;
- return NULL;
- }
-
- dib->size_ = size;
- return dib;
-}
-
-// static
-TransportDIB* TransportDIB::Map(Handle handle) {
- scoped_ptr<TransportDIB> dib(CreateWithHandle(handle));
- if (!dib->Map())
- return NULL;
- return dib.release();
-}
-
-// static
-TransportDIB* TransportDIB::CreateWithHandle(Handle handle) {
- return new TransportDIB(handle);
-}
-
-// static
-bool TransportDIB::is_valid_handle(Handle dib) {
- return dib.fd >= 0;
-}
-
-// static
-bool TransportDIB::is_valid_id(Id id) {
- return id != 0;
-}
-
-skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) {
- if ((!memory() && !Map()) || !VerifyCanvasSize(w, h))
- return NULL;
- return skia::CreatePlatformCanvas(w, h, true,
- reinterpret_cast<uint8_t*>(memory()),
- skia::RETURN_NULL_ON_FAILURE);
-}
-
-bool TransportDIB::Map() {
- if (!is_valid_handle(handle()))
- return false;
- if (memory())
- return true;
-
- struct stat st;
- if ((fstat(shared_memory_.handle().fd, &st) != 0) ||
- (!shared_memory_.Map(st.st_size))) {
- return false;
- }
-
- size_ = st.st_size;
- return true;
-}
-
-void* TransportDIB::memory() const {
- return shared_memory_.memory();
-}
-
-TransportDIB::Id TransportDIB::id() const {
- return shared_memory_.id();
-}
-
-TransportDIB::Handle TransportDIB::handle() const {
- return shared_memory_.handle();
-}

Powered by Google App Engine
This is Rietveld 408576698