summaryrefslogtreecommitdiffstats
path: root/cc/output/software_renderer.cc
diff options
context:
space:
mode:
authoraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-10 00:06:37 +0000
committeraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-10 00:06:37 +0000
commitb09c1946b4ee6798a214f759a5a74aca01a05d27 (patch)
tree430b9984456ecbf746d0b42f931416d89532eef8 /cc/output/software_renderer.cc
parent2c08ddfa8e8b43b06f778cac1066482ae73b0e6a (diff)
downloadchromium_src-b09c1946b4ee6798a214f759a5a74aca01a05d27.zip
chromium_src-b09c1946b4ee6798a214f759a5a74aca01a05d27.tar.gz
chromium_src-b09c1946b4ee6798a214f759a5a74aca01a05d27.tar.bz2
cc: Add tile-free software compositing mode.
In Android WebView, CC will be run in a hybrid hardware/software mode where the renderer used may vary frame by frame. We're planning to reserve the ResourceProvider exclusively for GL tiles; for the software case, we'll draw directly from the PicturePile instead. This patch implements this draw-direct-from-PicturePile flow by adding PictureDrawQuad support to SoftwareRenderer and introducing a OutputSurface-based setting telling PictureLayerImpl to only append PictureDrawQuads for the current frame. NOTRY=true BUG=178398 Review URL: https://chromiumcodereview.appspot.com/14417014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199313 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/output/software_renderer.cc')
-rw-r--r--cc/output/software_renderer.cc44
1 files changed, 42 insertions, 2 deletions
diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc
index 0e96c57..7dd4a71 100644
--- a/cc/output/software_renderer.cc
+++ b/cc/output/software_renderer.cc
@@ -12,6 +12,7 @@
#include "cc/output/output_surface.h"
#include "cc/output/software_output_device.h"
#include "cc/quads/debug_border_draw_quad.h"
+#include "cc/quads/picture_draw_quad.h"
#include "cc/quads/render_pass_draw_quad.h"
#include "cc/quads/solid_color_draw_quad.h"
#include "cc/quads/texture_draw_quad.h"
@@ -71,8 +72,11 @@ SoftwareRenderer::SoftwareRenderer(RendererClient* client,
output_surface_(output_surface),
output_device_(output_surface->software_device()),
current_canvas_(NULL) {
- capabilities_.max_texture_size = resource_provider_->max_texture_size();
- capabilities_.best_texture_format = resource_provider_->best_texture_format();
+ if (resource_provider_) {
+ capabilities_.max_texture_size = resource_provider_->max_texture_size();
+ capabilities_.best_texture_format =
+ resource_provider_->best_texture_format();
+ }
capabilities_.using_set_visibility = true;
// The updater can access bitmaps while the SoftwareRenderer is using them.
capabilities_.allow_partial_texture_updates = true;
@@ -244,6 +248,9 @@ void SoftwareRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) {
case DrawQuad::DEBUG_BORDER:
DrawDebugBorderQuad(frame, DebugBorderDrawQuad::MaterialCast(quad));
break;
+ case DrawQuad::PICTURE_CONTENT:
+ DrawPictureQuad(frame, PictureDrawQuad::MaterialCast(quad));
+ break;
case DrawQuad::SOLID_COLOR:
DrawSolidColorQuad(frame, SolidColorDrawQuad::MaterialCast(quad));
break;
@@ -283,6 +290,38 @@ void SoftwareRenderer::DrawDebugBorderQuad(const DrawingFrame* frame,
4, transformed_vertices, current_paint_);
}
+void SoftwareRenderer::DrawPictureQuad(const DrawingFrame* frame,
+ const PictureDrawQuad* quad) {
+ SkMatrix content_matrix;
+ content_matrix.setRectToRect(
+ gfx::RectFToSkRect(quad->tex_coord_rect),
+ gfx::RectFToSkRect(QuadVertexRect()),
+ SkMatrix::kFill_ScaleToFit);
+ current_canvas_->concat(content_matrix);
+
+ if (quad->ShouldDrawWithBlending()) {
+ TRACE_EVENT0("cc", "SoftwareRenderer::DrawPictureQuad with blending");
+ SkBitmap temp_bitmap;
+ temp_bitmap.setConfig(SkBitmap::kARGB_8888_Config,
+ quad->texture_size.width(),
+ quad->texture_size.height());
+ temp_bitmap.allocPixels();
+ SkDevice temp_device(temp_bitmap);
+ SkCanvas temp_canvas(&temp_device);
+
+ quad->picture_pile->Raster(
+ &temp_canvas, quad->content_rect, quad->contents_scale, NULL);
+
+ current_paint_.setFilterBitmap(true);
+ current_canvas_->drawBitmap(temp_bitmap, 0, 0, &current_paint_);
+ } else {
+ TRACE_EVENT0("cc",
+ "SoftwareRenderer::DrawPictureQuad direct from PicturePile");
+ quad->picture_pile->Raster(
+ current_canvas_, quad->content_rect, quad->contents_scale, NULL);
+ }
+}
+
void SoftwareRenderer::DrawSolidColorQuad(const DrawingFrame* frame,
const SolidColorDrawQuad* quad) {
current_paint_.setColor(quad->color);
@@ -316,6 +355,7 @@ void SoftwareRenderer::DrawTextureQuad(const DrawingFrame* frame,
void SoftwareRenderer::DrawTileQuad(const DrawingFrame* frame,
const TileDrawQuad* quad) {
+ DCHECK(!output_surface_->ForcedDrawToSoftwareDevice());
DCHECK(IsSoftwareResource(quad->resource_id));
ResourceProvider::ScopedReadLockSoftware lock(resource_provider_,
quad->resource_id);