OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 // Using accelerated 2d canvas with software renderer, which | 596 // Using accelerated 2d canvas with software renderer, which |
597 // should only happen in tests that use fake graphics contexts | 597 // should only happen in tests that use fake graphics contexts |
598 // or in Android WebView in software mode. In this case, we do | 598 // or in Android WebView in software mode. In this case, we do |
599 // not care about producing any results for this canvas. | 599 // not care about producing any results for this canvas. |
600 skipQueuedDrawCommands(); | 600 skipQueuedDrawCommands(); |
601 m_lastImageId = 0; | 601 m_lastImageId = 0; |
602 return false; | 602 return false; |
603 } | 603 } |
604 | 604 |
605 RefPtr<SkImage> image = newImageSnapshot(PreferAcceleration); | 605 RefPtr<SkImage> image = newImageSnapshot(PreferAcceleration); |
606 if (!image) | 606 if (!image || !image->getTexture()) |
607 return false; | 607 return false; |
608 | 608 |
609 WebGraphicsContext3D* webContext = context(); | 609 WebGraphicsContext3D* webContext = context(); |
610 | 610 |
611 // Early exit if canvas was not drawn to since last prepareMailbox | 611 // Early exit if canvas was not drawn to since last prepareMailbox |
612 GLenum filter = m_filterQuality == kNone_SkFilterQuality ? GL_NEAREST : GL_L
INEAR; | 612 GLenum filter = m_filterQuality == kNone_SkFilterQuality ? GL_NEAREST : GL_L
INEAR; |
613 if (image->uniqueID() == m_lastImageId && filter == m_lastFilter) | 613 if (image->uniqueID() == m_lastImageId && filter == m_lastFilter) |
614 return false; | 614 return false; |
615 m_lastImageId = image->uniqueID(); | 615 m_lastImageId = image->uniqueID(); |
616 m_lastFilter = filter; | 616 m_lastFilter = filter; |
(...skipping 11 matching lines...) Expand all Loading... |
628 GrContext* grContext = m_contextProvider->grContext(); | 628 GrContext* grContext = m_contextProvider->grContext(); |
629 if (!grContext) | 629 if (!grContext) |
630 return true; // for testing: skip gl stuff when using a mock graphics co
ntext. | 630 return true; // for testing: skip gl stuff when using a mock graphics co
ntext. |
631 | 631 |
632 if (RuntimeEnabledFeatures::forceDisable2dCanvasCopyOnWriteEnabled()) | 632 if (RuntimeEnabledFeatures::forceDisable2dCanvasCopyOnWriteEnabled()) |
633 m_surface->notifyContentWillChange(SkSurface::kRetain_ContentChangeMode)
; | 633 m_surface->notifyContentWillChange(SkSurface::kRetain_ContentChangeMode)
; |
634 | 634 |
635 // Need to flush skia's internal queue because texture is about to be access
ed directly | 635 // Need to flush skia's internal queue because texture is about to be access
ed directly |
636 grContext->flush(); | 636 grContext->flush(); |
637 | 637 |
638 ASSERT(image->getTexture()); | |
639 | |
640 // Because of texture sharing with the compositor, we must invalidate | 638 // Because of texture sharing with the compositor, we must invalidate |
641 // the state cached in skia so that the deferred copy on write | 639 // the state cached in skia so that the deferred copy on write |
642 // in SkSurface_Gpu does not make any false assumptions. | 640 // in SkSurface_Gpu does not make any false assumptions. |
643 mailboxInfo.m_image->getTexture()->textureParamsModified(); | 641 mailboxInfo.m_image->getTexture()->textureParamsModified(); |
644 | 642 |
645 webContext->bindTexture(GL_TEXTURE_2D, mailboxInfo.m_image->getTexture()->ge
tTextureHandle()); | 643 webContext->bindTexture(GL_TEXTURE_2D, mailboxInfo.m_image->getTexture()->ge
tTextureHandle()); |
646 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); | 644 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); |
647 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); | 645 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); |
648 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE
); | 646 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE
); |
649 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE
); | 647 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE
); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 m_image = other.m_image; | 823 m_image = other.m_image; |
826 m_parentLayerBridge = other.m_parentLayerBridge; | 824 m_parentLayerBridge = other.m_parentLayerBridge; |
827 } | 825 } |
828 | 826 |
829 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) | 827 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) |
830 { | 828 { |
831 blink::Platform::current()->histogramEnumeration("Canvas.HibernationEvents",
event, HibernationEventCount); | 829 blink::Platform::current()->histogramEnumeration("Canvas.HibernationEvents",
event, HibernationEventCount); |
832 } | 830 } |
833 | 831 |
834 } // namespace blink | 832 } // namespace blink |
OLD | NEW |