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

Side by Side Diff: services/gfx/compositor/render/render_image.cc

Issue 1552963002: Initial checkin of the new Mozart compositor. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-11
Patch Set: Created 4 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef GL_GLEXT_PROTOTYPES
6 #define GL_GLEXT_PROTOTYPES
7 #endif
8
9 #include "services/gfx/compositor/render/render_image.h"
10
11 #include "base/bind.h"
12 #include "base/location.h"
13 #include "base/logging.h"
14 #include "mojo/skia/ganesh_helpers.h"
15 #include "third_party/skia/include/core/SkImage.h"
16
17 namespace compositor {
18
19 static void DeleteTexture(GLuint texture_id) {
20 glDeleteTextures(1, &texture_id);
21 }
22
23 RenderImage::RenderImage(const uint8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM],
24 uint32_t sync_point,
25 uint32_t width,
26 uint32_t height,
27 const scoped_refptr<base::TaskRunner>& task_runner,
28 const base::Closure& release_task)
29 : sync_point_(sync_point),
30 width_(width),
31 height_(height),
32 task_runner_(task_runner),
33 release_task_(release_task) {
34 DCHECK(mailbox_name);
35 DCHECK(width_);
36 DCHECK(height_);
37 DCHECK(task_runner_);
38 memcpy(mailbox_name_, mailbox_name, GL_MAILBOX_SIZE_CHROMIUM);
39 }
40
41 RenderImage::~RenderImage() {
42 task_runner_->PostTask(FROM_HERE, release_task_);
43 }
44
45 // Creates a Skia image for this rendr image.
46 // Automatically inserts a sync point into the GL command stream.
47 skia::RefPtr<SkImage> RenderImage::CreateSkImage(
48 const PaintingScope& painting_scope) const {
49 if (sync_point_)
50 glWaitSyncPointCHROMIUM(sync_point_);
51
52 GLuint texture_id =
53 glCreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name_);
54 if (!texture_id)
55 return skia::RefPtr<SkImage>();
56
57 return mojo::skia::CreateImageFromTexture(
58 painting_scope.ganesh_scope(), texture_id, width_, height_,
59 base::Bind(&DeleteTexture, texture_id));
60 }
61
62 } // namespace compositor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698