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

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

Issue 2011713003: Roll skia to 8cc209111876b7c78b5ec577c9221d8ed5e21024 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 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
« no previous file with comments | « mojo/skia/ganesh_image_factory.h ('k') | mojo/skia/ganesh_texture_surface.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef GL_GLEXT_PROTOTYPES 5 #ifndef GL_GLEXT_PROTOTYPES
6 #define GL_GLEXT_PROTOTYPES 6 #define GL_GLEXT_PROTOTYPES
7 #endif 7 #endif
8 8
9 #include "mojo/skia/ganesh_image_factory.h" 9 #include "mojo/skia/ganesh_image_factory.h"
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "third_party/skia/include/core/SkImage.h" 12 #include "third_party/skia/include/core/SkImage.h"
13 #include "third_party/skia/include/gpu/GrContext.h" 13 #include "third_party/skia/include/gpu/GrContext.h"
14 #include "third_party/skia/include/gpu/GrTextureProvider.h" 14 #include "third_party/skia/include/gpu/GrTextureProvider.h"
15 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" 15 #include "third_party/skia/include/gpu/gl/GrGLTypes.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 namespace skia { 18 namespace skia {
19 namespace { 19 namespace {
20 void ReleaseThunk(void* data) { 20 void ReleaseThunk(void* data) {
21 auto release_callback = static_cast<base::Closure*>(data); 21 auto release_callback = static_cast<base::Closure*>(data);
22 release_callback->Run(); 22 release_callback->Run();
23 delete release_callback; 23 delete release_callback;
24 } 24 }
25 } // namespace 25 } // namespace
26 26
27 ::skia::RefPtr<SkImage> CreateImageFromTexture( 27 sk_sp<SkImage> CreateImageFromTexture(const GaneshContext::Scope& scope,
28 const GaneshContext::Scope& scope, 28 uint32_t texture_id,
29 uint32_t texture_id, 29 uint32_t width,
30 uint32_t width, 30 uint32_t height,
31 uint32_t height, 31 GrSurfaceOrigin origin,
32 GrSurfaceOrigin origin, 32 const base::Closure& release_callback) {
33 const base::Closure& release_callback) {
34 DCHECK(texture_id); 33 DCHECK(texture_id);
35 DCHECK(width); 34 DCHECK(width);
36 DCHECK(height); 35 DCHECK(height);
37 36
38 // TODO(jeffbrown): Give the caller more control over these parameters. 37 // TODO(jeffbrown): Give the caller more control over these parameters.
39 GrGLTextureInfo info; 38 GrGLTextureInfo info;
40 info.fTarget = GL_TEXTURE_2D; 39 info.fTarget = GL_TEXTURE_2D;
41 info.fID = texture_id; 40 info.fID = texture_id;
42 41
43 GrBackendTextureDesc desc; 42 GrBackendTextureDesc desc;
44 desc.fFlags = kNone_GrBackendTextureFlag; 43 desc.fFlags = kNone_GrBackendTextureFlag;
45 desc.fWidth = width; 44 desc.fWidth = width;
46 desc.fHeight = height; 45 desc.fHeight = height;
47 desc.fConfig = kSkia8888_GrPixelConfig; 46 desc.fConfig = kSkia8888_GrPixelConfig;
48 desc.fOrigin = origin; 47 desc.fOrigin = origin;
49 desc.fTextureHandle = reinterpret_cast<GrBackendObject>(&info); 48 desc.fTextureHandle = reinterpret_cast<GrBackendObject>(&info);
50 return ::skia::AdoptRef(SkImage::NewFromTexture( 49 return SkImage::MakeFromTexture(scope.gr_context().get(), desc,
51 scope.gr_context().get(), desc, kPremul_SkAlphaType, &ReleaseThunk, 50 kPremul_SkAlphaType, &ReleaseThunk,
52 new base::Closure(release_callback))); 51 new base::Closure(release_callback));
53 } 52 }
54 53
55 MailboxTextureImageGenerator::MailboxTextureImageGenerator( 54 MailboxTextureImageGenerator::MailboxTextureImageGenerator(
56 const GLbyte mailbox_name[GL_MAILBOX_SIZE_CHROMIUM], 55 const GLbyte mailbox_name[GL_MAILBOX_SIZE_CHROMIUM],
57 GLuint sync_point, 56 GLuint sync_point,
58 uint32_t width, 57 uint32_t width,
59 uint32_t height, 58 uint32_t height,
60 GrSurfaceOrigin origin) 59 GrSurfaceOrigin origin)
61 : SkImageGenerator(SkImageInfo::MakeN32Premul(width, height)), 60 : SkImageGenerator(SkImageInfo::MakeN32Premul(width, height)),
62 sync_point_(sync_point), 61 sync_point_(sync_point),
(...skipping 26 matching lines...) Expand all
89 desc.fHeight = getInfo().height(); 88 desc.fHeight = getInfo().height();
90 desc.fConfig = kSkia8888_GrPixelConfig; 89 desc.fConfig = kSkia8888_GrPixelConfig;
91 desc.fOrigin = origin_; 90 desc.fOrigin = origin_;
92 desc.fTextureHandle = reinterpret_cast<GrBackendObject>(&info); 91 desc.fTextureHandle = reinterpret_cast<GrBackendObject>(&info);
93 return context->textureProvider()->wrapBackendTexture(desc, 92 return context->textureProvider()->wrapBackendTexture(desc,
94 kAdopt_GrWrapOwnership); 93 kAdopt_GrWrapOwnership);
95 } 94 }
96 95
97 } // namespace skia 96 } // namespace skia
98 } // namespace mojo 97 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/skia/ganesh_image_factory.h ('k') | mojo/skia/ganesh_texture_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698