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

Side by Side Diff: cc/test/layer_tree_pixel_test.cc

Issue 23648014: cc: Move TextureMailbox::ReleaseCallback to SingleReleaseCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: releasecallback: dchecks Created 7 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/test/layer_tree_pixel_test.h" 5 #include "cc/test/layer_tree_pixel_test.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "cc/layers/solid_color_layer.h" 8 #include "cc/layers/solid_color_layer.h"
9 #include "cc/layers/texture_layer.h" 9 #include "cc/layers/texture_layer.h"
10 #include "cc/output/copy_output_request.h" 10 #include "cc/output/copy_output_request.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 layer->SetAnchorPoint(gfx::PointF()); 118 layer->SetAnchorPoint(gfx::PointF());
119 layer->SetBounds(rect.size()); 119 layer->SetBounds(rect.size());
120 layer->SetPosition(rect.origin()); 120 layer->SetPosition(rect.origin());
121 layer->SetBackgroundColor(color); 121 layer->SetBackgroundColor(color);
122 return layer; 122 return layer;
123 } 123 }
124 124
125 void LayerTreePixelTest::EndTest() { 125 void LayerTreePixelTest::EndTest() {
126 // Drop TextureMailboxes on the main thread so that they can be cleaned up and 126 // Drop TextureMailboxes on the main thread so that they can be cleaned up and
127 // the pending callbacks will fire. 127 // the pending callbacks will fire.
128 for (size_t i = 0; i < texture_layers_.size(); ++i) 128 for (size_t i = 0; i < texture_layers_.size(); ++i) {
129 texture_layers_[i]->SetTextureMailbox(TextureMailbox()); 129 texture_layers_[i]->SetTextureMailbox(TextureMailbox(),
130 scoped_ptr<ScopedReleaseCallback>());
131 }
130 132
131 TryEndTest(); 133 TryEndTest();
132 } 134 }
133 135
134 void LayerTreePixelTest::TryEndTest() { 136 void LayerTreePixelTest::TryEndTest() {
135 if (!result_bitmap_) 137 if (!result_bitmap_)
136 return; 138 return;
137 if (pending_texture_mailbox_callbacks_) 139 if (pending_texture_mailbox_callbacks_)
138 return; 140 return;
139 LayerTreeTest::EndTest(); 141 LayerTreeTest::EndTest();
(...skipping 27 matching lines...) Expand all
167 return layer; 169 return layer;
168 } 170 }
169 171
170 scoped_refptr<TextureLayer> LayerTreePixelTest::CreateTextureLayer( 172 scoped_refptr<TextureLayer> LayerTreePixelTest::CreateTextureLayer(
171 gfx::Rect rect, const SkBitmap& bitmap) { 173 gfx::Rect rect, const SkBitmap& bitmap) {
172 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(NULL); 174 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(NULL);
173 layer->SetIsDrawable(true); 175 layer->SetIsDrawable(true);
174 layer->SetAnchorPoint(gfx::PointF()); 176 layer->SetAnchorPoint(gfx::PointF());
175 layer->SetBounds(rect.size()); 177 layer->SetBounds(rect.size());
176 layer->SetPosition(rect.origin()); 178 layer->SetPosition(rect.origin());
177 layer->SetTextureMailbox(CopyBitmapToTextureMailboxAsTexture(bitmap)); 179
180 TextureMailbox texture_mailbox;
181 scoped_ptr<ScopedReleaseCallback> release_callback;
182 CopyBitmapToTextureMailboxAsTexture(
183 bitmap, &texture_mailbox, &release_callback);
184 layer->SetTextureMailbox(texture_mailbox, release_callback.Pass());
178 185
179 texture_layers_.push_back(layer); 186 texture_layers_.push_back(layer);
180 pending_texture_mailbox_callbacks_++; 187 pending_texture_mailbox_callbacks_++;
181 return layer; 188 return layer;
182 } 189 }
183 190
184 void LayerTreePixelTest::RunPixelTest( 191 void LayerTreePixelTest::RunPixelTest(
185 PixelTestType test_type, 192 PixelTestType test_type,
186 scoped_refptr<Layer> content_root, 193 scoped_refptr<Layer> content_root,
187 base::FilePath file_name) { 194 base::FilePath file_name) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 uint32 texture, 301 uint32 texture,
295 uint32 sync_point, 302 uint32 sync_point,
296 bool lost_resource) { 303 bool lost_resource) {
297 if (sync_point) 304 if (sync_point)
298 context3d->waitSyncPoint(sync_point); 305 context3d->waitSyncPoint(sync_point);
299 context3d->deleteTexture(texture); 306 context3d->deleteTexture(texture);
300 pending_texture_mailbox_callbacks_--; 307 pending_texture_mailbox_callbacks_--;
301 TryEndTest(); 308 TryEndTest();
302 } 309 }
303 310
304 TextureMailbox LayerTreePixelTest::CopyBitmapToTextureMailboxAsTexture( 311 void LayerTreePixelTest::CopyBitmapToTextureMailboxAsTexture(
305 const SkBitmap& bitmap) { 312 const SkBitmap& bitmap,
313 TextureMailbox* texture_mailbox,
314 scoped_ptr<ScopedReleaseCallback>* release_callback) {
306 DCHECK_GT(bitmap.width(), 0); 315 DCHECK_GT(bitmap.width(), 0);
307 DCHECK_GT(bitmap.height(), 0); 316 DCHECK_GT(bitmap.height(), 0);
308 317
309 CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL)); 318 CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL));
310 319
311 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; 320 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
312 scoped_ptr<WebKit::WebGraphicsContext3D> context3d( 321 scoped_ptr<WebKit::WebGraphicsContext3D> context3d(
313 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( 322 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
314 WebKit::WebGraphicsContext3D::Attributes())); 323 WebKit::WebGraphicsContext3D::Attributes()));
315 324
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 GL_UNSIGNED_BYTE, 366 GL_UNSIGNED_BYTE,
358 gl_pixels.get()); 367 gl_pixels.get());
359 } 368 }
360 369
361 gpu::Mailbox mailbox; 370 gpu::Mailbox mailbox;
362 context3d->genMailboxCHROMIUM(mailbox.name); 371 context3d->genMailboxCHROMIUM(mailbox.name);
363 context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 372 context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
364 context3d->bindTexture(GL_TEXTURE_2D, 0); 373 context3d->bindTexture(GL_TEXTURE_2D, 0);
365 uint32 sync_point = context3d->insertSyncPoint(); 374 uint32 sync_point = context3d->insertSyncPoint();
366 375
367 return TextureMailbox( 376 *texture_mailbox = TextureMailbox(mailbox, sync_point);
368 mailbox, 377 *release_callback = ScopedReleaseCallback::Create(
369 base::Bind(&LayerTreePixelTest::ReleaseTextureMailbox, 378 base::Bind(&LayerTreePixelTest::ReleaseTextureMailbox,
370 base::Unretained(this), 379 base::Unretained(this),
371 base::Passed(&context3d), 380 base::Passed(&context3d),
372 texture_id), 381 texture_id));
373 sync_point);
374 } 382 }
375 383
376 } // namespace cc 384 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698