| 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 "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h" | 5 #include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h" |
| 6 | 6 |
| 7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
| 8 #include "cc/quads/texture_draw_quad.h" | 8 #include "cc/quads/texture_draw_quad.h" |
| 9 #include "gpu/command_buffer/client/gles2_interface.h" | 9 #include "gpu/command_buffer/client/gles2_interface.h" |
| 10 #include "platform/CrossThreadFunctional.h" | 10 #include "platform/CrossThreadFunctional.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 void OffscreenCanvasFrameDispatcherImpl::ReclaimResources( | 371 void OffscreenCanvasFrameDispatcherImpl::ReclaimResources( |
| 372 const cc::ReturnedResourceArray& resources) { | 372 const cc::ReturnedResourceArray& resources) { |
| 373 for (const auto& resource : resources) { | 373 for (const auto& resource : resources) { |
| 374 RefPtr<StaticBitmapImage> image = m_cachedImages.get(resource.id); | 374 RefPtr<StaticBitmapImage> image = m_cachedImages.get(resource.id); |
| 375 if (image) | 375 if (image) |
| 376 image->updateSyncToken(resource.sync_token); | 376 image->updateSyncToken(resource.sync_token); |
| 377 reclaimResource(resource.id); | 377 reclaimResource(resource.id); |
| 378 } | 378 } |
| 379 } | 379 } |
| 380 | 380 |
| 381 void OffscreenCanvasFrameDispatcherImpl::WillDrawSurface() { |
| 382 // TODO(fsamuel, staraz): Implement this. |
| 383 NOTIMPLEMENTED(); |
| 384 } |
| 385 |
| 381 void OffscreenCanvasFrameDispatcherImpl::reclaimResource(unsigned resourceId) { | 386 void OffscreenCanvasFrameDispatcherImpl::reclaimResource(unsigned resourceId) { |
| 382 // An image resource needs to be returned by both the | 387 // An image resource needs to be returned by both the |
| 383 // CompositorFrameSink and the HTMLCanvasElement. These | 388 // CompositorFrameSink and the HTMLCanvasElement. These |
| 384 // events can happen in any order. The first of the two | 389 // events can happen in any order. The first of the two |
| 385 // to return a given resource will result in the spare | 390 // to return a given resource will result in the spare |
| 386 // resource lock being lifted, and the second will delete | 391 // resource lock being lifted, and the second will delete |
| 387 // the resource for real. | 392 // the resource for real. |
| 388 if (m_spareResourceLocks.contains(resourceId)) { | 393 if (m_spareResourceLocks.contains(resourceId)) { |
| 389 m_spareResourceLocks.remove(resourceId); | 394 m_spareResourceLocks.remove(resourceId); |
| 390 return; | 395 return; |
| 391 } | 396 } |
| 392 m_cachedImages.remove(resourceId); | 397 m_cachedImages.remove(resourceId); |
| 393 m_sharedBitmaps.remove(resourceId); | 398 m_sharedBitmaps.remove(resourceId); |
| 394 m_cachedTextureIds.remove(resourceId); | 399 m_cachedTextureIds.remove(resourceId); |
| 395 } | 400 } |
| 396 | 401 |
| 397 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize( | 402 bool OffscreenCanvasFrameDispatcherImpl::verifyImageSize( |
| 398 const IntSize imageSize) { | 403 const IntSize imageSize) { |
| 399 if (imageSize.width() == m_width && imageSize.height() == m_height) | 404 if (imageSize.width() == m_width && imageSize.height() == m_height) |
| 400 return true; | 405 return true; |
| 401 return false; | 406 return false; |
| 402 } | 407 } |
| 403 | 408 |
| 404 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) { | 409 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) { |
| 405 m_width = width; | 410 m_width = width; |
| 406 m_height = height; | 411 m_height = height; |
| 407 } | 412 } |
| 408 | 413 |
| 409 } // namespace blink | 414 } // namespace blink |
| OLD | NEW |