Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: cc/output/gl_renderer.cc

Issue 596343002: cc: Null-check the result of GrContext::wrapBackendTexture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: null: . Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 GrBackendTextureDesc backend_texture_description; 630 GrBackendTextureDesc backend_texture_description;
631 backend_texture_description.fWidth = source_texture_resource->size().width(); 631 backend_texture_description.fWidth = source_texture_resource->size().width();
632 backend_texture_description.fHeight = 632 backend_texture_description.fHeight =
633 source_texture_resource->size().height(); 633 source_texture_resource->size().height();
634 backend_texture_description.fConfig = kSkia8888_GrPixelConfig; 634 backend_texture_description.fConfig = kSkia8888_GrPixelConfig;
635 backend_texture_description.fTextureHandle = lock.texture_id(); 635 backend_texture_description.fTextureHandle = lock.texture_id();
636 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin; 636 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin;
637 skia::RefPtr<GrTexture> texture = 637 skia::RefPtr<GrTexture> texture =
638 skia::AdoptRef(use_gr_context->context()->wrapBackendTexture( 638 skia::AdoptRef(use_gr_context->context()->wrapBackendTexture(
639 backend_texture_description)); 639 backend_texture_description));
640 if (!texture) {
641 TRACE_EVENT_INSTANT0("cc",
642 "ApplyImageFilter wrap background texture failed",
643 TRACE_EVENT_SCOPE_THREAD);
644 return skia::RefPtr<SkImage>();
645 }
640 646
641 SkImageInfo info = 647 SkImageInfo info =
642 SkImageInfo::MakeN32Premul(source_texture_resource->size().width(), 648 SkImageInfo::MakeN32Premul(source_texture_resource->size().width(),
643 source_texture_resource->size().height()); 649 source_texture_resource->size().height());
644 // Place the platform texture inside an SkBitmap. 650 // Place the platform texture inside an SkBitmap.
645 SkBitmap source; 651 SkBitmap source;
646 source.setInfo(info); 652 source.setInfo(info);
647 skia::RefPtr<SkGrPixelRef> pixel_ref = 653 skia::RefPtr<SkGrPixelRef> pixel_ref =
648 skia::AdoptRef(new SkGrPixelRef(info, texture.get())); 654 skia::AdoptRef(new SkGrPixelRef(info, texture.get()));
649 source.setPixelRef(pixel_ref.get()); 655 source.setPixelRef(pixel_ref.get());
650 656
651 // Create a scratch texture for backing store. 657 // Create a scratch texture for backing store.
652 GrTextureDesc desc; 658 GrTextureDesc desc;
653 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; 659 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
654 desc.fSampleCnt = 0; 660 desc.fSampleCnt = 0;
655 desc.fWidth = source.width(); 661 desc.fWidth = source.width();
656 desc.fHeight = source.height(); 662 desc.fHeight = source.height();
657 desc.fConfig = kSkia8888_GrPixelConfig; 663 desc.fConfig = kSkia8888_GrPixelConfig;
658 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; 664 desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
659 GrAutoScratchTexture scratch_texture( 665 GrAutoScratchTexture scratch_texture(
660 use_gr_context->context(), desc, GrContext::kExact_ScratchTexMatch); 666 use_gr_context->context(), desc, GrContext::kExact_ScratchTexMatch);
661 skia::RefPtr<GrTexture> backing_store = 667 skia::RefPtr<GrTexture> backing_store =
662 skia::AdoptRef(scratch_texture.detach()); 668 skia::AdoptRef(scratch_texture.detach());
663 if (backing_store.get() == NULL) { 669 if (!backing_store) {
664 TRACE_EVENT_INSTANT0("cc", 670 TRACE_EVENT_INSTANT0("cc",
665 "ApplyImageFilter scratch texture allocation failed", 671 "ApplyImageFilter scratch texture allocation failed",
666 TRACE_EVENT_SCOPE_THREAD); 672 TRACE_EVENT_SCOPE_THREAD);
667 return skia::RefPtr<SkImage>(); 673 return skia::RefPtr<SkImage>();
668 } 674 }
669 675
670 // Create surface to draw into. 676 // Create surface to draw into.
671 skia::RefPtr<SkSurface> surface = skia::AdoptRef( 677 skia::RefPtr<SkSurface> surface = skia::AdoptRef(
672 SkSurface::NewRenderTargetDirect(backing_store->asRenderTarget())); 678 SkSurface::NewRenderTargetDirect(backing_store->asRenderTarget()));
673 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); 679 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 GrBackendTextureDesc backend_texture_description; 740 GrBackendTextureDesc backend_texture_description;
735 backend_texture_description.fConfig = kSkia8888_GrPixelConfig; 741 backend_texture_description.fConfig = kSkia8888_GrPixelConfig;
736 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin; 742 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin;
737 743
738 backend_texture_description.fWidth = source_size.width(); 744 backend_texture_description.fWidth = source_size.width();
739 backend_texture_description.fHeight = source_size.height(); 745 backend_texture_description.fHeight = source_size.height();
740 backend_texture_description.fTextureHandle = source_texture_with_filters_id; 746 backend_texture_description.fTextureHandle = source_texture_with_filters_id;
741 skia::RefPtr<GrTexture> source_texture = 747 skia::RefPtr<GrTexture> source_texture =
742 skia::AdoptRef(use_gr_context->context()->wrapBackendTexture( 748 skia::AdoptRef(use_gr_context->context()->wrapBackendTexture(
743 backend_texture_description)); 749 backend_texture_description));
750 if (!source_texture) {
751 TRACE_EVENT_INSTANT0(
752 "cc",
753 "ApplyBlendModeWithBackdrop wrap source texture failed",
754 TRACE_EVENT_SCOPE_THREAD);
755 return skia::RefPtr<SkImage>();
756 }
744 757
745 backend_texture_description.fWidth = background_size.width(); 758 backend_texture_description.fWidth = background_size.width();
746 backend_texture_description.fHeight = background_size.height(); 759 backend_texture_description.fHeight = background_size.height();
747 backend_texture_description.fTextureHandle = lock_background.texture_id(); 760 backend_texture_description.fTextureHandle = lock_background.texture_id();
748 skia::RefPtr<GrTexture> background_texture = 761 skia::RefPtr<GrTexture> background_texture =
749 skia::AdoptRef(use_gr_context->context()->wrapBackendTexture( 762 skia::AdoptRef(use_gr_context->context()->wrapBackendTexture(
750 backend_texture_description)); 763 backend_texture_description));
764 if (!background_texture) {
765 TRACE_EVENT_INSTANT0(
766 "cc",
767 "ApplyBlendModeWithBackdrop wrap background texture failed",
768 TRACE_EVENT_SCOPE_THREAD);
769 return skia::RefPtr<SkImage>();
770 }
751 771
752 SkImageInfo source_info = 772 SkImageInfo source_info =
753 SkImageInfo::MakeN32Premul(source_size.width(), source_size.height()); 773 SkImageInfo::MakeN32Premul(source_size.width(), source_size.height());
754 // Place the platform texture inside an SkBitmap. 774 // Place the platform texture inside an SkBitmap.
755 SkBitmap source; 775 SkBitmap source;
756 source.setInfo(source_info); 776 source.setInfo(source_info);
757 skia::RefPtr<SkGrPixelRef> source_pixel_ref = 777 skia::RefPtr<SkGrPixelRef> source_pixel_ref =
758 skia::AdoptRef(new SkGrPixelRef(source_info, source_texture.get())); 778 skia::AdoptRef(new SkGrPixelRef(source_info, source_texture.get()));
759 source.setPixelRef(source_pixel_ref.get()); 779 source.setPixelRef(source_pixel_ref.get());
760 780
(...skipping 12 matching lines...) Expand all
773 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; 793 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
774 desc.fSampleCnt = 0; 794 desc.fSampleCnt = 0;
775 desc.fWidth = source.width(); 795 desc.fWidth = source.width();
776 desc.fHeight = source.height(); 796 desc.fHeight = source.height();
777 desc.fConfig = kSkia8888_GrPixelConfig; 797 desc.fConfig = kSkia8888_GrPixelConfig;
778 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; 798 desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
779 GrAutoScratchTexture scratch_texture( 799 GrAutoScratchTexture scratch_texture(
780 use_gr_context->context(), desc, GrContext::kExact_ScratchTexMatch); 800 use_gr_context->context(), desc, GrContext::kExact_ScratchTexMatch);
781 skia::RefPtr<GrTexture> backing_store = 801 skia::RefPtr<GrTexture> backing_store =
782 skia::AdoptRef(scratch_texture.detach()); 802 skia::AdoptRef(scratch_texture.detach());
783 if (backing_store.get() == NULL) { 803 if (!backing_store) {
784 TRACE_EVENT_INSTANT0( 804 TRACE_EVENT_INSTANT0(
785 "cc", 805 "cc",
786 "ApplyBlendModeWithBackdrop scratch texture allocation failed", 806 "ApplyBlendModeWithBackdrop scratch texture allocation failed",
787 TRACE_EVENT_SCOPE_THREAD); 807 TRACE_EVENT_SCOPE_THREAD);
788 return source_bitmap_with_filters; 808 return source_bitmap_with_filters;
789 } 809 }
790 810
791 // Create a device and canvas using that backing store. 811 // Create a device and canvas using that backing store.
792 skia::RefPtr<SkSurface> surface = skia::AdoptRef( 812 skia::RefPtr<SkSurface> surface = skia::AdoptRef(
793 SkSurface::NewRenderTargetDirect(backing_store->asRenderTarget())); 813 SkSurface::NewRenderTargetDirect(backing_store->asRenderTarget()));
(...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after
3182 context_support_->ScheduleOverlayPlane( 3202 context_support_->ScheduleOverlayPlane(
3183 overlay.plane_z_order, 3203 overlay.plane_z_order,
3184 overlay.transform, 3204 overlay.transform,
3185 pending_overlay_resources_.back()->texture_id(), 3205 pending_overlay_resources_.back()->texture_id(),
3186 overlay.display_rect, 3206 overlay.display_rect,
3187 overlay.uv_rect); 3207 overlay.uv_rect);
3188 } 3208 }
3189 } 3209 }
3190 3210
3191 } // namespace cc 3211 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698