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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 if (quad->mask_resource_id) { | 511 if (quad->mask_resource_id) { |
512 ResourceProvider::ScopedReadLockSoftware mask_lock(resource_provider_, | 512 ResourceProvider::ScopedReadLockSoftware mask_lock(resource_provider_, |
513 quad->mask_resource_id); | 513 quad->mask_resource_id); |
514 if (!lock.valid()) | 514 if (!lock.valid()) |
515 return; | 515 return; |
516 SkShader::TileMode mask_tile_mode = WrapModeToTileMode( | 516 SkShader::TileMode mask_tile_mode = WrapModeToTileMode( |
517 mask_lock.wrap_mode()); | 517 mask_lock.wrap_mode()); |
518 | 518 |
519 const SkBitmap* mask = mask_lock.sk_bitmap(); | 519 const SkBitmap* mask = mask_lock.sk_bitmap(); |
520 | 520 |
521 SkRect mask_rect = SkRect::MakeXYWH( | 521 // Scale normalized uv rect into absolute texel coordinates. |
522 quad->mask_uv_rect.x() * mask->width(), | 522 SkRect mask_rect = |
523 quad->mask_uv_rect.y() * mask->height(), | 523 gfx::RectFToSkRect(gfx::ScaleRect(quad->MaskUVRect(), |
524 quad->mask_uv_rect.width() * mask->width(), | 524 quad->mask_texture_size.width(), |
525 quad->mask_uv_rect.height() * mask->height()); | 525 quad->mask_texture_size.height())); |
526 | 526 |
527 SkMatrix mask_mat; | 527 SkMatrix mask_mat; |
528 mask_mat.setRectToRect(mask_rect, dest_rect, SkMatrix::kFill_ScaleToFit); | 528 mask_mat.setRectToRect(mask_rect, dest_rect, SkMatrix::kFill_ScaleToFit); |
529 | 529 |
530 skia::RefPtr<SkShader> mask_shader = | 530 skia::RefPtr<SkShader> mask_shader = |
531 skia::AdoptRef(SkShader::CreateBitmapShader( | 531 skia::AdoptRef(SkShader::CreateBitmapShader( |
532 *mask, mask_tile_mode, mask_tile_mode, &mask_mat)); | 532 *mask, mask_tile_mode, mask_tile_mode, &mask_mat)); |
533 | 533 |
534 SkPaint mask_paint; | 534 SkPaint mask_paint; |
535 mask_paint.setShader(mask_shader.get()); | 535 mask_paint.setShader(mask_shader.get()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 } | 598 } |
599 | 599 |
600 void SoftwareRenderer::DidChangeVisibility() { | 600 void SoftwareRenderer::DidChangeVisibility() { |
601 if (visible()) | 601 if (visible()) |
602 EnsureBackbuffer(); | 602 EnsureBackbuffer(); |
603 else | 603 else |
604 DiscardBackbuffer(); | 604 DiscardBackbuffer(); |
605 } | 605 } |
606 | 606 |
607 } // namespace cc | 607 } // namespace cc |
OLD | NEW |