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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 43 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
44 #include "third_party/skia/include/core/SkBitmap.h" | 44 #include "third_party/skia/include/core/SkBitmap.h" |
45 #include "third_party/skia/include/core/SkColor.h" | 45 #include "third_party/skia/include/core/SkColor.h" |
46 #include "third_party/skia/include/core/SkColorFilter.h" | 46 #include "third_party/skia/include/core/SkColorFilter.h" |
47 #include "third_party/skia/include/core/SkImage.h" | 47 #include "third_party/skia/include/core/SkImage.h" |
48 #include "third_party/skia/include/core/SkSurface.h" | 48 #include "third_party/skia/include/core/SkSurface.h" |
49 #include "third_party/skia/include/gpu/GrContext.h" | 49 #include "third_party/skia/include/gpu/GrContext.h" |
50 #include "third_party/skia/include/gpu/GrTexture.h" | 50 #include "third_party/skia/include/gpu/GrTexture.h" |
51 #include "third_party/skia/include/gpu/GrTextureProvider.h" | 51 #include "third_party/skia/include/gpu/GrTextureProvider.h" |
52 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 52 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
| 53 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" |
53 #include "ui/gfx/geometry/quad_f.h" | 54 #include "ui/gfx/geometry/quad_f.h" |
54 #include "ui/gfx/geometry/rect_conversions.h" | 55 #include "ui/gfx/geometry/rect_conversions.h" |
55 | 56 |
56 using gpu::gles2::GLES2Interface; | 57 using gpu::gles2::GLES2Interface; |
57 | 58 |
58 namespace cc { | 59 namespace cc { |
59 namespace { | 60 namespace { |
60 | 61 |
61 bool NeedsIOSurfaceReadbackWorkaround() { | 62 bool NeedsIOSurfaceReadbackWorkaround() { |
62 #if defined(OS_MACOSX) | 63 #if defined(OS_MACOSX) |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 return skia::RefPtr<SkImage>(); | 609 return skia::RefPtr<SkImage>(); |
609 | 610 |
610 if (!use_gr_context) | 611 if (!use_gr_context) |
611 return skia::RefPtr<SkImage>(); | 612 return skia::RefPtr<SkImage>(); |
612 | 613 |
613 ResourceProvider::ScopedReadLockGL lock(resource_provider, | 614 ResourceProvider::ScopedReadLockGL lock(resource_provider, |
614 source_texture_resource->id()); | 615 source_texture_resource->id()); |
615 | 616 |
616 // Wrap the source texture in a Ganesh platform texture. | 617 // Wrap the source texture in a Ganesh platform texture. |
617 GrBackendTextureDesc backend_texture_description; | 618 GrBackendTextureDesc backend_texture_description; |
| 619 GrGLTextureInfo texture_info; |
| 620 texture_info.fTarget = lock.target(); |
| 621 texture_info.fID = lock.texture_id(); |
618 backend_texture_description.fWidth = source_texture_resource->size().width(); | 622 backend_texture_description.fWidth = source_texture_resource->size().width(); |
619 backend_texture_description.fHeight = | 623 backend_texture_description.fHeight = |
620 source_texture_resource->size().height(); | 624 source_texture_resource->size().height(); |
621 backend_texture_description.fConfig = kSkia8888_GrPixelConfig; | 625 backend_texture_description.fConfig = kSkia8888_GrPixelConfig; |
622 backend_texture_description.fTextureHandle = lock.texture_id(); | 626 backend_texture_description.fTextureHandle = |
| 627 reinterpret_cast<GrBackendObject>(&texture_info); |
623 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin; | 628 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin; |
624 | 629 |
625 skia::RefPtr<SkImage> srcImage = skia::AdoptRef(SkImage::NewFromTexture( | 630 skia::RefPtr<SkImage> srcImage = skia::AdoptRef(SkImage::NewFromTexture( |
626 use_gr_context->context(), backend_texture_description)); | 631 use_gr_context->context(), backend_texture_description)); |
627 if (!srcImage.get()) { | 632 if (!srcImage.get()) { |
628 TRACE_EVENT_INSTANT0("cc", | 633 TRACE_EVENT_INSTANT0("cc", |
629 "ApplyImageFilter wrap background texture failed", | 634 "ApplyImageFilter wrap background texture failed", |
630 TRACE_EVENT_SCOPE_THREAD); | 635 TRACE_EVENT_SCOPE_THREAD); |
631 return skia::RefPtr<SkImage>(); | 636 return skia::RefPtr<SkImage>(); |
632 } | 637 } |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 // amount of memory used by render surfaces: | 925 // amount of memory used by render surfaces: |
921 // LayerTreeHost::CalculateMemoryForRenderSurfaces. | 926 // LayerTreeHost::CalculateMemoryForRenderSurfaces. |
922 background_texture = GetBackdropTexture(background_rect); | 927 background_texture = GetBackdropTexture(background_rect); |
923 | 928 |
924 if (ShouldApplyBackgroundFilters(quad) && background_texture) { | 929 if (ShouldApplyBackgroundFilters(quad) && background_texture) { |
925 // Apply the background filters to R, so that it is applied in the | 930 // Apply the background filters to R, so that it is applied in the |
926 // pixels' coordinate space. | 931 // pixels' coordinate space. |
927 background_image = | 932 background_image = |
928 ApplyBackgroundFilters(frame, quad, background_texture.get()); | 933 ApplyBackgroundFilters(frame, quad, background_texture.get()); |
929 if (background_image) | 934 if (background_image) |
930 background_image_id = background_image->getTextureHandle(true); | 935 background_image_id = reinterpret_cast<const GrGLTextureInfo*>( |
| 936 background_image->getTextureHandle(true)) |
| 937 ->fID; |
931 DCHECK(background_image_id); | 938 DCHECK(background_image_id); |
932 } | 939 } |
933 } | 940 } |
934 | 941 |
935 if (!background_texture) { | 942 if (!background_texture) { |
936 // Something went wrong with reading the backdrop. | 943 // Something went wrong with reading the backdrop. |
937 DCHECK(!background_image_id); | 944 DCHECK(!background_image_id); |
938 use_shaders_for_blending = false; | 945 use_shaders_for_blending = false; |
939 } else if (background_image_id) { | 946 } else if (background_image_id) { |
940 // Reset original background texture if there is not any mask | 947 // Reset original background texture if there is not any mask |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 | 983 |
977 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { | 984 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { |
978 // We have a single color matrix as a filter; apply it locally | 985 // We have a single color matrix as a filter; apply it locally |
979 // in the compositor. | 986 // in the compositor. |
980 use_color_matrix = true; | 987 use_color_matrix = true; |
981 } else { | 988 } else { |
982 filter_image = ApplyImageFilter( | 989 filter_image = ApplyImageFilter( |
983 ScopedUseGrContext::Create(this, frame), resource_provider_, | 990 ScopedUseGrContext::Create(this, frame), resource_provider_, |
984 quad->rect, quad->filters_scale, filter.get(), contents_texture); | 991 quad->rect, quad->filters_scale, filter.get(), contents_texture); |
985 if (filter_image) { | 992 if (filter_image) { |
986 filter_image_id = filter_image->getTextureHandle(true); | 993 filter_image_id = reinterpret_cast<const GrGLTextureInfo*>( |
| 994 filter_image->getTextureHandle(true)) |
| 995 ->fID; |
987 DCHECK(filter_image_id); | 996 DCHECK(filter_image_id); |
988 } | 997 } |
989 } | 998 } |
990 } | 999 } |
991 } | 1000 } |
992 | 1001 |
993 scoped_ptr<ResourceProvider::ScopedSamplerGL> mask_resource_lock; | 1002 scoped_ptr<ResourceProvider::ScopedSamplerGL> mask_resource_lock; |
994 unsigned mask_texture_id = 0; | 1003 unsigned mask_texture_id = 0; |
995 SamplerType mask_sampler = SAMPLER_TYPE_NA; | 1004 SamplerType mask_sampler = SAMPLER_TYPE_NA; |
996 if (quad->mask_resource_id()) { | 1005 if (quad->mask_resource_id()) { |
(...skipping 2574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3571 texture_id = pending_overlay_resources_.back()->texture_id(); | 3580 texture_id = pending_overlay_resources_.back()->texture_id(); |
3572 } | 3581 } |
3573 | 3582 |
3574 context_support_->ScheduleOverlayPlane( | 3583 context_support_->ScheduleOverlayPlane( |
3575 overlay.plane_z_order, overlay.transform, texture_id, | 3584 overlay.plane_z_order, overlay.transform, texture_id, |
3576 ToNearestRect(overlay.display_rect), overlay.uv_rect); | 3585 ToNearestRect(overlay.display_rect), overlay.uv_rect); |
3577 } | 3586 } |
3578 } | 3587 } |
3579 | 3588 |
3580 } // namespace cc | 3589 } // namespace cc |
OLD | NEW |