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

Side by Side Diff: components/display_compositor/buffer_queue.cc

Issue 2465093002: cc: Add OutputSurface state snapshots.
Patch Set: nits Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/display_compositor/buffer_queue.h" 5 #include "components/display_compositor/buffer_queue.h"
6 6
7 #include "base/containers/adapters.h" 7 #include "base/containers/adapters.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "components/display_compositor/gl_helper.h" 10 #include "components/display_compositor/gl_helper.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 return nullptr; 236 return nullptr;
237 } 237 }
238 238
239 allocated_count_++; 239 allocated_count_++;
240 gl_->BindTexture(texture_target_, texture); 240 gl_->BindTexture(texture_target_, texture);
241 gl_->BindTexImage2DCHROMIUM(texture_target_, id); 241 gl_->BindTexImage2DCHROMIUM(texture_target_, id);
242 return base::MakeUnique<AllocatedSurface>(this, std::move(buffer), texture, 242 return base::MakeUnique<AllocatedSurface>(this, std::move(buffer), texture,
243 id, gfx::Rect(size_)); 243 id, gfx::Rect(size_));
244 } 244 }
245 245
246 void BufferQueue::ReadbackDisplayedFramebuffer(
247 SkBitmap* bitmap,
248 const base::Callback<void(bool)>& callback) {
249 if (!displayed_surface_) {
250 callback.Run(false);
251 return;
252 }
253 GLuint texture = gl_helper_->CreateTexture();
254 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
255 gl_->CopyTextureCHROMIUM(displayed_surface_->texture, texture, GL_RGBA,
256 GL_UNSIGNED_BYTE, false, false, false);
257 bitmap->allocN32Pixels(size_.width(), size_.height());
258 gl_helper_->ReadbackTextureAsync(
259 texture, size_, static_cast<unsigned char*>(bitmap->getPixels()),
260 kRGBA_8888_SkColorType, callback);
261 gl_helper_->DeleteTexture(texture);
262 }
263
246 BufferQueue::AllocatedSurface::AllocatedSurface( 264 BufferQueue::AllocatedSurface::AllocatedSurface(
247 BufferQueue* buffer_queue, 265 BufferQueue* buffer_queue,
248 std::unique_ptr<gfx::GpuMemoryBuffer> buffer, 266 std::unique_ptr<gfx::GpuMemoryBuffer> buffer,
249 uint32_t texture, 267 uint32_t texture,
250 uint32_t image, 268 uint32_t image,
251 const gfx::Rect& rect) 269 const gfx::Rect& rect)
252 : buffer_queue(buffer_queue), 270 : buffer_queue(buffer_queue),
253 buffer(buffer.release()), 271 buffer(buffer.release()),
254 texture(texture), 272 texture(texture),
255 image(image), 273 image(image),
256 damage(rect) {} 274 damage(rect) {}
257 275
258 BufferQueue::AllocatedSurface::~AllocatedSurface() { 276 BufferQueue::AllocatedSurface::~AllocatedSurface() {
259 buffer_queue->FreeSurfaceResources(this); 277 buffer_queue->FreeSurfaceResources(this);
260 } 278 }
261 279
262 } // namespace display_compositor 280 } // namespace display_compositor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698