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

Side by Side Diff: cc/resources/resource_provider.cc

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « cc/resources/picture_pile.cc ('k') | cc/resources/resource_provider_unittest.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 gfx::Size(), 615 gfx::Size(),
616 Resource::External, 616 Resource::External,
617 mailbox.target(), 617 mailbox.target(),
618 mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR, 618 mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR,
619 0, 619 0,
620 GL_CLAMP_TO_EDGE, 620 GL_CLAMP_TO_EDGE,
621 TextureHintImmutable, 621 TextureHintImmutable,
622 RGBA_8888); 622 RGBA_8888);
623 } else { 623 } else {
624 DCHECK(mailbox.IsSharedMemory()); 624 DCHECK(mailbox.IsSharedMemory());
625 base::SharedMemory* shared_memory = mailbox.shared_memory(); 625 SharedBitmap* shared_bitmap = mailbox.shared_bitmap();
626 DCHECK(shared_memory->memory()); 626 uint8_t* pixels = shared_bitmap->pixels();
627 uint8_t* pixels = reinterpret_cast<uint8_t*>(shared_memory->memory());
628 DCHECK(pixels); 627 DCHECK(pixels);
629 scoped_ptr<SharedBitmap> shared_bitmap; 628 resource = Resource(pixels, shared_bitmap, mailbox.shared_memory_size(),
630 if (shared_bitmap_manager_) { 629 Resource::External, GL_LINEAR, GL_CLAMP_TO_EDGE);
631 shared_bitmap =
632 shared_bitmap_manager_->GetBitmapForSharedMemory(shared_memory);
633 }
634 resource = Resource(pixels,
635 shared_bitmap.release(),
636 mailbox.shared_memory_size(),
637 Resource::External,
638 GL_LINEAR,
639 GL_CLAMP_TO_EDGE);
640 } 630 }
641 resource.allocated = true; 631 resource.allocated = true;
642 resource.mailbox = mailbox; 632 resource.mailbox = mailbox;
643 resource.release_callback_impl = 633 resource.release_callback_impl =
644 base::Bind(&SingleReleaseCallbackImpl::Run, 634 base::Bind(&SingleReleaseCallbackImpl::Run,
645 base::Owned(release_callback_impl.release())); 635 base::Owned(release_callback_impl.release()));
646 resource.allow_overlay = mailbox.allow_overlay(); 636 resource.allow_overlay = mailbox.allow_overlay();
647 return id; 637 return id;
648 } 638 }
649 639
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 GLES2Interface* gl = ContextGL(); 697 GLES2Interface* gl = ContextGL();
708 DCHECK(gl); 698 DCHECK(gl);
709 if (resource->gl_id) { 699 if (resource->gl_id) {
710 GLC(gl, gl->DeleteTextures(1, &resource->gl_id)); 700 GLC(gl, gl->DeleteTextures(1, &resource->gl_id));
711 resource->gl_id = 0; 701 resource->gl_id = 0;
712 if (!lost_resource) 702 if (!lost_resource)
713 sync_point = gl->InsertSyncPointCHROMIUM(); 703 sync_point = gl->InsertSyncPointCHROMIUM();
714 } 704 }
715 } else { 705 } else {
716 DCHECK(resource->mailbox.IsSharedMemory()); 706 DCHECK(resource->mailbox.IsSharedMemory());
717 base::SharedMemory* shared_memory = resource->mailbox.shared_memory(); 707 resource->shared_bitmap = nullptr;
718 if (resource->pixels && shared_memory) { 708 resource->pixels = nullptr;
719 DCHECK(shared_memory->memory() == resource->pixels);
720 resource->pixels = NULL;
721 delete resource->shared_bitmap;
722 resource->shared_bitmap = NULL;
723 }
724 } 709 }
725 resource->release_callback_impl.Run( 710 resource->release_callback_impl.Run(
726 sync_point, lost_resource, blocking_main_thread_task_runner_); 711 sync_point, lost_resource, blocking_main_thread_task_runner_);
727 } 712 }
728 if (resource->gl_id) { 713 if (resource->gl_id) {
729 GLES2Interface* gl = ContextGL(); 714 GLES2Interface* gl = ContextGL();
730 DCHECK(gl); 715 DCHECK(gl);
731 GLC(gl, gl->DeleteTextures(1, &resource->gl_id)); 716 GLC(gl, gl->DeleteTextures(1, &resource->gl_id));
732 resource->gl_id = 0; 717 resource->gl_id = 0;
733 } 718 }
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 SkSurface* ResourceProvider::ScopedWriteLockGr::GetSkSurface( 1101 SkSurface* ResourceProvider::ScopedWriteLockGr::GetSkSurface(
1117 bool use_distance_field_text, 1102 bool use_distance_field_text,
1118 bool can_use_lcd_text) { 1103 bool can_use_lcd_text) {
1119 DCHECK(thread_checker_.CalledOnValidThread()); 1104 DCHECK(thread_checker_.CalledOnValidThread());
1120 DCHECK(resource_->locked_for_write); 1105 DCHECK(resource_->locked_for_write);
1121 1106
1122 bool create_surface = 1107 bool create_surface =
1123 !resource_->sk_surface.get() || 1108 !resource_->sk_surface.get() ||
1124 !SurfaceHasMatchingProperties(use_distance_field_text, can_use_lcd_text); 1109 !SurfaceHasMatchingProperties(use_distance_field_text, can_use_lcd_text);
1125 if (create_surface) { 1110 if (create_surface) {
1126 class GrContext* gr_context = resource_provider_->GrContext();
1127 // TODO(alokp): Implement TestContextProvider::GrContext().
1128 if (!gr_context)
1129 return nullptr;
1130
1131 resource_provider_->LazyAllocate(resource_); 1111 resource_provider_->LazyAllocate(resource_);
1132 1112
1133 GrBackendTextureDesc desc; 1113 GrBackendTextureDesc desc;
1134 desc.fFlags = kRenderTarget_GrBackendTextureFlag; 1114 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
1135 desc.fWidth = resource_->size.width(); 1115 desc.fWidth = resource_->size.width();
1136 desc.fHeight = resource_->size.height(); 1116 desc.fHeight = resource_->size.height();
1137 desc.fConfig = ToGrPixelConfig(resource_->format); 1117 desc.fConfig = ToGrPixelConfig(resource_->format);
1138 desc.fOrigin = kTopLeft_GrSurfaceOrigin; 1118 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
1139 desc.fTextureHandle = resource_->gl_id; 1119 desc.fTextureHandle = resource_->gl_id;
1120
1121 class GrContext* gr_context = resource_provider_->GrContext();
1140 skia::RefPtr<GrTexture> gr_texture = 1122 skia::RefPtr<GrTexture> gr_texture =
1141 skia::AdoptRef(gr_context->wrapBackendTexture(desc)); 1123 skia::AdoptRef(gr_context->wrapBackendTexture(desc));
1142 if (!gr_texture) 1124 if (!gr_texture)
1143 return nullptr; 1125 return nullptr;
1144 uint32_t flags = use_distance_field_text 1126 uint32_t flags = use_distance_field_text
1145 ? SkSurfaceProps::kUseDistanceFieldFonts_Flag 1127 ? SkSurfaceProps::kUseDistanceFieldFonts_Flag
1146 : 0; 1128 : 0;
1147 // Use unknown pixel geometry to disable LCD text. 1129 // Use unknown pixel geometry to disable LCD text.
1148 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry); 1130 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry);
1149 if (can_use_lcd_text) { 1131 if (can_use_lcd_text) {
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 ContextProvider* context_provider = output_surface_->context_provider(); 2141 ContextProvider* context_provider = output_surface_->context_provider();
2160 return context_provider ? context_provider->ContextGL() : NULL; 2142 return context_provider ? context_provider->ContextGL() : NULL;
2161 } 2143 }
2162 2144
2163 class GrContext* ResourceProvider::GrContext() const { 2145 class GrContext* ResourceProvider::GrContext() const {
2164 ContextProvider* context_provider = output_surface_->context_provider(); 2146 ContextProvider* context_provider = output_surface_->context_provider();
2165 return context_provider ? context_provider->GrContext() : NULL; 2147 return context_provider ? context_provider->GrContext() : NULL;
2166 } 2148 }
2167 2149
2168 } // namespace cc 2150 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_pile.cc ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698