summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjbauman <jbauman@chromium.org>2015-05-11 16:43:12 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-11 23:43:33 +0000
commit7e15c6af85005fb44e35f2b1e3bfa1d61c4e2826 (patch)
tree2118c10ccb153fd97dcc20dcf8b771ed9feda410
parentbca23e588da39bd335338f3fdebe470eacd77e2a (diff)
downloadchromium_src-7e15c6af85005fb44e35f2b1e3bfa1d61c4e2826.zip
chromium_src-7e15c6af85005fb44e35f2b1e3bfa1d61c4e2826.tar.gz
chromium_src-7e15c6af85005fb44e35f2b1e3bfa1d61c4e2826.tar.bz2
Remove CompositorSoftwareOutputDevice
This was only used in tests. In that case there's no reason to send the contents to another process, so we can use the simpler cc::SoftwareOutputDevice instead. Review URL: https://codereview.chromium.org/1136553004 Cr-Commit-Position: refs/heads/master@{#329272}
-rw-r--r--content/content_renderer.gypi2
-rw-r--r--content/renderer/gpu/compositor_software_output_device.cc232
-rw-r--r--content/renderer/gpu/compositor_software_output_device.h101
-rw-r--r--content/renderer/render_widget.cc3
4 files changed, 1 insertions, 337 deletions
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index 21bac27..f6a9eee 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -174,8 +174,6 @@
'renderer/gpu/compositor_forwarding_message_filter.h',
'renderer/gpu/compositor_output_surface.cc',
'renderer/gpu/compositor_output_surface.h',
- 'renderer/gpu/compositor_software_output_device.cc',
- 'renderer/gpu/compositor_software_output_device.h',
'renderer/gpu/delegated_compositor_output_surface.cc',
'renderer/gpu/delegated_compositor_output_surface.h',
'renderer/gpu/frame_swap_message_queue.cc',
diff --git a/content/renderer/gpu/compositor_software_output_device.cc b/content/renderer/gpu/compositor_software_output_device.cc
deleted file mode 100644
index 93155cc..0000000
--- a/content/renderer/gpu/compositor_software_output_device.cc
+++ /dev/null
@@ -1,232 +0,0 @@
-// Copyright (c) 2013 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/renderer/gpu/compositor_software_output_device.h"
-
-#include "base/logging.h"
-#include "cc/output/software_frame_data.h"
-#include "content/child/child_shared_bitmap_manager.h"
-#include "content/renderer/render_process.h"
-#include "content/renderer/render_thread_impl.h"
-#include "third_party/skia/include/core/SkCanvas.h"
-#include "third_party/skia/include/core/SkPixelRef.h"
-#include "third_party/skia/include/core/SkRegion.h"
-#include "ui/gfx/skia_util.h"
-
-namespace {
-
-const size_t kInvalidIndex = static_cast<size_t>(-1);
-
-} // namespace
-
-namespace content {
-
-CompositorSoftwareOutputDevice::Buffer::Buffer(
- unsigned id,
- scoped_ptr<cc::SharedBitmap> bitmap)
- : id_(id), shared_bitmap_(bitmap.Pass()), free_(true), parent_(NULL) {}
-
-CompositorSoftwareOutputDevice::Buffer::~Buffer() {
-}
-
-void CompositorSoftwareOutputDevice::Buffer::SetParent(
- Buffer* parent, const gfx::Rect& damage) {
- parent_ = parent;
- damage_ = damage;
-}
-
-bool CompositorSoftwareOutputDevice::Buffer::FindDamageDifferenceFrom(
- Buffer* buffer, SkRegion* result) const {
- if (!buffer)
- return false;
-
- if (buffer == this) {
- *result = SkRegion();
- return true;
- }
-
- SkRegion damage;
- const Buffer* current = this;
- while (current->parent_) {
- damage.op(RectToSkIRect(current->damage_), SkRegion::kUnion_Op);
- if (current->parent_ == buffer) {
- *result = damage;
- return true;
- }
- current = current->parent_;
- }
-
- return false;
-}
-
-CompositorSoftwareOutputDevice::CompositorSoftwareOutputDevice()
- : current_index_(kInvalidIndex),
- next_buffer_id_(1),
- shared_bitmap_manager_(
- RenderThreadImpl::current()->shared_bitmap_manager()) {
- DetachFromThread();
-}
-
-CompositorSoftwareOutputDevice::~CompositorSoftwareOutputDevice() {
- DCHECK(CalledOnValidThread());
-}
-
-unsigned CompositorSoftwareOutputDevice::GetNextId() {
- unsigned id = next_buffer_id_++;
- // Zero is reserved to label invalid frame id.
- if (id == 0)
- id = next_buffer_id_++;
- return id;
-}
-
-CompositorSoftwareOutputDevice::Buffer*
-CompositorSoftwareOutputDevice::CreateBuffer() {
- scoped_ptr<cc::SharedBitmap> shared_bitmap =
- shared_bitmap_manager_->AllocateSharedBitmap(viewport_pixel_size_);
- CHECK(shared_bitmap);
- return new Buffer(GetNextId(), shared_bitmap.Pass());
-}
-
-size_t CompositorSoftwareOutputDevice::FindFreeBuffer(size_t hint) {
- for (size_t i = 0; i < buffers_.size(); ++i) {
- size_t index = (hint + i) % buffers_.size();
- if (buffers_[index]->free())
- return index;
- }
-
- buffers_.push_back(CreateBuffer());
- return buffers_.size() - 1;
-}
-
-void CompositorSoftwareOutputDevice::Resize(
- const gfx::Size& viewport_pixel_size,
- float scale_factor) {
- DCHECK(CalledOnValidThread());
-
- scale_factor_ = scale_factor;
-
- if (viewport_pixel_size_ == viewport_pixel_size)
- return;
-
- // Keep non-ACKed buffers in awaiting_ack_ until they get acknowledged.
- for (size_t i = 0; i < buffers_.size(); ++i) {
- if (!buffers_[i]->free()) {
- awaiting_ack_.push_back(buffers_[i]);
- buffers_[i] = NULL;
- }
- }
-
- buffers_.clear();
- current_index_ = kInvalidIndex;
- viewport_pixel_size_ = viewport_pixel_size;
-}
-
-void CompositorSoftwareOutputDevice::DiscardBackbuffer() {
- // Keep non-ACKed buffers in awaiting_ack_ until they get acknowledged.
- for (size_t i = 0; i < buffers_.size(); ++i) {
- if (!buffers_[i]->free()) {
- awaiting_ack_.push_back(buffers_[i]);
- buffers_[i] = NULL;
- }
- }
- buffers_.clear();
- current_index_ = kInvalidIndex;
-}
-
-void CompositorSoftwareOutputDevice::EnsureBackbuffer() {
-}
-
-SkCanvas* CompositorSoftwareOutputDevice::BeginPaint(
- const gfx::Rect& damage_rect) {
- DCHECK(CalledOnValidThread());
-
- Buffer* previous = NULL;
- if (current_index_ != kInvalidIndex)
- previous = buffers_[current_index_];
- current_index_ = FindFreeBuffer(current_index_ + 1);
- Buffer* current = buffers_[current_index_];
- DCHECK(current->free());
- current->SetFree(false);
-
- // Set up a canvas for the current front buffer.
- SkImageInfo info = SkImageInfo::MakeN32Premul(viewport_pixel_size_.width(),
- viewport_pixel_size_.height());
- surface_ = skia::AdoptRef(SkSurface::NewRasterDirect(info, current->memory(),
- info.minRowBytes()));
-
- if (!previous) {
- DCHECK(damage_rect == gfx::Rect(viewport_pixel_size_));
- } else {
- // Find the smallest damage region that needs
- // to be copied from the |previous| buffer.
- SkRegion region;
- bool found =
- current->FindDamageDifferenceFrom(previous, &region) ||
- previous->FindDamageDifferenceFrom(current, &region);
- if (!found)
- region = SkRegion(RectToSkIRect(gfx::Rect(viewport_pixel_size_)));
- region.op(RectToSkIRect(damage_rect), SkRegion::kDifference_Op);
-
- // Copy over the damage region.
- if (!region.isEmpty()) {
- SkImageInfo info = SkImageInfo::MakeN32Premul(
- viewport_pixel_size_.width(), viewport_pixel_size_.height());
- SkBitmap back_bitmap;
- back_bitmap.installPixels(info, previous->memory(), info.minRowBytes());
-
- for (SkRegion::Iterator it(region); !it.done(); it.next()) {
- const SkIRect& src_rect = it.rect();
- SkRect dst_rect = SkRect::Make(src_rect);
- surface_->getCanvas()->drawBitmapRect(back_bitmap, &src_rect, dst_rect);
- }
- }
- }
-
- // Make |current| child of |previous| and orphan all of |current|'s children.
- current->SetParent(previous, damage_rect);
- for (size_t i = 0; i < buffers_.size(); ++i) {
- Buffer* buffer = buffers_[i];
- if (buffer->parent() == current)
- buffer->SetParent(NULL, gfx::Rect(viewport_pixel_size_));
- }
- damage_rect_ = damage_rect;
-
- return surface_->getCanvas();
-}
-
-void CompositorSoftwareOutputDevice::EndPaint(
- cc::SoftwareFrameData* frame_data) {
- DCHECK(CalledOnValidThread());
- DCHECK(frame_data);
-
- Buffer* buffer = buffers_[current_index_];
- frame_data->id = buffer->id();
- frame_data->size = viewport_pixel_size_;
- frame_data->damage_rect = damage_rect_;
- frame_data->bitmap_id = buffer->shared_bitmap_id();
-}
-
-void CompositorSoftwareOutputDevice::ReclaimSoftwareFrame(unsigned id) {
- DCHECK(CalledOnValidThread());
-
- if (!id)
- return;
-
- // The reclaimed buffer id might not be among the currently
- // active buffers if we got a resize event in the mean time.
- ScopedVector<Buffer>::iterator it =
- std::find_if(buffers_.begin(), buffers_.end(), CompareById(id));
- if (it != buffers_.end()) {
- DCHECK(!(*it)->free());
- (*it)->SetFree(true);
- return;
- } else {
- it = std::find_if(awaiting_ack_.begin(), awaiting_ack_.end(),
- CompareById(id));
- DCHECK(it != awaiting_ack_.end());
- awaiting_ack_.erase(it);
- }
-}
-
-} // namespace content
diff --git a/content/renderer/gpu/compositor_software_output_device.h b/content/renderer/gpu/compositor_software_output_device.h
deleted file mode 100644
index 48fa050..0000000
--- a/content/renderer/gpu/compositor_software_output_device.h
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright (c) 2013 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_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_
-#define CONTENT_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/scoped_vector.h"
-#include "base/memory/shared_memory.h"
-#include "base/threading/non_thread_safe.h"
-#include "cc/output/software_output_device.h"
-#include "cc/resources/shared_bitmap.h"
-#include "content/public/renderer/render_thread.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-class SkRegion;
-
-namespace cc {
-class SharedBitmapManager;
-}
-
-namespace content {
-
-// This class can be created only on the main thread, but then becomes pinned
-// to a fixed thread when BindToClient is called.
-class CompositorSoftwareOutputDevice
- : NON_EXPORTED_BASE(public cc::SoftwareOutputDevice),
- NON_EXPORTED_BASE(public base::NonThreadSafe) {
- public:
- CompositorSoftwareOutputDevice();
- ~CompositorSoftwareOutputDevice() override;
-
- void Resize(const gfx::Size& pixel_size, float scale_factor) override;
-
- SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override;
- void EndPaint(cc::SoftwareFrameData* frame_data) override;
- void EnsureBackbuffer() override;
- void DiscardBackbuffer() override;
-
- void ReclaimSoftwareFrame(unsigned id) override;
-
- private:
- // Internal buffer class that manages shared memory lifetime and ownership.
- // It also tracks buffers' history so we can calculate what's the minimum
- // damage rect difference between any two given buffers (see SetParent and
- // FindDamageDifferenceFrom).
- class Buffer {
- public:
- explicit Buffer(unsigned id, scoped_ptr<cc::SharedBitmap> bitmap);
- ~Buffer();
-
- unsigned id() const { return id_; }
-
- void* memory() const { return shared_bitmap_->pixels(); }
- cc::SharedBitmapId shared_bitmap_id() const { return shared_bitmap_->id(); }
-
- bool free() const { return free_; }
- void SetFree(bool free) { free_ = free; }
-
- Buffer* parent() const { return parent_; }
- void SetParent(Buffer* parent, const gfx::Rect& damage);
-
- bool FindDamageDifferenceFrom(Buffer* buffer, SkRegion* result) const;
-
- private:
- const unsigned id_;
- scoped_ptr<cc::SharedBitmap> shared_bitmap_;
- bool free_;
- Buffer* parent_;
- gfx::Rect damage_;
-
- DISALLOW_COPY_AND_ASSIGN(Buffer);
- };
-
- class CompareById {
- public:
- CompareById(unsigned id) : id_(id) {}
-
- bool operator()(const Buffer* buffer) const {
- return buffer->id() == id_;
- }
-
- private:
- const unsigned id_;
- };
-
- unsigned GetNextId();
- Buffer* CreateBuffer();
- size_t FindFreeBuffer(size_t hint);
-
- size_t current_index_;
- unsigned next_buffer_id_;
- ScopedVector<Buffer> buffers_;
- ScopedVector<Buffer> awaiting_ack_;
- cc::SharedBitmapManager* shared_bitmap_manager_;
-};
-
-} // namespace content
-
-#endif // CONTENT_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 6d34a51..0b8d2ff 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -36,7 +36,6 @@
#include "content/renderer/cursor_utils.h"
#include "content/renderer/external_popup_menu.h"
#include "content/renderer/gpu/compositor_output_surface.h"
-#include "content/renderer/gpu/compositor_software_output_device.h"
#include "content/renderer/gpu/delegated_compositor_output_surface.h"
#include "content/renderer/gpu/frame_swap_message_queue.h"
#include "content/renderer/gpu/mailbox_output_surface.h"
@@ -1036,7 +1035,7 @@ scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) {
}
if (!context_provider.get()) {
scoped_ptr<cc::SoftwareOutputDevice> software_device(
- new CompositorSoftwareOutputDevice());
+ new cc::SoftwareOutputDevice());
return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface(
routing_id(), output_surface_id, nullptr, nullptr,