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

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

Issue 16069004: cc: Remove legacy accelerated painting path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Base files missing blahblahblah Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/resource_update.cc ('k') | cc/resources/skpicture_content_layer_updater.h » ('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_update_controller.h" 5 #include "cc/resources/resource_update_controller.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/base/thread.h" 10 #include "cc/base/thread.h"
(...skipping 15 matching lines...) Expand all
26 26
27 // Measured in seconds. 27 // Measured in seconds.
28 const double kTextureUpdateTickRate = 0.004; 28 const double kTextureUpdateTickRate = 0.004;
29 29
30 // Measured in seconds. 30 // Measured in seconds.
31 const double kUploaderBusyTickRate = 0.001; 31 const double kUploaderBusyTickRate = 0.001;
32 32
33 // Number of blocking update intervals to allow. 33 // Number of blocking update intervals to allow.
34 const size_t kMaxBlockingUpdateIntervals = 4; 34 const size_t kMaxBlockingUpdateIntervals = 4;
35 35
36 skia::RefPtr<SkCanvas> CreateAcceleratedCanvas( 36 skia::RefPtr<SkCanvas> CreateAcceleratedCanvas(
reveman 2013/05/28 22:40:28 please also remove this and all includes it pulls
enne (OOO) 2013/05/28 22:53:21 Done. Sorry for missing that.
37 GrContext* gr_context, gfx::Size canvas_size, unsigned texture_id) { 37 GrContext* gr_context, gfx::Size canvas_size, unsigned texture_id) {
38 GrBackendTextureDesc texture_desc; 38 GrBackendTextureDesc texture_desc;
39 texture_desc.fFlags = kRenderTarget_GrBackendTextureFlag; 39 texture_desc.fFlags = kRenderTarget_GrBackendTextureFlag;
40 texture_desc.fWidth = canvas_size.width(); 40 texture_desc.fWidth = canvas_size.width();
41 texture_desc.fHeight = canvas_size.height(); 41 texture_desc.fHeight = canvas_size.height();
42 texture_desc.fConfig = kSkia8888_GrPixelConfig; 42 texture_desc.fConfig = kSkia8888_GrPixelConfig;
43 texture_desc.fTextureHandle = texture_id; 43 texture_desc.fTextureHandle = texture_id;
44 skia::RefPtr<GrTexture> target = 44 skia::RefPtr<GrTexture> target =
45 skia::AdoptRef(gr_context->wrapBackendTexture(texture_desc)); 45 skia::AdoptRef(gr_context->wrapBackendTexture(texture_desc));
46 skia::RefPtr<SkDevice> device = 46 skia::RefPtr<SkDevice> device =
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 105
106 first_update_attempt_ = false; 106 first_update_attempt_ = false;
107 } 107 }
108 108
109 void ResourceUpdateController::DiscardUploadsToEvictedResources() { 109 void ResourceUpdateController::DiscardUploadsToEvictedResources() {
110 queue_->ClearUploadsToEvictedResources(); 110 queue_->ClearUploadsToEvictedResources();
111 } 111 }
112 112
113 void ResourceUpdateController::UpdateTexture(ResourceUpdate update) { 113 void ResourceUpdateController::UpdateTexture(ResourceUpdate update) {
114 if (update.picture) { 114 update.bitmap->lockPixels();
115 PrioritizedResource* texture = update.texture; 115 update.texture->SetPixels(
116 gfx::Rect picture_rect = update.content_rect; 116 resource_provider_,
117 gfx::Rect source_rect = update.source_rect; 117 static_cast<const uint8_t*>(update.bitmap->getPixels()),
118 gfx::Vector2d dest_offset = update.dest_offset; 118 update.content_rect,
119 119 update.source_rect,
120 texture->AcquireBackingTexture(resource_provider_); 120 update.dest_offset);
121 DCHECK(texture->have_backing_texture()); 121 update.bitmap->unlockPixels();
122
123 DCHECK_EQ(resource_provider_->GetResourceType(texture->resource_id()),
124 ResourceProvider::GLTexture);
125
126 cc::ContextProvider* offscreen_contexts =
127 resource_provider_->offscreen_context_provider();
128
129 ResourceProvider::ScopedWriteLockGL lock(
130 resource_provider_, texture->resource_id());
131
132 // Flush the compositor context to ensure that textures there are available
133 // in the shared context. Do this after locking/creating the compositor
134 // texture.
135 resource_provider_->Flush();
136
137 // Make sure skia uses the correct GL context.
138 offscreen_contexts->Context3d()->makeContextCurrent();
139
140 // Create an accelerated canvas to draw on.
141 skia::RefPtr<SkCanvas> canvas = CreateAcceleratedCanvas(
142 offscreen_contexts->GrContext(), texture->size(), lock.texture_id());
143
144 // The compositor expects the textures to be upside-down so it can flip
145 // the final composited image. Ganesh renders the image upright so we
146 // need to do a y-flip.
147 canvas->translate(0.0, texture->size().height());
148 canvas->scale(1.0, -1.0);
149 // Clip to the destination on the texture that must be updated.
150 canvas->clipRect(SkRect::MakeXYWH(dest_offset.x(),
151 dest_offset.y(),
152 source_rect.width(),
153 source_rect.height()));
154 // Translate the origin of picture_rect to dest_offset.
155 // Note that dest_offset is defined relative to source_rect.
156 canvas->translate(
157 picture_rect.x() - source_rect.x() + dest_offset.x(),
158 picture_rect.y() - source_rect.y() + dest_offset.y());
159 canvas->drawPicture(*update.picture);
160
161 // Flush skia context so that all the rendered stuff appears on the
162 // texture.
163 offscreen_contexts->GrContext()->flush();
164
165 // Flush the GL context so rendering results from this context are
166 // visible in the compositor's context.
167 offscreen_contexts->Context3d()->flush();
168
169 // Use the compositor's GL context again.
170 resource_provider_->GraphicsContext3D()->makeContextCurrent();
171 }
172
173 if (update.bitmap) {
174 update.bitmap->lockPixels();
175 update.texture->SetPixels(
176 resource_provider_,
177 static_cast<const uint8_t*>(update.bitmap->getPixels()),
178 update.content_rect,
179 update.source_rect,
180 update.dest_offset);
181 update.bitmap->unlockPixels();
182 }
183 } 122 }
184 123
185 void ResourceUpdateController::Finalize() { 124 void ResourceUpdateController::Finalize() {
186 while (queue_->FullUploadSize()) 125 while (queue_->FullUploadSize())
187 UpdateTexture(queue_->TakeFirstFullUpload()); 126 UpdateTexture(queue_->TakeFirstFullUpload());
188 127
189 while (queue_->PartialUploadSize()) 128 while (queue_->PartialUploadSize())
190 UpdateTexture(queue_->TakeFirstPartialUpload()); 129 UpdateTexture(queue_->TakeFirstPartialUpload());
191 130
192 resource_provider_->FlushUploads(); 131 resource_provider_->FlushUploads();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 if (!uploads) 205 if (!uploads)
267 return; 206 return;
268 207
269 while (queue_->FullUploadSize() && uploads--) 208 while (queue_->FullUploadSize() && uploads--)
270 UpdateTexture(queue_->TakeFirstFullUpload()); 209 UpdateTexture(queue_->TakeFirstFullUpload());
271 210
272 resource_provider_->FlushUploads(); 211 resource_provider_->FlushUploads();
273 } 212 }
274 213
275 } // namespace cc 214 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_update.cc ('k') | cc/resources/skpicture_content_layer_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698