OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/laser/laser_pointer_view.h" | 5 #include "ash/laser/laser_pointer_view.h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #include <GLES2/gl2ext.h> | 8 #include <GLES2/gl2ext.h> |
9 #include <GLES2/gl2extchromium.h> | 9 #include <GLES2/gl2extchromium.h> |
10 | 10 |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 // drawing to the buffer directly this ensures that the buffer is never in a | 564 // drawing to the buffer directly this ensures that the buffer is never in a |
565 // state that would result in flicker. | 565 // state that would result in flicker. |
566 { | 566 { |
567 TRACE_EVENT0("ui", "LaserPointerView::OnPointsUpdated::Copy"); | 567 TRACE_EVENT0("ui", "LaserPointerView::OnPointsUpdated::Copy"); |
568 | 568 |
569 // Convert update rectangle to pixel coordinates. | 569 // Convert update rectangle to pixel coordinates. |
570 gfx::Rect pixel_rect = | 570 gfx::Rect pixel_rect = |
571 gfx::ScaleToEnclosingRect(update_rect, scale_factor_); | 571 gfx::ScaleToEnclosingRect(update_rect, scale_factor_); |
572 uint8_t* data = static_cast<uint8_t*>(gpu_memory_buffer_->memory(0)); | 572 uint8_t* data = static_cast<uint8_t*>(gpu_memory_buffer_->memory(0)); |
573 int stride = gpu_memory_buffer_->stride(0); | 573 int stride = gpu_memory_buffer_->stride(0); |
574 canvas.sk_canvas()->readPixels( | 574 canvas.GetBitmap().readPixels( |
575 SkImageInfo::MakeN32Premul(pixel_rect.width(), pixel_rect.height()), | 575 SkImageInfo::MakeN32Premul(pixel_rect.width(), pixel_rect.height()), |
576 data + pixel_rect.y() * stride + pixel_rect.x() * 4, stride, 0, 0); | 576 data + pixel_rect.y() * stride + pixel_rect.x() * 4, stride, 0, 0); |
577 } | 577 } |
578 | 578 |
579 // Unmap to flush writes to buffer. | 579 // Unmap to flush writes to buffer. |
580 gpu_memory_buffer_->Unmap(); | 580 gpu_memory_buffer_->Unmap(); |
581 | 581 |
582 // Update surface damage rectangle. | 582 // Update surface damage rectangle. |
583 surface_damage_rect_.Union(update_rect); | 583 surface_damage_rect_.Union(update_rect); |
584 | 584 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 pending_draw_surface_ = true; | 723 pending_draw_surface_ = true; |
724 } | 724 } |
725 | 725 |
726 void LaserPointerView::OnDidDrawSurface() { | 726 void LaserPointerView::OnDidDrawSurface() { |
727 pending_draw_surface_ = false; | 727 pending_draw_surface_ = false; |
728 if (needs_update_surface_) | 728 if (needs_update_surface_) |
729 UpdateSurface(); | 729 UpdateSurface(); |
730 } | 730 } |
731 | 731 |
732 } // namespace ash | 732 } // namespace ash |
OLD | NEW |