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

Side by Side Diff: src/core/SkSpecialImage.cpp

Issue 1789663002: sRGB support in Ganesh. Several pieces: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 4 years, 9 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
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkImage_Base.h" 9 #include "SkImage_Base.h"
10 #include "SkSpecialImage.h" 10 #include "SkSpecialImage.h"
11 #include "SkSpecialSurface.h" 11 #include "SkSpecialSurface.h"
12 12
13 #include "GrContext.h"
14
13 /////////////////////////////////////////////////////////////////////////////// 15 ///////////////////////////////////////////////////////////////////////////////
14 class SkSpecialImage_Base : public SkSpecialImage { 16 class SkSpecialImage_Base : public SkSpecialImage {
15 public: 17 public:
16 SkSpecialImage_Base(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint 32_t uniqueID) 18 SkSpecialImage_Base(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint 32_t uniqueID)
17 : INHERITED(proxy, subset, uniqueID) { 19 : INHERITED(proxy, subset, uniqueID) {
18 } 20 }
19 virtual ~SkSpecialImage_Base() { } 21 virtual ~SkSpecialImage_Base() { }
20 22
21 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const = 0; 23 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const = 0;
22 24
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 161 }
160 162
161 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { 163 bool testingOnlyOnGetROPixels(SkBitmap* result) const override {
162 return fImage->asLegacyBitmap(result, SkImage::kRO_LegacyBitmapMode); 164 return fImage->asLegacyBitmap(result, SkImage::kRO_LegacyBitmapMode);
163 } 165 }
164 166
165 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { 167 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override {
166 #if SK_SUPPORT_GPU 168 #if SK_SUPPORT_GPU
167 GrTexture* texture = as_IB(fImage.get())->peekTexture(); 169 GrTexture* texture = as_IB(fImage.get())->peekTexture();
168 if (texture) { 170 if (texture) {
169 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info); 171 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *texture->getCon text()->caps());
170 desc.fFlags = kRenderTarget_GrSurfaceFlag; 172 desc.fFlags = kRenderTarget_GrSurfaceFlag;
171 173
172 return SkSpecialSurface::NewRenderTarget(this->proxy(), texture->get Context(), desc); 174 return SkSpecialSurface::NewRenderTarget(this->proxy(), texture->get Context(), desc);
173 } 175 }
174 #endif 176 #endif
175 return SkSpecialSurface::NewRaster(this->proxy(), info, nullptr); 177 return SkSpecialSurface::NewRaster(this->proxy(), info, nullptr);
176 } 178 }
177 179
178 SkSpecialImage* onExtractSubset(const SkIRect& subset) const override { 180 SkSpecialImage* onExtractSubset(const SkIRect& subset) const override {
179 SkAutoTUnref<SkImage> subsetImg(fImage->newSubset(subset)); 181 SkAutoTUnref<SkImage> subsetImg(fImage->newSubset(subset));
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 if (!fTexture->readPixels(0, 0, result->width(), result->height(), kSkia 8888_GrPixelConfig, 379 if (!fTexture->readPixels(0, 0, result->width(), result->height(), kSkia 8888_GrPixelConfig,
378 result->getPixels(), result->rowBytes())) { 380 result->getPixels(), result->rowBytes())) {
379 return false; 381 return false;
380 } 382 }
381 383
382 result->pixelRef()->setImmutable(); 384 result->pixelRef()->setImmutable();
383 return true; 385 return true;
384 } 386 }
385 387
386 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { 388 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override {
387 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info); 389 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *fTexture->getContex t()->caps());
388 desc.fFlags = kRenderTarget_GrSurfaceFlag; 390 desc.fFlags = kRenderTarget_GrSurfaceFlag;
389 391
390 return SkSpecialSurface::NewRenderTarget(this->proxy(), fTexture->getCon text(), desc); 392 return SkSpecialSurface::NewRenderTarget(this->proxy(), fTexture->getCon text(), desc);
391 } 393 }
392 394
393 SkSpecialImage* onExtractSubset(const SkIRect& subset) const override { 395 SkSpecialImage* onExtractSubset(const SkIRect& subset) const override {
394 return SkSpecialImage::NewFromGpu(this->internal_getProxy(), 396 return SkSpecialImage::NewFromGpu(this->internal_getProxy(),
395 subset, 397 subset,
396 this->uniqueID(), 398 this->uniqueID(),
397 fTexture, 399 fTexture,
(...skipping 20 matching lines...) Expand all
418 420
419 SkSpecialImage* SkSpecialImage::NewFromGpu(SkImageFilter::Proxy* proxy, 421 SkSpecialImage* SkSpecialImage::NewFromGpu(SkImageFilter::Proxy* proxy,
420 const SkIRect& subset, 422 const SkIRect& subset,
421 uint32_t uniqueID, 423 uint32_t uniqueID,
422 GrTexture* tex, 424 GrTexture* tex,
423 SkAlphaType at) { 425 SkAlphaType at) {
424 return nullptr; 426 return nullptr;
425 } 427 }
426 428
427 #endif 429 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698