| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 skia::RefPtr<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 skia::RefPtr<SkImage>(); |
| 622 | 622 |
| 623 if (!use_gr_context) | 623 if (!use_gr_context) |
| 624 return SkBitmap(); | 624 return skia::RefPtr<SkImage>(); |
| 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 Loading... |
| 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 skia::RefPtr<SkImage>(); |
| 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 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(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 skia::RefPtr<SkImage> image = skia::AdoptRef(surface->newImageSnapshot()); |
| 685 if (!image || !image->getTexture()) { |
| 686 return skia::RefPtr<SkImage>(); |
| 687 } |
| 684 | 688 |
| 685 // Flush the GrContext to ensure all buffered GL calls are drawn to the | 689 // 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 | 690 // backing store before we access and return it, and have cc begin using the |
| 687 // GL context again. | 691 // GL context again. |
| 688 use_gr_context->context()->flush(); | 692 canvas->flush(); |
| 689 | 693 |
| 690 return device->accessBitmap(false); | 694 return image; |
| 691 } | 695 } |
| 692 | 696 |
| 693 static SkBitmap ApplyBlendModeWithBackdrop( | 697 static skia::RefPtr<SkImage> ApplyBlendModeWithBackdrop( |
| 694 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, | 698 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, |
| 695 ResourceProvider* resource_provider, | 699 ResourceProvider* resource_provider, |
| 696 SkBitmap source_bitmap_with_filters, | 700 skia::RefPtr<SkImage> source_bitmap_with_filters, |
| 697 ScopedResource* source_texture_resource, | 701 ScopedResource* source_texture_resource, |
| 698 ScopedResource* background_texture_resource, | 702 ScopedResource* background_texture_resource, |
| 699 SkXfermode::Mode blend_mode) { | 703 SkXfermode::Mode blend_mode) { |
| 700 if (!use_gr_context) | 704 if (!use_gr_context) |
| 701 return source_bitmap_with_filters; | 705 return source_bitmap_with_filters; |
| 702 | 706 |
| 703 DCHECK(background_texture_resource); | 707 DCHECK(background_texture_resource); |
| 704 DCHECK(source_texture_resource); | 708 DCHECK(source_texture_resource); |
| 705 | 709 |
| 706 gfx::Size source_size = source_texture_resource->size(); | 710 gfx::Size source_size = source_texture_resource->size(); |
| 707 gfx::Size background_size = background_texture_resource->size(); | 711 gfx::Size background_size = background_texture_resource->size(); |
| 708 | 712 |
| 709 DCHECK_LE(background_size.width(), source_size.width()); | 713 DCHECK_LE(background_size.width(), source_size.width()); |
| 710 DCHECK_LE(background_size.height(), source_size.height()); | 714 DCHECK_LE(background_size.height(), source_size.height()); |
| 711 | 715 |
| 712 int source_texture_with_filters_id; | 716 int source_texture_with_filters_id; |
| 713 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock; | 717 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock; |
| 714 if (source_bitmap_with_filters.getTexture()) { | 718 if (source_bitmap_with_filters) { |
| 715 DCHECK_EQ(source_size.width(), source_bitmap_with_filters.width()); | 719 DCHECK_EQ(source_size.width(), source_bitmap_with_filters->width()); |
| 716 DCHECK_EQ(source_size.height(), source_bitmap_with_filters.height()); | 720 DCHECK_EQ(source_size.height(), source_bitmap_with_filters->height()); |
| 717 GrTexture* texture = | 721 GrTexture* texture = |
| 718 reinterpret_cast<GrTexture*>(source_bitmap_with_filters.getTexture()); | 722 reinterpret_cast<GrTexture*>(source_bitmap_with_filters->getTexture()); |
| 719 source_texture_with_filters_id = texture->getTextureHandle(); | 723 source_texture_with_filters_id = texture->getTextureHandle(); |
| 720 } else { | 724 } else { |
| 721 lock.reset(new ResourceProvider::ScopedReadLockGL( | 725 lock.reset(new ResourceProvider::ScopedReadLockGL( |
| 722 resource_provider, source_texture_resource->id())); | 726 resource_provider, source_texture_resource->id())); |
| 723 source_texture_with_filters_id = lock->texture_id(); | 727 source_texture_with_filters_id = lock->texture_id(); |
| 724 } | 728 } |
| 725 | 729 |
| 726 ResourceProvider::ScopedReadLockGL lock_background( | 730 ResourceProvider::ScopedReadLockGL lock_background( |
| 727 resource_provider, background_texture_resource->id()); | 731 resource_provider, background_texture_resource->id()); |
| 728 | 732 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 skia::AdoptRef(scratch_texture.detach()); | 782 skia::AdoptRef(scratch_texture.detach()); |
| 779 if (backing_store.get() == NULL) { | 783 if (backing_store.get() == NULL) { |
| 780 TRACE_EVENT_INSTANT0( | 784 TRACE_EVENT_INSTANT0( |
| 781 "cc", | 785 "cc", |
| 782 "ApplyBlendModeWithBackdrop scratch texture allocation failed", | 786 "ApplyBlendModeWithBackdrop scratch texture allocation failed", |
| 783 TRACE_EVENT_SCOPE_THREAD); | 787 TRACE_EVENT_SCOPE_THREAD); |
| 784 return source_bitmap_with_filters; | 788 return source_bitmap_with_filters; |
| 785 } | 789 } |
| 786 | 790 |
| 787 // Create a device and canvas using that backing store. | 791 // Create a device and canvas using that backing store. |
| 788 skia::RefPtr<SkGpuDevice> device = | 792 skia::RefPtr<SkSurface> surface = skia::AdoptRef( |
| 789 skia::AdoptRef(SkGpuDevice::Create(backing_store->asRenderTarget())); | 793 SkSurface::NewRenderTargetDirect(backing_store->asRenderTarget())); |
| 790 DCHECK(device.get()); | 794 if (!surface) |
| 791 SkCanvas canvas(device.get()); | 795 return skia::RefPtr<SkImage>(); |
| 796 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); |
| 792 | 797 |
| 793 // Draw the source bitmap through the filter to the canvas. | 798 // Draw the source bitmap through the filter to the canvas. |
| 794 canvas.clear(SK_ColorTRANSPARENT); | 799 canvas->clear(SK_ColorTRANSPARENT); |
| 795 canvas.drawSprite(background, 0, 0); | 800 canvas->drawSprite(background, 0, 0); |
| 796 SkPaint paint; | 801 SkPaint paint; |
| 797 paint.setXfermodeMode(blend_mode); | 802 paint.setXfermodeMode(blend_mode); |
| 798 canvas.drawSprite(source, 0, 0, &paint); | 803 canvas->drawSprite(source, 0, 0, &paint); |
| 804 |
| 805 skia::RefPtr<SkImage> image = skia::AdoptRef(surface->newImageSnapshot()); |
| 806 if (!image || !image->getTexture()) { |
| 807 return skia::RefPtr<SkImage>(); |
| 808 } |
| 799 | 809 |
| 800 // Flush the GrContext to ensure all buffered GL calls are drawn to the | 810 // 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 | 811 // backing store before we access and return it, and have cc begin using the |
| 802 // GL context again. | 812 // GL context again. |
| 803 use_gr_context->context()->flush(); | 813 canvas->flush(); |
| 804 | 814 |
| 805 return device->accessBitmap(false); | 815 return image; |
| 806 } | 816 } |
| 807 | 817 |
| 808 scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters( | 818 scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters( |
| 809 DrawingFrame* frame, | 819 DrawingFrame* frame, |
| 810 const RenderPassDrawQuad* quad, | 820 const RenderPassDrawQuad* quad, |
| 811 const gfx::Transform& contents_device_transform, | 821 const gfx::Transform& contents_device_transform, |
| 812 const gfx::Transform& contents_device_transform_inverse, | 822 const gfx::Transform& contents_device_transform_inverse, |
| 813 bool* background_changed) { | 823 bool* background_changed) { |
| 814 // This method draws a background filter, which applies a filter to any pixels | 824 // 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 | 825 // behind the quad and seen through its background. The algorithm works as |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 { | 876 { |
| 867 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, | 877 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, |
| 868 device_background_texture->id()); | 878 device_background_texture->id()); |
| 869 GetFramebufferTexture( | 879 GetFramebufferTexture( |
| 870 lock.texture_id(), device_background_texture->format(), window_rect); | 880 lock.texture_id(), device_background_texture->format(), window_rect); |
| 871 } | 881 } |
| 872 | 882 |
| 873 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( | 883 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( |
| 874 quad->background_filters, device_background_texture->size()); | 884 quad->background_filters, device_background_texture->size()); |
| 875 | 885 |
| 876 SkBitmap filtered_device_background; | 886 skia::RefPtr<SkImage> filtered_device_background; |
| 877 if (apply_background_filters) { | 887 if (apply_background_filters) { |
| 878 filtered_device_background = | 888 filtered_device_background = |
| 879 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), | 889 ApplyImageFilter(ScopedUseGrContext::Create(this, frame), |
| 880 resource_provider_, | 890 resource_provider_, |
| 881 quad->rect.origin(), | 891 quad->rect.origin(), |
| 882 quad->filters_scale, | 892 quad->filters_scale, |
| 883 filter.get(), | 893 filter.get(), |
| 884 device_background_texture.get()); | 894 device_background_texture.get()); |
| 885 } | 895 } |
| 886 *background_changed = (filtered_device_background.getTexture() != NULL); | 896 *background_changed = (filtered_device_background != NULL); |
| 887 | 897 |
| 888 int filtered_device_background_texture_id = 0; | 898 int filtered_device_background_texture_id = 0; |
| 889 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock; | 899 scoped_ptr<ResourceProvider::ScopedReadLockGL> lock; |
| 890 if (filtered_device_background.getTexture()) { | 900 if (filtered_device_background) { |
| 891 GrTexture* texture = | 901 GrTexture* texture = filtered_device_background->getTexture(); |
| 892 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture()); | |
| 893 filtered_device_background_texture_id = texture->getTextureHandle(); | 902 filtered_device_background_texture_id = texture->getTextureHandle(); |
| 894 } else { | 903 } else { |
| 895 lock.reset(new ResourceProvider::ScopedReadLockGL( | 904 lock.reset(new ResourceProvider::ScopedReadLockGL( |
| 896 resource_provider_, device_background_texture->id())); | 905 resource_provider_, device_background_texture->id())); |
| 897 filtered_device_background_texture_id = lock->texture_id(); | 906 filtered_device_background_texture_id = lock->texture_id(); |
| 898 } | 907 } |
| 899 | 908 |
| 900 scoped_ptr<ScopedResource> background_texture = | 909 scoped_ptr<ScopedResource> background_texture = |
| 901 ScopedResource::Create(resource_provider_); | 910 ScopedResource::Create(resource_provider_); |
| 902 background_texture->Allocate( | 911 background_texture->Allocate( |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 contents_device_transform, | 990 contents_device_transform, |
| 982 contents_device_transform_inverse, | 991 contents_device_transform_inverse, |
| 983 &background_changed); | 992 &background_changed); |
| 984 | 993 |
| 985 if (disable_blending) | 994 if (disable_blending) |
| 986 SetBlendEnabled(true); | 995 SetBlendEnabled(true); |
| 987 } | 996 } |
| 988 | 997 |
| 989 // TODO(senorblanco): Cache this value so that we don't have to do it for both | 998 // 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. | 999 // the surface and its replica. Apply filters to the contents texture. |
| 991 SkBitmap filter_bitmap; | 1000 skia::RefPtr<SkImage> filter_bitmap; |
| 992 SkScalar color_matrix[20]; | 1001 SkScalar color_matrix[20]; |
| 993 bool use_color_matrix = false; | 1002 bool use_color_matrix = false; |
| 994 if (!quad->filters.IsEmpty()) { | 1003 if (!quad->filters.IsEmpty()) { |
| 995 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( | 1004 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( |
| 996 quad->filters, contents_texture->size()); | 1005 quad->filters, contents_texture->size()); |
| 997 if (filter) { | 1006 if (filter) { |
| 998 skia::RefPtr<SkColorFilter> cf; | 1007 skia::RefPtr<SkColorFilter> cf; |
| 999 | 1008 |
| 1000 { | 1009 { |
| 1001 SkColorFilter* colorfilter_rawptr = NULL; | 1010 SkColorFilter* colorfilter_rawptr = NULL; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 if (quad->mask_resource_id) { | 1078 if (quad->mask_resource_id) { |
| 1070 mask_resource_lock.reset(new ResourceProvider::ScopedReadLockGL( | 1079 mask_resource_lock.reset(new ResourceProvider::ScopedReadLockGL( |
| 1071 resource_provider_, quad->mask_resource_id)); | 1080 resource_provider_, quad->mask_resource_id)); |
| 1072 mask_texture_id = mask_resource_lock->texture_id(); | 1081 mask_texture_id = mask_resource_lock->texture_id(); |
| 1073 } | 1082 } |
| 1074 | 1083 |
| 1075 // TODO(danakj): use the background_texture and blend the background in with | 1084 // 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. | 1085 // this draw instead of having a separate copy of the background texture. |
| 1077 | 1086 |
| 1078 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock; | 1087 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock; |
| 1079 if (filter_bitmap.getTexture()) { | 1088 if (filter_bitmap) { |
| 1080 GrTexture* texture = | 1089 GrTexture* texture = filter_bitmap->getTexture(); |
| 1081 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture()); | |
| 1082 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); | 1090 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); |
| 1083 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); | 1091 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); |
| 1084 } else { | 1092 } else { |
| 1085 contents_resource_lock = | 1093 contents_resource_lock = |
| 1086 make_scoped_ptr(new ResourceProvider::ScopedSamplerGL( | 1094 make_scoped_ptr(new ResourceProvider::ScopedSamplerGL( |
| 1087 resource_provider_, contents_texture->id(), GL_LINEAR)); | 1095 resource_provider_, contents_texture->id(), GL_LINEAR)); |
| 1088 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 1096 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 1089 contents_resource_lock->target()); | 1097 contents_resource_lock->target()); |
| 1090 } | 1098 } |
| 1091 | 1099 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 device_layer_edges.ToQuadF(), | 1334 device_layer_edges.ToQuadF(), |
| 1327 &clipped); | 1335 &clipped); |
| 1328 | 1336 |
| 1329 SetShaderOpacity(quad->opacity(), shader_alpha_location); | 1337 SetShaderOpacity(quad->opacity(), shader_alpha_location); |
| 1330 SetShaderQuadF(surface_quad, shader_quad_location); | 1338 SetShaderQuadF(surface_quad, shader_quad_location); |
| 1331 DrawQuadGeometry( | 1339 DrawQuadGeometry( |
| 1332 frame, quad->quadTransform(), quad->rect, shader_matrix_location); | 1340 frame, quad->quadTransform(), quad->rect, shader_matrix_location); |
| 1333 | 1341 |
| 1334 // Flush the compositor context before the filter bitmap goes out of | 1342 // Flush the compositor context before the filter bitmap goes out of |
| 1335 // scope, so the draw gets processed before the filter texture gets deleted. | 1343 // scope, so the draw gets processed before the filter texture gets deleted. |
| 1336 if (filter_bitmap.getTexture()) | 1344 if (filter_bitmap) |
| 1337 GLC(gl_, gl_->Flush()); | 1345 GLC(gl_, gl_->Flush()); |
| 1338 } | 1346 } |
| 1339 | 1347 |
| 1340 struct SolidColorProgramUniforms { | 1348 struct SolidColorProgramUniforms { |
| 1341 unsigned program; | 1349 unsigned program; |
| 1342 unsigned matrix_location; | 1350 unsigned matrix_location; |
| 1343 unsigned viewport_location; | 1351 unsigned viewport_location; |
| 1344 unsigned quad_location; | 1352 unsigned quad_location; |
| 1345 unsigned edge_location; | 1353 unsigned edge_location; |
| 1346 unsigned color_location; | 1354 unsigned color_location; |
| (...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3174 context_support_->ScheduleOverlayPlane( | 3182 context_support_->ScheduleOverlayPlane( |
| 3175 overlay.plane_z_order, | 3183 overlay.plane_z_order, |
| 3176 overlay.transform, | 3184 overlay.transform, |
| 3177 pending_overlay_resources_.back()->texture_id(), | 3185 pending_overlay_resources_.back()->texture_id(), |
| 3178 overlay.display_rect, | 3186 overlay.display_rect, |
| 3179 overlay.uv_rect); | 3187 overlay.uv_rect); |
| 3180 } | 3188 } |
| 3181 } | 3189 } |
| 3182 | 3190 |
| 3183 } // namespace cc | 3191 } // namespace cc |
| OLD | NEW |