| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "cc/quads/picture_draw_quad.h" | 38 #include "cc/quads/picture_draw_quad.h" |
| 39 #include "cc/quads/render_pass.h" | 39 #include "cc/quads/render_pass.h" |
| 40 #include "cc/quads/stream_video_draw_quad.h" | 40 #include "cc/quads/stream_video_draw_quad.h" |
| 41 #include "cc/quads/texture_draw_quad.h" | 41 #include "cc/quads/texture_draw_quad.h" |
| 42 #include "cc/raster/scoped_gpu_raster.h" | 42 #include "cc/raster/scoped_gpu_raster.h" |
| 43 #include "cc/resources/scoped_resource.h" | 43 #include "cc/resources/scoped_resource.h" |
| 44 #include "gpu/GLES2/gl2extchromium.h" | 44 #include "gpu/GLES2/gl2extchromium.h" |
| 45 #include "gpu/command_buffer/client/context_support.h" | 45 #include "gpu/command_buffer/client/context_support.h" |
| 46 #include "gpu/command_buffer/client/gles2_interface.h" | 46 #include "gpu/command_buffer/client/gles2_interface.h" |
| 47 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 47 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
| 48 #include "skia/ext/texture_handle.h" |
| 48 #include "third_party/skia/include/core/SkBitmap.h" | 49 #include "third_party/skia/include/core/SkBitmap.h" |
| 49 #include "third_party/skia/include/core/SkColor.h" | 50 #include "third_party/skia/include/core/SkColor.h" |
| 50 #include "third_party/skia/include/core/SkColorFilter.h" | 51 #include "third_party/skia/include/core/SkColorFilter.h" |
| 51 #include "third_party/skia/include/core/SkImage.h" | 52 #include "third_party/skia/include/core/SkImage.h" |
| 52 #include "third_party/skia/include/core/SkSurface.h" | 53 #include "third_party/skia/include/core/SkSurface.h" |
| 53 #include "third_party/skia/include/gpu/GrContext.h" | 54 #include "third_party/skia/include/gpu/GrContext.h" |
| 54 #include "third_party/skia/include/gpu/GrTexture.h" | 55 #include "third_party/skia/include/gpu/GrTexture.h" |
| 55 #include "third_party/skia/include/gpu/GrTextureProvider.h" | 56 #include "third_party/skia/include/gpu/GrTextureProvider.h" |
| 56 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 57 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
| 58 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" |
| 57 #include "ui/gfx/geometry/quad_f.h" | 59 #include "ui/gfx/geometry/quad_f.h" |
| 58 #include "ui/gfx/geometry/rect_conversions.h" | 60 #include "ui/gfx/geometry/rect_conversions.h" |
| 59 #include "ui/gfx/skia_util.h" | 61 #include "ui/gfx/skia_util.h" |
| 60 | 62 |
| 61 using gpu::gles2::GLES2Interface; | 63 using gpu::gles2::GLES2Interface; |
| 62 | 64 |
| 63 namespace cc { | 65 namespace cc { |
| 64 namespace { | 66 namespace { |
| 65 | 67 |
| 66 bool NeedsIOSurfaceReadbackWorkaround() { | 68 bool NeedsIOSurfaceReadbackWorkaround() { |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 return skia::RefPtr<SkImage>(); | 613 return skia::RefPtr<SkImage>(); |
| 612 | 614 |
| 613 if (!use_gr_context) | 615 if (!use_gr_context) |
| 614 return skia::RefPtr<SkImage>(); | 616 return skia::RefPtr<SkImage>(); |
| 615 | 617 |
| 616 ResourceProvider::ScopedReadLockGL lock(resource_provider, | 618 ResourceProvider::ScopedReadLockGL lock(resource_provider, |
| 617 source_texture_resource->id()); | 619 source_texture_resource->id()); |
| 618 | 620 |
| 619 // Wrap the source texture in a Ganesh platform texture. | 621 // Wrap the source texture in a Ganesh platform texture. |
| 620 GrBackendTextureDesc backend_texture_description; | 622 GrBackendTextureDesc backend_texture_description; |
| 623 GrGLTextureInfo texture_info; |
| 624 texture_info.fTarget = lock.target(); |
| 625 texture_info.fID = lock.texture_id(); |
| 621 backend_texture_description.fWidth = source_texture_resource->size().width(); | 626 backend_texture_description.fWidth = source_texture_resource->size().width(); |
| 622 backend_texture_description.fHeight = | 627 backend_texture_description.fHeight = |
| 623 source_texture_resource->size().height(); | 628 source_texture_resource->size().height(); |
| 624 backend_texture_description.fConfig = kSkia8888_GrPixelConfig; | 629 backend_texture_description.fConfig = kSkia8888_GrPixelConfig; |
| 625 backend_texture_description.fTextureHandle = lock.texture_id(); | 630 backend_texture_description.fTextureHandle = |
| 631 skia::GrGLTextureInfoToGrBackendObject(texture_info); |
| 626 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin; | 632 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin; |
| 627 | 633 |
| 628 skia::RefPtr<SkImage> srcImage = skia::AdoptRef(SkImage::NewFromTexture( | 634 skia::RefPtr<SkImage> srcImage = skia::AdoptRef(SkImage::NewFromTexture( |
| 629 use_gr_context->context(), backend_texture_description)); | 635 use_gr_context->context(), backend_texture_description)); |
| 630 if (!srcImage.get()) { | 636 if (!srcImage.get()) { |
| 631 TRACE_EVENT_INSTANT0("cc", | 637 TRACE_EVENT_INSTANT0("cc", |
| 632 "ApplyImageFilter wrap background texture failed", | 638 "ApplyImageFilter wrap background texture failed", |
| 633 TRACE_EVENT_SCOPE_THREAD); | 639 TRACE_EVENT_SCOPE_THREAD); |
| 634 return skia::RefPtr<SkImage>(); | 640 return skia::RefPtr<SkImage>(); |
| 635 } | 641 } |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 // amount of memory used by render surfaces: | 954 // amount of memory used by render surfaces: |
| 949 // LayerTreeHost::CalculateMemoryForRenderSurfaces. | 955 // LayerTreeHost::CalculateMemoryForRenderSurfaces. |
| 950 background_texture = GetBackdropTexture(background_rect); | 956 background_texture = GetBackdropTexture(background_rect); |
| 951 | 957 |
| 952 if (ShouldApplyBackgroundFilters(quad) && background_texture) { | 958 if (ShouldApplyBackgroundFilters(quad) && background_texture) { |
| 953 // Apply the background filters to R, so that it is applied in the | 959 // Apply the background filters to R, so that it is applied in the |
| 954 // pixels' coordinate space. | 960 // pixels' coordinate space. |
| 955 background_image = ApplyBackgroundFilters( | 961 background_image = ApplyBackgroundFilters( |
| 956 frame, quad, background_texture.get(), gfx::RectF(background_rect)); | 962 frame, quad, background_texture.get(), gfx::RectF(background_rect)); |
| 957 if (background_image) | 963 if (background_image) |
| 958 background_image_id = background_image->getTextureHandle(true); | 964 background_image_id = skia::GrBackendObjectToGrGLTextureInfo( |
| 965 background_image->getTextureHandle(true)) |
| 966 ->fID; |
| 959 DCHECK(background_image_id); | 967 DCHECK(background_image_id); |
| 960 } | 968 } |
| 961 } | 969 } |
| 962 | 970 |
| 963 if (!background_texture) { | 971 if (!background_texture) { |
| 964 // Something went wrong with reading the backdrop. | 972 // Something went wrong with reading the backdrop. |
| 965 DCHECK(!background_image_id); | 973 DCHECK(!background_image_id); |
| 966 use_shaders_for_blending = false; | 974 use_shaders_for_blending = false; |
| 967 } else if (background_image_id) { | 975 } else if (background_image_id) { |
| 968 // Reset original background texture if there is not any mask | 976 // Reset original background texture if there is not any mask |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 dst_rect.Intersect(local_clip.BoundingBox()); | 1035 dst_rect.Intersect(local_clip.BoundingBox()); |
| 1028 // If we've been fully clipped out (by crop rect or clipping), there's | 1036 // If we've been fully clipped out (by crop rect or clipping), there's |
| 1029 // nothing to draw. | 1037 // nothing to draw. |
| 1030 if (dst_rect.IsEmpty()) { | 1038 if (dst_rect.IsEmpty()) { |
| 1031 return; | 1039 return; |
| 1032 } | 1040 } |
| 1033 filter_image = ApplyImageFilter(ScopedUseGrContext::Create(this, frame), | 1041 filter_image = ApplyImageFilter(ScopedUseGrContext::Create(this, frame), |
| 1034 resource_provider_, rect, dst_rect, | 1042 resource_provider_, rect, dst_rect, |
| 1035 scale, filter.get(), contents_texture); | 1043 scale, filter.get(), contents_texture); |
| 1036 if (filter_image) { | 1044 if (filter_image) { |
| 1037 filter_image_id = filter_image->getTextureHandle(true); | 1045 filter_image_id = skia::GrBackendObjectToGrGLTextureInfo( |
| 1046 filter_image->getTextureHandle(true)) |
| 1047 ->fID; |
| 1038 DCHECK(filter_image_id); | 1048 DCHECK(filter_image_id); |
| 1039 rect = dst_rect; | 1049 rect = dst_rect; |
| 1040 } | 1050 } |
| 1041 } | 1051 } |
| 1042 } | 1052 } |
| 1043 } | 1053 } |
| 1044 | 1054 |
| 1045 scoped_ptr<ResourceProvider::ScopedSamplerGL> mask_resource_lock; | 1055 scoped_ptr<ResourceProvider::ScopedSamplerGL> mask_resource_lock; |
| 1046 unsigned mask_texture_id = 0; | 1056 unsigned mask_texture_id = 0; |
| 1047 SamplerType mask_sampler = SAMPLER_TYPE_NA; | 1057 SamplerType mask_sampler = SAMPLER_TYPE_NA; |
| (...skipping 2586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3634 texture_id = pending_overlay_resources_.back()->texture_id(); | 3644 texture_id = pending_overlay_resources_.back()->texture_id(); |
| 3635 } | 3645 } |
| 3636 | 3646 |
| 3637 context_support_->ScheduleOverlayPlane( | 3647 context_support_->ScheduleOverlayPlane( |
| 3638 overlay.plane_z_order, overlay.transform, texture_id, | 3648 overlay.plane_z_order, overlay.transform, texture_id, |
| 3639 ToNearestRect(overlay.display_rect), overlay.uv_rect); | 3649 ToNearestRect(overlay.display_rect), overlay.uv_rect); |
| 3640 } | 3650 } |
| 3641 } | 3651 } |
| 3642 | 3652 |
| 3643 } // namespace cc | 3653 } // namespace cc |
| OLD | NEW |