summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/browser/BUILD.gn6
-rw-r--r--content/browser/compositor/DEPS3
-rw-r--r--content/browser/compositor/gpu_process_transport_factory.cc19
-rw-r--r--content/browser/compositor/software_output_device_mus.cc64
-rw-r--r--content/browser/compositor/software_output_device_mus.h36
5 files changed, 127 insertions, 1 deletions
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
index 9990e72..e98e681 100644
--- a/content/browser/BUILD.gn
+++ b/content/browser/BUILD.gn
@@ -421,7 +421,13 @@ source_set("browser") {
"//ui/strings",
"//ui/views/mus:for_component",
"//ui/wm",
+ "//components/bitmap_uploader",
]
+ sources += [
+ "compositor/software_output_device_mus.cc",
+ "compositor/software_output_device_mus.h",
+ ]
+ defines += [ "MOJO_RUNNER_CLIENT" ]
} else { # Not aura.
sources -= [
"media/capture/cursor_renderer_aura.cc",
diff --git a/content/browser/compositor/DEPS b/content/browser/compositor/DEPS
index 1701f72..70240ed 100644
--- a/content/browser/compositor/DEPS
+++ b/content/browser/compositor/DEPS
@@ -1,3 +1,4 @@
include_rules = [
- "+ui/platform_window",
+ "+components/bitmap_uploader",
+ "+ui/platform_window",
]
diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc
index 7e2c513b9..2b9cd696 100644
--- a/content/browser/compositor/gpu_process_transport_factory.cc
+++ b/content/browser/compositor/gpu_process_transport_factory.cc
@@ -28,6 +28,7 @@
#include "content/browser/compositor/offscreen_browser_compositor_output_surface.h"
#include "content/browser/compositor/reflector_impl.h"
#include "content/browser/compositor/software_browser_compositor_output_surface.h"
+#include "content/browser/compositor/software_output_device_mus.h"
#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
#include "content/browser/gpu/compositor_util.h"
@@ -148,6 +149,14 @@ GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() {
scoped_ptr<cc::SoftwareOutputDevice>
GpuProcessTransportFactory::CreateSoftwareOutputDevice(
ui::Compositor* compositor) {
+#if defined(MOJO_RUNNER_CLIENT)
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ "mojo-platform-channel-handle")) {
+ return scoped_ptr<cc::SoftwareOutputDevice>(
+ new SoftwareOutputDeviceMus(compositor));
+ }
+#endif
+
#if defined(OS_WIN)
return scoped_ptr<cc::SoftwareOutputDevice>(
new SoftwareOutputDeviceWin(software_backing_.get(), compositor));
@@ -192,6 +201,16 @@ CreateOverlayCandidateValidator(gfx::AcceleratedWidget widget) {
}
static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) {
+#if defined(MOJO_RUNNER_CLIENT)
+ // Chrome running as a mojo app currently can only use software compositing.
+ // TODO(rjkroege): http://crbug.com/548451
+ // TODO(rjkroege): Make IsRunningInMojoRunner callable from content.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ "mojo-platform-channel-handle")) {
+ return false;
+ }
+#endif
+
#if defined(OS_CHROMEOS)
// Software fallback does not happen on Chrome OS.
return true;
diff --git a/content/browser/compositor/software_output_device_mus.cc b/content/browser/compositor/software_output_device_mus.cc
new file mode 100644
index 0000000..6180114
--- /dev/null
+++ b/content/browser/compositor/software_output_device_mus.cc
@@ -0,0 +1,64 @@
+// Copyright 2015 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 "content/browser/compositor/software_output_device_mus.h"
+
+#include "components/bitmap_uploader/bitmap_uploader.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "third_party/skia/include/core/SkDevice.h"
+#include "ui/base/view_prop.h"
+#include "ui/compositor/compositor.h"
+#include "ui/gfx/skia_util.h"
+
+#if !defined(OFFICIAL_BUILD)
+#include "base/threading/thread_restrictions.h"
+#endif
+
+namespace content {
+
+SoftwareOutputDeviceMus::SoftwareOutputDeviceMus(ui::Compositor* compositor)
+ : compositor_(compositor) {}
+
+void SoftwareOutputDeviceMus::EndPaint() {
+ SoftwareOutputDevice::EndPaint();
+#if !defined(OFFICIAL_BUILD)
+ base::ThreadRestrictions::ScopedAllowWait wait;
+#endif
+
+ if (!surface_)
+ return;
+
+ gfx::Rect rect = damage_rect_;
+ rect.Intersect(gfx::Rect(viewport_pixel_size_));
+ if (rect.IsEmpty())
+ return;
+
+ gfx::AcceleratedWidget widget = compositor_->widget();
+ bitmap_uploader::BitmapUploader* uploader =
+ reinterpret_cast<bitmap_uploader::BitmapUploader*>(ui::ViewProp::GetValue(
+ widget, bitmap_uploader::kBitmapUploaderForAcceleratedWidget));
+ DCHECK(uploader);
+
+ SkImageInfo info;
+ size_t rowBytes;
+ const void* addr = surface_->peekPixels(&info, &rowBytes);
+
+ if (!addr) {
+ LOG(WARNING) << "SoftwareOutputDeviceMus: skia surface did not provide us "
+ "with pixels";
+ return;
+ }
+
+ const unsigned char* pixels = static_cast<const unsigned char*>(addr);
+
+ // TODO(rjkroege): This makes an additional copy. Improve the
+ // bitmap_uploader API to remove.
+ scoped_ptr<std::vector<unsigned char>> data(new std::vector<unsigned char>(
+ pixels, pixels + rowBytes * viewport_pixel_size_.height()));
+ uploader->SetBitmap(viewport_pixel_size_.width(),
+ viewport_pixel_size_.height(), data.Pass(),
+ bitmap_uploader::BitmapUploader::BGRA);
+}
+
+} // namespace content
diff --git a/content/browser/compositor/software_output_device_mus.h b/content/browser/compositor/software_output_device_mus.h
new file mode 100644
index 0000000..d4a2e450
--- /dev/null
+++ b/content/browser/compositor/software_output_device_mus.h
@@ -0,0 +1,36 @@
+// Copyright 2015 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.
+
+#ifndef CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_MUS_H_
+#define CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_MUS_H_
+
+#include "base/macros.h"
+#include "cc/output/software_output_device.h"
+#include "content/common/content_export.h"
+
+namespace ui {
+class Compositor;
+}
+
+namespace content {
+
+// Mus implementation of software compositing: Chrome will do a software
+// composite and ship the resultant bitmap to an instance of the mus
+// window server. Remove this upon completion of http://crbug.com/548451
+class SoftwareOutputDeviceMus : public cc::SoftwareOutputDevice {
+ public:
+ explicit SoftwareOutputDeviceMus(ui::Compositor* compositor);
+
+ private:
+ // cc::SoftwareOutputDevice
+ void EndPaint() override;
+
+ ui::Compositor* compositor_;
+
+ DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDeviceMus);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_MUS_H_