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

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

Issue 520793002: Use SkSurface and SkImage instead of SkGpuDevice and SkBitmap in cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove #include in resource_provider.cc 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 | cc/resources/resource_provider.cc » ('j') | 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 18 matching lines...) Expand all
29 #include "cc/resources/layer_quad.h" 29 #include "cc/resources/layer_quad.h"
30 #include "cc/resources/scoped_resource.h" 30 #include "cc/resources/scoped_resource.h"
31 #include "cc/resources/texture_mailbox_deleter.h" 31 #include "cc/resources/texture_mailbox_deleter.h"
32 #include "gpu/GLES2/gl2extchromium.h" 32 #include "gpu/GLES2/gl2extchromium.h"
33 #include "gpu/command_buffer/client/context_support.h" 33 #include "gpu/command_buffer/client/context_support.h"
34 #include "gpu/command_buffer/client/gles2_interface.h" 34 #include "gpu/command_buffer/client/gles2_interface.h"
35 #include "gpu/command_buffer/common/gpu_memory_allocation.h" 35 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
36 #include "third_party/skia/include/core/SkBitmap.h" 36 #include "third_party/skia/include/core/SkBitmap.h"
37 #include "third_party/skia/include/core/SkColor.h" 37 #include "third_party/skia/include/core/SkColor.h"
38 #include "third_party/skia/include/core/SkColorFilter.h" 38 #include "third_party/skia/include/core/SkColorFilter.h"
39 #include "third_party/skia/include/core/SkImage.h"
39 #include "third_party/skia/include/core/SkSurface.h" 40 #include "third_party/skia/include/core/SkSurface.h"
40 #include "third_party/skia/include/gpu/GrContext.h" 41 #include "third_party/skia/include/gpu/GrContext.h"
41 #include "third_party/skia/include/gpu/GrTexture.h" 42 #include "third_party/skia/include/gpu/GrTexture.h"
42 #include "third_party/skia/include/gpu/SkGpuDevice.h"
43 #include "third_party/skia/include/gpu/SkGrTexturePixelRef.h" 43 #include "third_party/skia/include/gpu/SkGrTexturePixelRef.h"
44 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" 44 #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
45 #include "ui/gfx/geometry/quad_f.h" 45 #include "ui/gfx/geometry/quad_f.h"
46 #include "ui/gfx/geometry/rect_conversions.h" 46 #include "ui/gfx/geometry/rect_conversions.h"
47 47
48 using gpu::gles2::GLES2Interface; 48 using gpu::gles2::GLES2Interface;
49 49
50 namespace cc { 50 namespace cc {
51 namespace { 51 namespace {
52 52
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, 603 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha,
604 alpha)); 604 alpha));
605 605
606 GLC(gl_, gl_->LineWidth(quad->width)); 606 GLC(gl_, gl_->LineWidth(quad->width));
607 607
608 // The indices for the line are stored in the same array as the triangle 608 // The indices for the line are stored in the same array as the triangle
609 // indices. 609 // indices.
610 GLC(gl_, gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0)); 610 GLC(gl_, gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0));
611 } 611 }
612 612
613 static SkBitmap ApplyImageFilter( 613 static SkImage* ApplyImageFilter(
614 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, 614 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context,
615 ResourceProvider* resource_provider, 615 ResourceProvider* resource_provider,
616 const gfx::Point& origin, 616 const gfx::Point& origin,
617 const gfx::Vector2dF& scale, 617 const gfx::Vector2dF& scale,
618 SkImageFilter* filter, 618 SkImageFilter* filter,
619 ScopedResource* source_texture_resource) { 619 ScopedResource* source_texture_resource) {
620 if (!filter) 620 if (!filter)
621 return SkBitmap(); 621 return NULL;
622 622
623 if (!use_gr_context) 623 if (!use_gr_context)
624 return SkBitmap(); 624 return NULL;
625 625
626 ResourceProvider::ScopedReadLockGL lock(resource_provider, 626 ResourceProvider::ScopedReadLockGL lock(resource_provider,
627 source_texture_resource->id()); 627 source_texture_resource->id());
628 628
629 // Wrap the source texture in a Ganesh platform texture. 629 // Wrap the source texture in a Ganesh platform texture.
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;
(...skipping 22 matching lines...) Expand all
657 desc.fConfig = kSkia8888_GrPixelConfig; 657 desc.fConfig = kSkia8888_GrPixelConfig;
658 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; 658 desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
659 GrAutoScratchTexture scratch_texture( 659 GrAutoScratchTexture scratch_texture(
660 use_gr_context->context(), desc, GrContext::kExact_ScratchTexMatch); 660 use_gr_context->context(), desc, GrContext::kExact_ScratchTexMatch);
661 skia::RefPtr<GrTexture> backing_store = 661 skia::RefPtr<GrTexture> backing_store =
662 skia::AdoptRef(scratch_texture.detach()); 662 skia::AdoptRef(scratch_texture.detach());
663 if (backing_store.get() == NULL) { 663 if (backing_store.get() == NULL) {
664 TRACE_EVENT_INSTANT0("cc", 664 TRACE_EVENT_INSTANT0("cc",
665 "ApplyImageFilter scratch texture allocation failed", 665 "ApplyImageFilter scratch texture allocation failed",
666 TRACE_EVENT_SCOPE_THREAD); 666 TRACE_EVENT_SCOPE_THREAD);
667 return SkBitmap(); 667 return NULL;
668 } 668 }
669 669
670 // Create a device and canvas using that backing store. 670 // Create surface to draw into.
671 skia::RefPtr<SkGpuDevice> device = 671 skia::RefPtr<SkSurface> surface = skia::AdoptRef(
672 skia::AdoptRef(SkGpuDevice::Create(backing_store->asRenderTarget())); 672 SkSurface::NewRenderTargetDirect(backing_store->asRenderTarget()));
673 DCHECK(device.get()); 673 SkCanvas* canvas = surface->getCanvas();
674 SkCanvas canvas(device.get());
675 674
676 // Draw the source bitmap through the filter to the canvas. 675 // Draw the source bitmap through the filter to the canvas.
677 SkPaint paint; 676 SkPaint paint;
678 paint.setImageFilter(filter); 677 paint.setImageFilter(filter);
679 canvas.clear(SK_ColorTRANSPARENT); 678 canvas->clear(SK_ColorTRANSPARENT);
680 679
681 canvas.translate(SkIntToScalar(-origin.x()), SkIntToScalar(-origin.y())); 680 canvas->translate(SkIntToScalar(-origin.x()), SkIntToScalar(-origin.y()));
682 canvas.scale(scale.x(), scale.y()); 681 canvas->scale(scale.x(), scale.y());
683 canvas.drawSprite(source, 0, 0, &paint); 682 canvas->drawSprite(source, 0, 0, &paint);
683
684 SkImage* image = surface->newImageSnapshot();
684 685
685 // Flush the GrContext to ensure all buffered GL calls are drawn to the 686 // Flush the GrContext to ensure all buffered GL calls are drawn to the
686 // backing store before we access and return it, and have cc begin using the 687 // backing store before we access and return it, and have cc begin using the
687 // GL context again. 688 // GL context again.
688 use_gr_context->context()->flush(); 689 canvas->flush();
689 690
690 return device->accessBitmap(false); 691 return image;
691 } 692 }
692 693
693 static SkBitmap ApplyBlendModeWithBackdrop( 694 static SkImage* ApplyBlendModeWithBackdrop(
694 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, 695 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context,
695 ResourceProvider* resource_provider, 696 ResourceProvider* resource_provider,
696 SkBitmap source_bitmap_with_filters, 697 SkImage* source_bitmap_with_filters,
697 ScopedResource* source_texture_resource, 698 ScopedResource* source_texture_resource,
698 ScopedResource* background_texture_resource, 699 ScopedResource* background_texture_resource,
699 SkXfermode::Mode blend_mode) { 700 SkXfermode::Mode blend_mode) {
700 if (!use_gr_context) 701 if (!use_gr_context)
701 return source_bitmap_with_filters; 702 return source_bitmap_with_filters;
702 703
703 DCHECK(background_texture_resource); 704 DCHECK(background_texture_resource);
704 DCHECK(source_texture_resource); 705 DCHECK(source_texture_resource);
705 706
706 gfx::Size source_size = source_texture_resource->size(); 707 gfx::Size source_size = source_texture_resource->size();
707 gfx::Size background_size = background_texture_resource->size(); 708 gfx::Size background_size = background_texture_resource->size();
708 709
709 DCHECK_LE(background_size.width(), source_size.width()); 710 DCHECK_LE(background_size.width(), source_size.width());
710 DCHECK_LE(background_size.height(), source_size.height()); 711 DCHECK_LE(background_size.height(), source_size.height());
711 712
712 int source_texture_with_filters_id; 713 int source_texture_with_filters_id;
713 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock; 714 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock;
714 if (source_bitmap_with_filters.getTexture()) { 715 if (source_bitmap_with_filters) {
715 DCHECK_EQ(source_size.width(), source_bitmap_with_filters.width()); 716 DCHECK_EQ(source_size.width(), source_bitmap_with_filters->width());
716 DCHECK_EQ(source_size.height(), source_bitmap_with_filters.height()); 717 DCHECK_EQ(source_size.height(), source_bitmap_with_filters->height());
717 GrTexture* texture = 718 GrTexture* texture =
718 reinterpret_cast<GrTexture*>(source_bitmap_with_filters.getTexture()); 719 reinterpret_cast<GrTexture*>(source_bitmap_with_filters->getTexture());
719 source_texture_with_filters_id = texture->getTextureHandle(); 720 source_texture_with_filters_id = texture->getTextureHandle();
720 } else { 721 } else {
721 lock.reset(new ResourceProvider::ScopedReadLockGL( 722 lock.reset(new ResourceProvider::ScopedReadLockGL(
722 resource_provider, source_texture_resource->id())); 723 resource_provider, source_texture_resource->id()));
723 source_texture_with_filters_id = lock->texture_id(); 724 source_texture_with_filters_id = lock->texture_id();
724 } 725 }
725 726
726 ResourceProvider::ScopedReadLockGL lock_background( 727 ResourceProvider::ScopedReadLockGL lock_background(
727 resource_provider, background_texture_resource->id()); 728 resource_provider, background_texture_resource->id());
728 729
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 skia::AdoptRef(scratch_texture.detach()); 779 skia::AdoptRef(scratch_texture.detach());
779 if (backing_store.get() == NULL) { 780 if (backing_store.get() == NULL) {
780 TRACE_EVENT_INSTANT0( 781 TRACE_EVENT_INSTANT0(
781 "cc", 782 "cc",
782 "ApplyBlendModeWithBackdrop scratch texture allocation failed", 783 "ApplyBlendModeWithBackdrop scratch texture allocation failed",
783 TRACE_EVENT_SCOPE_THREAD); 784 TRACE_EVENT_SCOPE_THREAD);
784 return source_bitmap_with_filters; 785 return source_bitmap_with_filters;
785 } 786 }
786 787
787 // Create a device and canvas using that backing store. 788 // Create a device and canvas using that backing store.
788 skia::RefPtr<SkGpuDevice> device = 789 skia::RefPtr<SkSurface> surface = skia::AdoptRef(
789 skia::AdoptRef(SkGpuDevice::Create(backing_store->asRenderTarget())); 790 SkSurface::NewRenderTargetDirect(backing_store->asRenderTarget()));
790 DCHECK(device.get()); 791 if (!surface)
791 SkCanvas canvas(device.get()); 792 return NULL;
793 SkCanvas* canvas = surface->getCanvas();
792 794
793 // Draw the source bitmap through the filter to the canvas. 795 // Draw the source bitmap through the filter to the canvas.
794 canvas.clear(SK_ColorTRANSPARENT); 796 canvas->clear(SK_ColorTRANSPARENT);
795 canvas.drawSprite(background, 0, 0); 797 canvas->drawSprite(background, 0, 0);
796 SkPaint paint; 798 SkPaint paint;
797 paint.setXfermodeMode(blend_mode); 799 paint.setXfermodeMode(blend_mode);
798 canvas.drawSprite(source, 0, 0, &paint); 800 canvas->drawSprite(source, 0, 0, &paint);
799 801
802 SkImage* image = surface->newImageSnapshot();
enne (OOO) 2014/08/29 19:05:40 After fixing numerous memory leaks, I'm a little a
bsalomon 2014/08/29 20:47:33 I tried in the new patch. I've never used these be
enne (OOO) 2014/08/29 21:20:21 Thanks. Those usages look right to me, based on w
800 // Flush the GrContext to ensure all buffered GL calls are drawn to the 803 // Flush the GrContext to ensure all buffered GL calls are drawn to the
801 // backing store before we access and return it, and have cc begin using the 804 // backing store before we access and return it, and have cc begin using the
802 // GL context again. 805 // GL context again.
803 use_gr_context->context()->flush(); 806 canvas->flush();
804 807
805 return device->accessBitmap(false); 808 return image;
806 } 809 }
807 810
808 scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters( 811 scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters(
809 DrawingFrame* frame, 812 DrawingFrame* frame,
810 const RenderPassDrawQuad* quad, 813 const RenderPassDrawQuad* quad,
811 const gfx::Transform& contents_device_transform, 814 const gfx::Transform& contents_device_transform,
812 const gfx::Transform& contents_device_transform_inverse, 815 const gfx::Transform& contents_device_transform_inverse,
813 bool* background_changed) { 816 bool* background_changed) {
814 // This method draws a background filter, which applies a filter to any pixels 817 // This method draws a background filter, which applies a filter to any pixels
815 // behind the quad and seen through its background. The algorithm works as 818 // behind the quad and seen through its background. The algorithm works as
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 { 869 {
867 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, 870 ResourceProvider::ScopedWriteLockGL lock(resource_provider_,
868 device_background_texture->id()); 871 device_background_texture->id());
869 GetFramebufferTexture( 872 GetFramebufferTexture(
870 lock.texture_id(), device_background_texture->format(), window_rect); 873 lock.texture_id(), device_background_texture->format(), window_rect);
871 } 874 }
872 875
873 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( 876 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
874 quad->background_filters, device_background_texture->size()); 877 quad->background_filters, device_background_texture->size());
875 878
876 SkBitmap filtered_device_background; 879 skia::RefPtr<SkImage> filtered_device_background;
877 if (apply_background_filters) { 880 if (apply_background_filters) {
878 filtered_device_background = 881 filtered_device_background =
879 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), 882 skia::AdoptRef(ApplyImageFilter(ScopedUseGrContext::Create(this, frame),
880 resource_provider_, 883 resource_provider_,
881 quad->rect.origin(), 884 quad->rect.origin(),
882 quad->filters_scale, 885 quad->filters_scale,
883 filter.get(), 886 filter.get(),
884 device_background_texture.get()); 887 device_background_texture.get()));
885 } 888 }
886 *background_changed = (filtered_device_background.getTexture() != NULL); 889 *background_changed = (filtered_device_background != NULL);
887 890
888 int filtered_device_background_texture_id = 0; 891 int filtered_device_background_texture_id = 0;
889 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock; 892 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock;
890 if (filtered_device_background.getTexture()) { 893 if (filtered_device_background) {
891 GrTexture* texture = 894 GrTexture* texture = filtered_device_background->getTexture();
892 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture());
893 filtered_device_background_texture_id = texture->getTextureHandle(); 895 filtered_device_background_texture_id = texture->getTextureHandle();
894 } else { 896 } else {
895 lock.reset(new ResourceProvider::ScopedReadLockGL( 897 lock.reset(new ResourceProvider::ScopedReadLockGL(
896 resource_provider_, device_background_texture->id())); 898 resource_provider_, device_background_texture->id()));
897 filtered_device_background_texture_id = lock->texture_id(); 899 filtered_device_background_texture_id = lock->texture_id();
898 } 900 }
899 901
900 scoped_ptr<ScopedResource> background_texture = 902 scoped_ptr<ScopedResource> background_texture =
901 ScopedResource::Create(resource_provider_); 903 ScopedResource::Create(resource_provider_);
902 background_texture->Allocate( 904 background_texture->Allocate(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 contents_device_transform, 983 contents_device_transform,
982 contents_device_transform_inverse, 984 contents_device_transform_inverse,
983 &background_changed); 985 &background_changed);
984 986
985 if (disable_blending) 987 if (disable_blending)
986 SetBlendEnabled(true); 988 SetBlendEnabled(true);
987 } 989 }
988 990
989 // TODO(senorblanco): Cache this value so that we don't have to do it for both 991 // TODO(senorblanco): Cache this value so that we don't have to do it for both
990 // the surface and its replica. Apply filters to the contents texture. 992 // the surface and its replica. Apply filters to the contents texture.
991 SkBitmap filter_bitmap; 993 skia::RefPtr<SkImage> filter_bitmap;
992 SkScalar color_matrix[20]; 994 SkScalar color_matrix[20];
993 bool use_color_matrix = false; 995 bool use_color_matrix = false;
994 if (!quad->filters.IsEmpty()) { 996 if (!quad->filters.IsEmpty()) {
995 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( 997 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
996 quad->filters, contents_texture->size()); 998 quad->filters, contents_texture->size());
997 if (filter) { 999 if (filter) {
998 skia::RefPtr<SkColorFilter> cf; 1000 skia::RefPtr<SkColorFilter> cf;
999 1001
1000 { 1002 {
1001 SkColorFilter* colorfilter_rawptr = NULL; 1003 SkColorFilter* colorfilter_rawptr = NULL;
1002 filter->asColorFilter(&colorfilter_rawptr); 1004 filter->asColorFilter(&colorfilter_rawptr);
1003 cf = skia::AdoptRef(colorfilter_rawptr); 1005 cf = skia::AdoptRef(colorfilter_rawptr);
1004 } 1006 }
1005 1007
1006 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { 1008 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) {
1007 // We have a single color matrix as a filter; apply it locally 1009 // We have a single color matrix as a filter; apply it locally
1008 // in the compositor. 1010 // in the compositor.
1009 use_color_matrix = true; 1011 use_color_matrix = true;
1010 } else { 1012 } else {
1011 filter_bitmap = 1013 filter_bitmap = skia::AdoptRef(
1012 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), 1014 ApplyImageFilter(ScopedUseGrContext::Create(this, frame),
1013 resource_provider_, 1015 resource_provider_,
1014 quad->rect.origin(), 1016 quad->rect.origin(),
1015 quad->filters_scale, 1017 quad->filters_scale,
1016 filter.get(), 1018 filter.get(),
1017 contents_texture); 1019 contents_texture));
1018 } 1020 }
1019 } 1021 }
1020 } 1022 }
1021 1023
1022 if (quad->shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode && 1024 if (quad->shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode &&
1023 background_texture) { 1025 background_texture) {
1024 filter_bitmap = 1026 filter_bitmap = skia::AdoptRef(
1025 ApplyBlendModeWithBackdrop(ScopedUseGrContext::Create(this, frame), 1027 ApplyBlendModeWithBackdrop(ScopedUseGrContext::Create(this, frame),
1026 resource_provider_, 1028 resource_provider_,
1027 filter_bitmap, 1029 filter_bitmap.get(),
1028 contents_texture, 1030 contents_texture,
1029 background_texture.get(), 1031 background_texture.get(),
1030 quad->shared_quad_state->blend_mode); 1032 quad->shared_quad_state->blend_mode));
1031 } 1033 }
1032 1034
1033 // Draw the background texture if it has some filters applied. 1035 // Draw the background texture if it has some filters applied.
1034 if (background_texture && background_changed) { 1036 if (background_texture && background_changed) {
1035 DCHECK(background_texture->size() == quad->rect.size()); 1037 DCHECK(background_texture->size() == quad->rect.size());
1036 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 1038 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
1037 background_texture->id()); 1039 background_texture->id());
1038 1040
1039 // The background_texture is oriented the same as the frame buffer. The 1041 // The background_texture is oriented the same as the frame buffer. The
1040 // transform we are copying with has a vertical flip, so flip the contents 1042 // transform we are copying with has a vertical flip, so flip the contents
(...skipping 28 matching lines...) Expand all
1069 if (quad->mask_resource_id) { 1071 if (quad->mask_resource_id) {
1070 mask_resource_lock.reset(new ResourceProvider::ScopedReadLockGL( 1072 mask_resource_lock.reset(new ResourceProvider::ScopedReadLockGL(
1071 resource_provider_, quad->mask_resource_id)); 1073 resource_provider_, quad->mask_resource_id));
1072 mask_texture_id = mask_resource_lock->texture_id(); 1074 mask_texture_id = mask_resource_lock->texture_id();
1073 } 1075 }
1074 1076
1075 // TODO(danakj): use the background_texture and blend the background in with 1077 // TODO(danakj): use the background_texture and blend the background in with
1076 // this draw instead of having a separate copy of the background texture. 1078 // this draw instead of having a separate copy of the background texture.
1077 1079
1078 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock; 1080 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock;
1079 if (filter_bitmap.getTexture()) { 1081 if (filter_bitmap) {
1080 GrTexture* texture = 1082 GrTexture* texture = filter_bitmap->getTexture();
1081 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture());
1082 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 1083 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
1083 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); 1084 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle());
1084 } else { 1085 } else {
1085 contents_resource_lock = 1086 contents_resource_lock =
1086 make_scoped_ptr(new ResourceProvider::ScopedSamplerGL( 1087 make_scoped_ptr(new ResourceProvider::ScopedSamplerGL(
1087 resource_provider_, contents_texture->id(), GL_LINEAR)); 1088 resource_provider_, contents_texture->id(), GL_LINEAR));
1088 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), 1089 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
1089 contents_resource_lock->target()); 1090 contents_resource_lock->target());
1090 } 1091 }
1091 1092
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 device_layer_edges.ToQuadF(), 1327 device_layer_edges.ToQuadF(),
1327 &clipped); 1328 &clipped);
1328 1329
1329 SetShaderOpacity(quad->opacity(), shader_alpha_location); 1330 SetShaderOpacity(quad->opacity(), shader_alpha_location);
1330 SetShaderQuadF(surface_quad, shader_quad_location); 1331 SetShaderQuadF(surface_quad, shader_quad_location);
1331 DrawQuadGeometry( 1332 DrawQuadGeometry(
1332 frame, quad->quadTransform(), quad->rect, shader_matrix_location); 1333 frame, quad->quadTransform(), quad->rect, shader_matrix_location);
1333 1334
1334 // Flush the compositor context before the filter bitmap goes out of 1335 // Flush the compositor context before the filter bitmap goes out of
1335 // scope, so the draw gets processed before the filter texture gets deleted. 1336 // scope, so the draw gets processed before the filter texture gets deleted.
1336 if (filter_bitmap.getTexture()) 1337 if (filter_bitmap)
1337 GLC(gl_, gl_->Flush()); 1338 GLC(gl_, gl_->Flush());
1338 } 1339 }
1339 1340
1340 struct SolidColorProgramUniforms { 1341 struct SolidColorProgramUniforms {
1341 unsigned program; 1342 unsigned program;
1342 unsigned matrix_location; 1343 unsigned matrix_location;
1343 unsigned viewport_location; 1344 unsigned viewport_location;
1344 unsigned quad_location; 1345 unsigned quad_location;
1345 unsigned edge_location; 1346 unsigned edge_location;
1346 unsigned color_location; 1347 unsigned color_location;
(...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after
3174 context_support_->ScheduleOverlayPlane( 3175 context_support_->ScheduleOverlayPlane(
3175 overlay.plane_z_order, 3176 overlay.plane_z_order,
3176 overlay.transform, 3177 overlay.transform,
3177 pending_overlay_resources_.back()->texture_id(), 3178 pending_overlay_resources_.back()->texture_id(),
3178 overlay.display_rect, 3179 overlay.display_rect,
3179 overlay.uv_rect); 3180 overlay.uv_rect);
3180 } 3181 }
3181 } 3182 }
3182 3183
3183 } // namespace cc 3184 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698