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

Side by Side Diff: cc/output/software_renderer.cc

Issue 18432002: Blend TextureLayer background-color at draw time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: resolved conflicts with TOT Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/output/shader.cc ('k') | cc/quads/draw_quad_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/software_renderer.h" 5 #include "cc/output/software_renderer.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "cc/base/math_util.h" 8 #include "cc/base/math_util.h"
9 #include "cc/output/compositor_frame.h" 9 #include "cc/output/compositor_frame.h"
10 #include "cc/output/compositor_frame_ack.h" 10 #include "cc/output/compositor_frame_ack.h"
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 346
347 // TODO(skaslev): Add support for non-premultiplied alpha. 347 // TODO(skaslev): Add support for non-premultiplied alpha.
348 ResourceProvider::ScopedReadLockSoftware lock(resource_provider_, 348 ResourceProvider::ScopedReadLockSoftware lock(resource_provider_,
349 quad->resource_id); 349 quad->resource_id);
350 const SkBitmap* bitmap = lock.sk_bitmap(); 350 const SkBitmap* bitmap = lock.sk_bitmap();
351 gfx::RectF uv_rect = gfx::ScaleRect(gfx::BoundingRect(quad->uv_top_left, 351 gfx::RectF uv_rect = gfx::ScaleRect(gfx::BoundingRect(quad->uv_top_left,
352 quad->uv_bottom_right), 352 quad->uv_bottom_right),
353 bitmap->width(), 353 bitmap->width(),
354 bitmap->height()); 354 bitmap->height());
355 SkRect sk_uv_rect = gfx::RectFToSkRect(uv_rect); 355 SkRect sk_uv_rect = gfx::RectFToSkRect(uv_rect);
356 SkRect quad_rect = gfx::RectFToSkRect(QuadVertexRect());
357
356 if (quad->flipped) 358 if (quad->flipped)
357 current_canvas_->scale(1, -1); 359 current_canvas_->scale(1, -1);
358 current_canvas_->drawBitmapRectToRect(*bitmap, &sk_uv_rect, 360
359 gfx::RectFToSkRect(QuadVertexRect()), 361 bool blend_background = quad->background_color != SK_ColorTRANSPARENT &&
362 !bitmap->isOpaque();
363 bool needs_layer = blend_background && (current_paint_.getAlpha() != 0xFF);
364 if (needs_layer) {
365 current_canvas_->saveLayerAlpha(&quad_rect, current_paint_.getAlpha());
366 current_paint_.setAlpha(0xFF);
367 }
368 if (blend_background) {
369 SkPaint background_paint;
370 background_paint.setColor(quad->background_color);
371 current_canvas_->drawRect(quad_rect, background_paint);
372 }
373
374 current_canvas_->drawBitmapRectToRect(*bitmap,
375 &sk_uv_rect,
376 quad_rect,
360 &current_paint_); 377 &current_paint_);
378
379 if (needs_layer)
380 current_canvas_->restore();
361 } 381 }
362 382
363 void SoftwareRenderer::DrawTileQuad(const DrawingFrame* frame, 383 void SoftwareRenderer::DrawTileQuad(const DrawingFrame* frame,
364 const TileDrawQuad* quad) { 384 const TileDrawQuad* quad) {
365 DCHECK(!output_surface_->ForcedDrawToSoftwareDevice()); 385 DCHECK(!output_surface_->ForcedDrawToSoftwareDevice());
366 DCHECK(IsSoftwareResource(quad->resource_id)); 386 DCHECK(IsSoftwareResource(quad->resource_id));
367 ResourceProvider::ScopedReadLockSoftware lock(resource_provider_, 387 ResourceProvider::ScopedReadLockSoftware lock(resource_provider_,
368 quad->resource_id); 388 quad->resource_id);
369 389
370 SkRect uv_rect = gfx::RectFToSkRect(quad->tex_coord_rect); 390 SkRect uv_rect = gfx::RectFToSkRect(quad->tex_coord_rect);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 visible_ = visible; 509 visible_ = visible;
490 } 510 }
491 511
492 void SoftwareRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) { 512 void SoftwareRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) {
493 // TODO(piman, skaslev): Can we release the backbuffer? We don't currently 513 // TODO(piman, skaslev): Can we release the backbuffer? We don't currently
494 // receive memory policy yet anyway. 514 // receive memory policy yet anyway.
495 NOTIMPLEMENTED(); 515 NOTIMPLEMENTED();
496 } 516 }
497 517
498 } // namespace cc 518 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/shader.cc ('k') | cc/quads/draw_quad_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698