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

Side by Side Diff: mojo/skia/ganesh_helpers.cc

Issue 1534033002: Improve Ganesh helpers. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-8
Patch Set: rebase 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 2014 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 #include "mojo/skia/ganesh_helpers.h"
6
7 #include <GLES2/gl2.h>
8
9 #include "base/logging.h"
10 #include "third_party/skia/include/core/SkImage.h"
11 #include "third_party/skia/include/gpu/gl/GrGLTypes.h"
12
13 namespace mojo {
14 namespace skia {
15
16 static void ReleaseThunk(void* data) {
17 auto release_callback = static_cast<base::Closure*>(data);
18 release_callback->Run();
19 delete release_callback;
20 }
21
22 ::skia::RefPtr<SkImage> CreateImageFromTexture(
23 const GaneshContext::Scope& scope,
24 uint32_t texture_id,
25 uint32_t width,
26 uint32_t height,
27 const base::Closure& release_callback) {
28 DCHECK(texture_id);
29 DCHECK(width);
30 DCHECK(height);
31
32 // TODO(jeffbrown): Give the caller more control over these parameters
33 // as required.
34 GrGLTextureInfo info;
35 info.fTarget = GL_TEXTURE_2D;
36 info.fID = texture_id;
37
38 GrBackendTextureDesc desc;
39 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
40 desc.fWidth = width;
41 desc.fHeight = height;
42 desc.fConfig = kSkia8888_GrPixelConfig;
43 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
44 desc.fTextureHandle = reinterpret_cast<GrBackendObject>(&info);
45 return ::skia::AdoptRef(SkImage::NewFromTexture(
46 scope.gr_context(), desc, kPremul_SkAlphaType, &ReleaseThunk,
47 new base::Closure(release_callback)));
48 }
49
50 } // namespace skia
51 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698