OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 3802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3813 AutoLockUIResourceBitmap bitmap_lock(bitmap); | 3813 AutoLockUIResourceBitmap bitmap_lock(bitmap); |
3814 SkBitmap source_bitmap; | 3814 SkBitmap source_bitmap; |
3815 source_bitmap.setInfo(info, row_bytes); | 3815 source_bitmap.setInfo(info, row_bytes); |
3816 source_bitmap.setPixels(const_cast<uint8_t*>(bitmap_lock.GetPixels())); | 3816 source_bitmap.setPixels(const_cast<uint8_t*>(bitmap_lock.GetPixels())); |
3817 | 3817 |
3818 // This applies the scale to draw the |bitmap| into |scaled_bitmap|. | 3818 // This applies the scale to draw the |bitmap| into |scaled_bitmap|. |
3819 SkBitmap scaled_bitmap; | 3819 SkBitmap scaled_bitmap; |
3820 scaled_bitmap.allocN32Pixels(upload_size.width(), upload_size.height()); | 3820 scaled_bitmap.allocN32Pixels(upload_size.width(), upload_size.height()); |
3821 SkCanvas scaled_canvas(scaled_bitmap); | 3821 SkCanvas scaled_canvas(scaled_bitmap); |
3822 scaled_canvas.scale(canvas_scale_x, canvas_scale_y); | 3822 scaled_canvas.scale(canvas_scale_x, canvas_scale_y); |
| 3823 // The |canvas_scale_x| and |canvas_scale_y| may have some floating point |
| 3824 // error for large enough values, causing pixels on the edge to be not |
| 3825 // fully filled by drawBitmap(), so we ensure they start empty. (See |
| 3826 // crbug.com/642011 for an example.) |
| 3827 scaled_canvas.clear(SK_ColorTRANSPARENT); |
3823 scaled_canvas.drawBitmap(source_bitmap, 0, 0); | 3828 scaled_canvas.drawBitmap(source_bitmap, 0, 0); |
3824 | 3829 |
3825 SkAutoLockPixels scaled_bitmap_lock(scaled_bitmap); | 3830 SkAutoLockPixels scaled_bitmap_lock(scaled_bitmap); |
3826 auto* pixels = static_cast<uint8_t*>(scaled_bitmap.getPixels()); | 3831 auto* pixels = static_cast<uint8_t*>(scaled_bitmap.getPixels()); |
3827 resource_provider_->CopyToResource(id, pixels, upload_size); | 3832 resource_provider_->CopyToResource(id, pixels, upload_size); |
3828 } | 3833 } |
3829 | 3834 |
3830 UIResourceData data; | 3835 UIResourceData data; |
3831 data.resource_id = id; | 3836 data.resource_id = id; |
3832 data.opaque = bitmap.GetOpaque(); | 3837 data.opaque = bitmap.GetOpaque(); |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4183 return task_runner_provider_->HasImplThread(); | 4188 return task_runner_provider_->HasImplThread(); |
4184 } | 4189 } |
4185 | 4190 |
4186 bool LayerTreeHostImpl::CommitToActiveTree() const { | 4191 bool LayerTreeHostImpl::CommitToActiveTree() const { |
4187 // In single threaded mode we skip the pending tree and commit directly to the | 4192 // In single threaded mode we skip the pending tree and commit directly to the |
4188 // active tree. | 4193 // active tree. |
4189 return !task_runner_provider_->HasImplThread(); | 4194 return !task_runner_provider_->HasImplThread(); |
4190 } | 4195 } |
4191 | 4196 |
4192 } // namespace cc | 4197 } // namespace cc |
OLD | NEW |