Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 | 345 |
| 346 // TODO(skaslev): Add support for non-premultiplied alpha. | 346 // TODO(skaslev): Add support for non-premultiplied alpha. |
| 347 ResourceProvider::ScopedReadLockSoftware lock(resource_provider_, | 347 ResourceProvider::ScopedReadLockSoftware lock(resource_provider_, |
| 348 quad->resource_id); | 348 quad->resource_id); |
| 349 const SkBitmap* bitmap = lock.sk_bitmap(); | 349 const SkBitmap* bitmap = lock.sk_bitmap(); |
| 350 gfx::RectF uv_rect = gfx::ScaleRect(gfx::BoundingRect(quad->uv_top_left, | 350 gfx::RectF uv_rect = gfx::ScaleRect(gfx::BoundingRect(quad->uv_top_left, |
| 351 quad->uv_bottom_right), | 351 quad->uv_bottom_right), |
| 352 bitmap->width(), | 352 bitmap->width(), |
| 353 bitmap->height()); | 353 bitmap->height()); |
| 354 SkRect sk_uv_rect = gfx::RectFToSkRect(uv_rect); | 354 SkRect sk_uv_rect = gfx::RectFToSkRect(uv_rect); |
| 355 SkRect quad_rect = gfx::RectFToSkRect(QuadVertexRect()); | |
| 356 | |
| 355 if (quad->flipped) | 357 if (quad->flipped) |
| 356 current_canvas_->scale(1, -1); | 358 current_canvas_->scale(1, -1); |
| 357 current_canvas_->drawBitmapRectToRect(*bitmap, &sk_uv_rect, | 359 |
| 358 gfx::RectFToSkRect(QuadVertexRect()), | 360 bool blend_background = (SkColorGetA(quad->background_color) != 0) && |
| 361 !bitmap->isOpaque(); | |
| 362 bool needs_layer = blend_background && (current_paint_.getAlpha() != 0xFF); | |
|
alokp
2013/07/09 00:08:06
reed@: Is there a paint mode in skia that will avo
| |
| 363 if (needs_layer) { | |
| 364 current_canvas_->saveLayerAlpha(&quad_rect, current_paint_.getAlpha()); | |
| 365 current_paint_.setAlpha(0xFF); | |
| 366 } | |
| 367 if (blend_background) { | |
| 368 SkPaint background_paint; | |
| 369 background_paint.setColor(quad->background_color); | |
| 370 current_canvas_->drawRect(quad_rect, background_paint); | |
| 371 } | |
| 372 | |
| 373 current_canvas_->drawBitmapRectToRect(*bitmap, | |
| 374 &sk_uv_rect, | |
| 375 quad_rect, | |
| 359 ¤t_paint_); | 376 ¤t_paint_); |
| 377 | |
| 378 if (needs_layer) | |
| 379 current_canvas_->restore(); | |
| 360 } | 380 } |
| 361 | 381 |
| 362 void SoftwareRenderer::DrawTileQuad(const DrawingFrame* frame, | 382 void SoftwareRenderer::DrawTileQuad(const DrawingFrame* frame, |
| 363 const TileDrawQuad* quad) { | 383 const TileDrawQuad* quad) { |
| 364 DCHECK(!output_surface_->ForcedDrawToSoftwareDevice()); | 384 DCHECK(!output_surface_->ForcedDrawToSoftwareDevice()); |
| 365 DCHECK(IsSoftwareResource(quad->resource_id)); | 385 DCHECK(IsSoftwareResource(quad->resource_id)); |
| 366 ResourceProvider::ScopedReadLockSoftware lock(resource_provider_, | 386 ResourceProvider::ScopedReadLockSoftware lock(resource_provider_, |
| 367 quad->resource_id); | 387 quad->resource_id); |
| 368 | 388 |
| 369 SkRect uv_rect = gfx::RectFToSkRect(quad->tex_coord_rect); | 389 SkRect uv_rect = gfx::RectFToSkRect(quad->tex_coord_rect); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 visible_ = visible; | 508 visible_ = visible; |
| 489 } | 509 } |
| 490 | 510 |
| 491 void SoftwareRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) { | 511 void SoftwareRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) { |
| 492 // TODO(piman, skaslev): Can we release the backbuffer? We don't currently | 512 // TODO(piman, skaslev): Can we release the backbuffer? We don't currently |
| 493 // receive memory policy yet anyway. | 513 // receive memory policy yet anyway. |
| 494 NOTIMPLEMENTED(); | 514 NOTIMPLEMENTED(); |
| 495 } | 515 } |
| 496 | 516 |
| 497 } // namespace cc | 517 } // namespace cc |
| OLD | NEW |