| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkSurface_DEFINED | 8 #ifndef SkSurface_DEFINED |
| 9 #define SkSurface_DEFINED | 9 #define SkSurface_DEFINED |
| 10 | 10 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 * pixels in SkPMColor format. | 75 * pixels in SkPMColor format. |
| 76 */ | 76 */ |
| 77 static sk_sp<SkSurface> MakeRasterN32Premul(int width, int height, | 77 static sk_sp<SkSurface> MakeRasterN32Premul(int width, int height, |
| 78 const SkSurfaceProps* props = nu
llptr) { | 78 const SkSurfaceProps* props = nu
llptr) { |
| 79 return MakeRaster(SkImageInfo::MakeN32Premul(width, height), props); | 79 return MakeRaster(SkImageInfo::MakeN32Premul(width, height), props); |
| 80 } | 80 } |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * Return a new surface using the specified render target. | 83 * Return a new surface using the specified render target. |
| 84 */ | 84 */ |
| 85 static sk_sp<SkSurface> MakeRenderTargetDirect(GrRenderTarget*, | 85 static sk_sp<SkSurface> MakeRenderTargetDirect(GrRenderTarget*, sk_sp<SkColo
rSpace> colorSpace, |
| 86 const SkSurfaceProps* = nullp
tr); | 86 const SkSurfaceProps* = nullp
tr); |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * Used to wrap a pre-existing backend 3D API texture as a SkSurface. The k
RenderTarget flag | 89 * Used to wrap a pre-existing backend 3D API texture as a SkSurface. The k
RenderTarget flag |
| 90 * must be set on GrBackendTextureDesc for this to succeed. Skia will not a
ssume ownership | 90 * must be set on GrBackendTextureDesc for this to succeed. Skia will not a
ssume ownership |
| 91 * of the texture and the client must ensure the texture is valid for the l
ifetime of the | 91 * of the texture and the client must ensure the texture is valid for the l
ifetime of the |
| 92 * SkSurface. | 92 * SkSurface. |
| 93 */ | 93 */ |
| 94 static sk_sp<SkSurface> MakeFromBackendTexture(GrContext*, const GrBackendTe
xtureDesc&, | 94 static sk_sp<SkSurface> MakeFromBackendTexture(GrContext*, const GrBackendTe
xtureDesc&, |
| 95 const SkSurfaceProps*); | 95 sk_sp<SkColorSpace>, const Sk
SurfaceProps*); |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * Used to wrap a pre-existing 3D API rendering target as a SkSurface. Skia
will not assume | 98 * Used to wrap a pre-existing 3D API rendering target as a SkSurface. Skia
will not assume |
| 99 * ownership of the render target and the client must ensure the render tar
get is valid for the | 99 * ownership of the render target and the client must ensure the render tar
get is valid for the |
| 100 * lifetime of the SkSurface. | 100 * lifetime of the SkSurface. |
| 101 */ | 101 */ |
| 102 static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext*, | 102 static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext*, |
| 103 const GrBackendRenderTar
getDesc&, | 103 const GrBackendRenderTar
getDesc&, |
| 104 sk_sp<SkColorSpace>, |
| 104 const SkSurfaceProps*); | 105 const SkSurfaceProps*); |
| 105 | 106 |
| 106 /** | 107 /** |
| 107 * Used to wrap a pre-existing 3D API texture as a SkSurface. Skia will tre
at the texture as | 108 * Used to wrap a pre-existing 3D API texture as a SkSurface. Skia will tre
at the texture as |
| 108 * a rendering target only, but unlike NewFromBackendRenderTarget, Skia wil
l manage and own | 109 * a rendering target only, but unlike NewFromBackendRenderTarget, Skia wil
l manage and own |
| 109 * the associated render target objects (but not the provided texture). The
kRenderTarget flag | 110 * the associated render target objects (but not the provided texture). The
kRenderTarget flag |
| 110 * must be set on GrBackendTextureDesc for this to succeed. Skia will not a
ssume ownership | 111 * must be set on GrBackendTextureDesc for this to succeed. Skia will not a
ssume ownership |
| 111 * of the texture and the client must ensure the texture is valid for the l
ifetime of the | 112 * of the texture and the client must ensure the texture is valid for the l
ifetime of the |
| 112 * SkSurface. | 113 * SkSurface. |
| 113 */ | 114 */ |
| 114 static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget( | 115 static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget( |
| 115 GrContext*, const GrBackendTextureDesc&, const SkSurfaceProps*); | 116 GrContext*, const GrBackendTextureDesc&, sk_sp<SkColorSpace>, const SkSu
rfaceProps*); |
| 117 |
| 118 /** |
| 119 * Legacy versions of the above factories, without color space support. Thes
e create "legacy" |
| 120 * surfaces that operate without gamma correction or color management. |
| 121 */ |
| 122 static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* ctx, const GrBacke
ndTextureDesc& desc, |
| 123 const SkSurfaceProps* props)
{ |
| 124 return MakeFromBackendTexture(ctx, desc, nullptr, props); |
| 125 } |
| 126 |
| 127 static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* ctx, |
| 128 const GrBackendRenderTar
getDesc& desc, |
| 129 const SkSurfaceProps* pr
ops) { |
| 130 return MakeFromBackendRenderTarget(ctx, desc, nullptr, props); |
| 131 } |
| 132 |
| 133 static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget( |
| 134 GrContext* ctx, const GrBackendTextureDesc& desc, const SkSurfacePro
ps* props) { |
| 135 return MakeFromBackendTextureAsRenderTarget(ctx, desc, nullptr, props); |
| 136 } |
| 137 |
| 116 | 138 |
| 117 /** | 139 /** |
| 118 * Return a new surface whose contents will be drawn to an offscreen | 140 * Return a new surface whose contents will be drawn to an offscreen |
| 119 * render target, allocated by the surface. | 141 * render target, allocated by the surface. |
| 120 */ | 142 */ |
| 121 static sk_sp<SkSurface> MakeRenderTarget( | 143 static sk_sp<SkSurface> MakeRenderTarget( |
| 122 GrContext*, SkBudgeted, const SkImageInfo&, int sampleCount, const S
kSurfaceProps*); | 144 GrContext*, SkBudgeted, const SkImageInfo&, int sampleCount, const S
kSurfaceProps*); |
| 123 | 145 |
| 124 static sk_sp<SkSurface> MakeRenderTarget(GrContext* gr, SkBudgeted b, const
SkImageInfo& info) { | 146 static sk_sp<SkSurface> MakeRenderTarget(GrContext* gr, SkBudgeted b, const
SkImageInfo& info) { |
| 125 return MakeRenderTarget(gr, b, info, 0, nullptr); | 147 return MakeRenderTarget(gr, b, info, 0, nullptr); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 142 return MakeRaster(info, rowBytes, props).release(); | 164 return MakeRaster(info, rowBytes, props).release(); |
| 143 } | 165 } |
| 144 static SkSurface* NewRaster(const SkImageInfo& info, const SkSurfaceProps* p
rops = NULL) { | 166 static SkSurface* NewRaster(const SkImageInfo& info, const SkSurfaceProps* p
rops = NULL) { |
| 145 return MakeRaster(info, props).release(); | 167 return MakeRaster(info, props).release(); |
| 146 } | 168 } |
| 147 static SkSurface* NewRasterN32Premul(int width, int height, | 169 static SkSurface* NewRasterN32Premul(int width, int height, |
| 148 const SkSurfaceProps* props = NULL) { | 170 const SkSurfaceProps* props = NULL) { |
| 149 return NewRaster(SkImageInfo::MakeN32Premul(width, height), props); | 171 return NewRaster(SkImageInfo::MakeN32Premul(width, height), props); |
| 150 } | 172 } |
| 151 static SkSurface* NewRenderTargetDirect(GrRenderTarget* rt, const SkSurfaceP
rops* props) { | 173 static SkSurface* NewRenderTargetDirect(GrRenderTarget* rt, const SkSurfaceP
rops* props) { |
| 152 return MakeRenderTargetDirect(rt, props).release(); | 174 return MakeRenderTargetDirect(rt, nullptr, props).release(); |
| 153 } | 175 } |
| 154 static SkSurface* NewRenderTargetDirect(GrRenderTarget* target) { | 176 static SkSurface* NewRenderTargetDirect(GrRenderTarget* target) { |
| 155 return NewRenderTargetDirect(target, NULL); | 177 return NewRenderTargetDirect(target, NULL); |
| 156 } | 178 } |
| 157 static SkSurface* NewFromBackendTexture(GrContext* ctx, const GrBackendTextu
reDesc& desc, | 179 static SkSurface* NewFromBackendTexture(GrContext* ctx, const GrBackendTextu
reDesc& desc, |
| 158 const SkSurfaceProps* props) { | 180 const SkSurfaceProps* props) { |
| 159 return MakeFromBackendTexture(ctx, desc, props).release(); | 181 return MakeFromBackendTexture(ctx, desc, props).release(); |
| 160 } | 182 } |
| 161 // Legacy alias | 183 // Legacy alias |
| 162 static SkSurface* NewWrappedRenderTarget(GrContext* ctx, const GrBackendText
ureDesc& desc, | 184 static SkSurface* NewWrappedRenderTarget(GrContext* ctx, const GrBackendText
ureDesc& desc, |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 private: | 393 private: |
| 372 const SkSurfaceProps fProps; | 394 const SkSurfaceProps fProps; |
| 373 const int fWidth; | 395 const int fWidth; |
| 374 const int fHeight; | 396 const int fHeight; |
| 375 uint32_t fGenerationID; | 397 uint32_t fGenerationID; |
| 376 | 398 |
| 377 typedef SkRefCnt INHERITED; | 399 typedef SkRefCnt INHERITED; |
| 378 }; | 400 }; |
| 379 | 401 |
| 380 #endif | 402 #endif |
| OLD | NEW |