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

Side by Side Diff: src/image/SkSurface_Gpu.cpp

Issue 359953002: Revert of Begin atlasing (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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 | « src/gpu/SkGpuDevice.cpp ('k') | tests/GpuLayerCacheTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_Base.h" 8 #include "SkSurface_Base.h"
9 #include "SkImagePriv.h" 9 #include "SkImagePriv.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkGpuDevice.h" 11 #include "SkGpuDevice.h"
12 12
13 class SkSurface_Gpu : public SkSurface_Base { 13 class SkSurface_Gpu : public SkSurface_Base {
14 public: 14 public:
15 SK_DECLARE_INST_COUNT(SkSurface_Gpu) 15 SK_DECLARE_INST_COUNT(SkSurface_Gpu)
16 16
17 SkSurface_Gpu(GrRenderTarget*, bool cached, TextRenderMode trm, 17 SkSurface_Gpu(GrRenderTarget*, bool cached, TextRenderMode trm);
18 SkSurface::RenderTargetFlags flags);
19 virtual ~SkSurface_Gpu(); 18 virtual ~SkSurface_Gpu();
20 19
21 virtual SkCanvas* onNewCanvas() SK_OVERRIDE; 20 virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
22 virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE; 21 virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE;
23 virtual SkImage* onNewImageSnapshot() SK_OVERRIDE; 22 virtual SkImage* onNewImageSnapshot() SK_OVERRIDE;
24 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, 23 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y,
25 const SkPaint*) SK_OVERRIDE; 24 const SkPaint*) SK_OVERRIDE;
26 virtual void onCopyOnWrite(ContentChangeMode) SK_OVERRIDE; 25 virtual void onCopyOnWrite(ContentChangeMode) SK_OVERRIDE;
27 virtual void onDiscard() SK_OVERRIDE; 26 virtual void onDiscard() SK_OVERRIDE;
28 27
29 private: 28 private:
30 SkGpuDevice* fDevice; 29 SkGpuDevice* fDevice;
31 30
32 typedef SkSurface_Base INHERITED; 31 typedef SkSurface_Base INHERITED;
33 }; 32 };
34 33
35 /////////////////////////////////////////////////////////////////////////////// 34 ///////////////////////////////////////////////////////////////////////////////
36 35
37 SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, bool cached, TextRend erMode trm, 36 SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, bool cached, TextRend erMode trm)
38 SkSurface::RenderTargetFlags flags)
39 : INHERITED(renderTarget->width(), renderTarget->height()) { 37 : INHERITED(renderTarget->width(), renderTarget->height()) {
40 int deviceFlags = 0; 38 int flags = 0;
41 deviceFlags |= cached ? SkGpuDevice::kCached_Flag : 0; 39 flags |= cached ? SkGpuDevice::kCached_Flag : 0;
42 deviceFlags |= (kDistanceField_TextRenderMode == trm) ? SkGpuDevice::kDFFont s_Flag : 0; 40 flags |= (kDistanceField_TextRenderMode == trm) ? SkGpuDevice::kDFFonts_Flag : 0;
43 fDevice = SkGpuDevice::Create(renderTarget, deviceFlags); 41 fDevice = SkGpuDevice::Create(renderTarget, flags);
44 42
45 if (kRGB_565_GrPixelConfig != renderTarget->config() && 43 if (kRGB_565_GrPixelConfig != renderTarget->config()) {
46 !(flags & kDontClear_RenderTargetFlag)) {
47 fDevice->clear(0x0); 44 fDevice->clear(0x0);
48 } 45 }
49 } 46 }
50 47
51 SkSurface_Gpu::~SkSurface_Gpu() { 48 SkSurface_Gpu::~SkSurface_Gpu() {
52 SkSafeUnref(fDevice); 49 SkSafeUnref(fDevice);
53 } 50 }
54 51
55 SkCanvas* SkSurface_Gpu::onNewCanvas() { 52 SkCanvas* SkSurface_Gpu::onNewCanvas() {
56 return SkNEW_ARGS(SkCanvas, (fDevice)); 53 return SkNEW_ARGS(SkCanvas, (fDevice));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 this->SkSurface_Gpu::onDiscard(); 94 this->SkSurface_Gpu::onDiscard();
98 } 95 }
99 } 96 }
100 97
101 void SkSurface_Gpu::onDiscard() { 98 void SkSurface_Gpu::onDiscard() {
102 fDevice->accessRenderTarget()->discard(); 99 fDevice->accessRenderTarget()->discard();
103 } 100 }
104 101
105 /////////////////////////////////////////////////////////////////////////////// 102 ///////////////////////////////////////////////////////////////////////////////
106 103
107 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, TextRenderMo de trm, 104 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, TextRenderMo de trm) {
108 RenderTargetFlags flags) {
109 if (NULL == target) { 105 if (NULL == target) {
110 return NULL; 106 return NULL;
111 } 107 }
112 return SkNEW_ARGS(SkSurface_Gpu, (target, false, trm, flags)); 108 return SkNEW_ARGS(SkSurface_Gpu, (target, false, trm));
113 } 109 }
114 110
115 SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, i nt sampleCount, 111 SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, i nt sampleCount,
116 TextRenderMode trm, RenderTargetFlags flag s) { 112 TextRenderMode trm) {
117 if (NULL == ctx) { 113 if (NULL == ctx) {
118 return NULL; 114 return NULL;
119 } 115 }
120 116
121 GrTextureDesc desc; 117 GrTextureDesc desc;
122 desc.fFlags = kRenderTarget_GrTextureFlagBit | kCheckAllocation_GrTextureFla gBit; 118 desc.fFlags = kRenderTarget_GrTextureFlagBit | kCheckAllocation_GrTextureFla gBit;
123 desc.fWidth = info.width(); 119 desc.fWidth = info.width();
124 desc.fHeight = info.height(); 120 desc.fHeight = info.height();
125 desc.fConfig = SkImageInfo2GrPixelConfig(info); 121 desc.fConfig = SkImageInfo2GrPixelConfig(info);
126 desc.fSampleCnt = sampleCount; 122 desc.fSampleCnt = sampleCount;
127 123
128 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0)); 124 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0));
129 if (NULL == tex) { 125 if (NULL == tex) {
130 return NULL; 126 return NULL;
131 } 127 }
132 128
133 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false, trm, flags)) ; 129 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false, trm));
134 } 130 }
135 131
136 SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo& info, 132 SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo& info,
137 int sampleCount, TextRenderMode trm , 133 int sampleCount, TextRenderMode trm ) {
138 RenderTargetFlags flags) {
139 if (NULL == ctx) { 134 if (NULL == ctx) {
140 return NULL; 135 return NULL;
141 } 136 }
142 137
143 GrTextureDesc desc; 138 GrTextureDesc desc;
144 desc.fFlags = kRenderTarget_GrTextureFlagBit | kCheckAllocation_GrTextureFla gBit; 139 desc.fFlags = kRenderTarget_GrTextureFlagBit | kCheckAllocation_GrTextureFla gBit;
145 desc.fWidth = info.width(); 140 desc.fWidth = info.width();
146 desc.fHeight = info.height(); 141 desc.fHeight = info.height();
147 desc.fConfig = SkImageInfo2GrPixelConfig(info); 142 desc.fConfig = SkImageInfo2GrPixelConfig(info);
148 desc.fSampleCnt = sampleCount; 143 desc.fSampleCnt = sampleCount;
149 144
150 SkAutoTUnref<GrTexture> tex(ctx->lockAndRefScratchTexture(desc, GrContext::k Exact_ScratchTexMatch)); 145 SkAutoTUnref<GrTexture> tex(ctx->lockAndRefScratchTexture(desc, GrContext::k Exact_ScratchTexMatch));
151 146
152 if (NULL == tex) { 147 if (NULL == tex) {
153 return NULL; 148 return NULL;
154 } 149 }
155 150
156 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, trm, flags)); 151 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, trm));
157 } 152 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | tests/GpuLayerCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698