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 #include "SkSurface_Gpu.h" | 8 #include "SkSurface_Gpu.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 SkCanvas* SkSurface_Gpu::onNewCanvas() { | 30 SkCanvas* SkSurface_Gpu::onNewCanvas() { |
31 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags; | 31 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags; |
32 // When we think this works... | 32 // When we think this works... |
33 // flags |= SkCanvas::kConservativeRasterClip_InitFlag; | 33 // flags |= SkCanvas::kConservativeRasterClip_InitFlag; |
34 | 34 |
35 return SkNEW_ARGS(SkCanvas, (fDevice, &this->props(), flags)); | 35 return SkNEW_ARGS(SkCanvas, (fDevice, &this->props(), flags)); |
36 } | 36 } |
37 | 37 |
38 SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) { | 38 SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) { |
39 GrRenderTarget* rt = fDevice->accessRenderTarget(); | 39 GrRenderTarget* rt = fDevice->accessRenderTarget(); |
40 int sampleCount = rt->numSamples(); | 40 int sampleCount = rt->numColorSamples(); |
41 // TODO: Make caller specify this (change virtual signature of onNewSurface)
. | 41 // TODO: Make caller specify this (change virtual signature of onNewSurface)
. |
42 static const Budgeted kBudgeted = kNo_Budgeted; | 42 static const Budgeted kBudgeted = kNo_Budgeted; |
43 return SkSurface::NewRenderTarget(fDevice->context(), kBudgeted, info, sampl
eCount, | 43 return SkSurface::NewRenderTarget(fDevice->context(), kBudgeted, info, sampl
eCount, |
44 &this->props()); | 44 &this->props()); |
45 } | 45 } |
46 | 46 |
47 SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted) { | 47 SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted) { |
48 const SkImageInfo info = fDevice->imageInfo(); | 48 const SkImageInfo info = fDevice->imageInfo(); |
49 const int sampleCount = fDevice->accessRenderTarget()->numSamples(); | 49 const int sampleCount = fDevice->accessRenderTarget()->numColorSamples(); |
50 SkImage* image = NULL; | 50 SkImage* image = NULL; |
51 GrTexture* tex = fDevice->accessRenderTarget()->asTexture(); | 51 GrTexture* tex = fDevice->accessRenderTarget()->asTexture(); |
52 if (tex) { | 52 if (tex) { |
53 image = SkNEW_ARGS(SkImage_Gpu, | 53 image = SkNEW_ARGS(SkImage_Gpu, |
54 (info.width(), info.height(), info.alphaType(), | 54 (info.width(), info.height(), info.alphaType(), |
55 tex, sampleCount, budgeted)); | 55 tex, sampleCount, budgeted)); |
56 } | 56 } |
57 if (image) { | 57 if (image) { |
58 as_IB(image)->initWithProps(this->props()); | 58 as_IB(image)->initWithProps(this->props()); |
59 } | 59 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 115 } |
116 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(surface->asRenderTarget
(), props, | 116 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(surface->asRenderTarget
(), props, |
117 SkGpuDevice::kNeedClear
_Flag)); | 117 SkGpuDevice::kNeedClear
_Flag)); |
118 if (!device) { | 118 if (!device) { |
119 return NULL; | 119 return NULL; |
120 } | 120 } |
121 return SkNEW_ARGS(SkSurface_Gpu, (device)); | 121 return SkNEW_ARGS(SkSurface_Gpu, (device)); |
122 } | 122 } |
123 | 123 |
124 #endif | 124 #endif |
OLD | NEW |