SampleApp: Remove SkWindow::setColorType
Remove SkWindow::setColorType, it is used wrong and inconsistently.
The color type is actually property of window backbuffer, used when the
window is painted with software. This is as opposed to a generic window
property that would affect all operation.
Similar to MSAA sample count for window GPU backbuffer, the bitmap
backbuffer color type should be a parameter of "attach" or "create
window" functions, should this property ever be added back.
The apps use the call wrong, setting the type as kRGBA_8888
or kBGRRA_8888 without no apparent rationale. These color types
are incorrect, as the raster surface can not work with these.
Reorganize the SkWindow::resize, since no change in SkWindow backbuffer size does not neccessarily mean that SkView would not need the call.
Do not show the sw backbuffer color type in SampleApp title, as
it does not really provide any information. On small screens,
kBGRA_8888_ColorType fills up the whole title.
BUG=skia:4733
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1595503002
Review URL: https://codereview.chromium.org/1595503002
diff --git a/example/HelloWorld.cpp b/example/HelloWorld.cpp
index c7c6bcd..6833a33 100644
--- a/example/HelloWorld.cpp
+++ b/example/HelloWorld.cpp
@@ -59,7 +59,6 @@
}
bool HelloWorldWindow::setUpBackend() {
- this->setColorType(kRGBA_8888_SkColorType);
this->setVisibleP(true);
this->setClipToBounds(false);
diff --git a/experimental/SkV8Example/SkV8Example.cpp b/experimental/SkV8Example/SkV8Example.cpp
index 03a8826..fe205d7 100644
--- a/experimental/SkV8Example/SkV8Example.cpp
+++ b/experimental/SkV8Example/SkV8Example.cpp
@@ -52,7 +52,6 @@
, fCurSurface(NULL)
#endif
{
- this->setColorType(kBGRA_8888_SkColorType);
this->setVisibleP(true);
this->setClipToBounds(false);
diff --git a/experimental/iOSSampleApp/Shared/SkUIView.mm b/experimental/iOSSampleApp/Shared/SkUIView.mm
index e2dce54..df55619 100644
--- a/experimental/iOSSampleApp/Shared/SkUIView.mm
+++ b/experimental/iOSSampleApp/Shared/SkUIView.mm
@@ -1,3 +1,9 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
#import "SkUIView.h"
#include "SkCanvas.h"
#include "SkCGUtils.h"
@@ -29,8 +35,7 @@
- (void)setUpWindow {
if (NULL != fWind) {
fWind->setVisibleP(true);
- fWind->resize(self.frame.size.width, self.frame.size.height,
- kN32_SkColorType);
+ fWind->resize(self.frame.size.width, self.frame.size.height);
}
}
diff --git a/experimental/iOSSampleApp/SkSampleUIView.mm b/experimental/iOSSampleApp/SkSampleUIView.mm
index f2a8977..0c5209f 100644
--- a/experimental/iOSSampleApp/SkSampleUIView.mm
+++ b/experimental/iOSSampleApp/SkSampleUIView.mm
@@ -326,8 +326,7 @@
fDevManager = new SkiOSDeviceManager(fGL.fFramebuffer);
fWind = new SampleWindow(self, argc, argv, fDevManager);
- fWind->resize(self.frame.size.width, self.frame.size.height,
- kN32_SkColorType);
+ fWind->resize(self.frame.size.width, self.frame.size.height);
for (int i = 0; i < argc; ++i) {
delete [] argv[i];
diff --git a/include/views/SkWindow.h b/include/views/SkWindow.h
index 0d47875..6db85a4 100644
--- a/include/views/SkWindow.h
+++ b/include/views/SkWindow.h
@@ -43,8 +43,7 @@
const SkBitmap& getBitmap() const { return fBitmap; }
- void setColorType(SkColorType);
- void resize(int width, int height, SkColorType = kUnknown_SkColorType);
+ void resize(int width, int height);
bool isDirty() const { return !fDirtyRgn.isEmpty(); }
bool update(SkIRect* updateArea);
@@ -96,7 +95,6 @@
private:
SkSurfaceProps fSurfaceProps;
- SkColorType fColorType;
SkBitmap fBitmap;
SkRegion fDirtyRgn;
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index a3a81d8..65e3c17 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -1982,9 +1982,6 @@
title.prepend(gDeviceTypePrefix[fDeviceType]);
- title.prepend(" ");
- title.prepend(sk_tool_utils::colortype_name(this->getBitmap().colorType()));
-
if (fTilingMode != kNo_Tiling) {
title.prependf("<T: %s> ", gTilingInfo[fTilingMode].label);
}
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index d93bc96..0e6da0b 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -20,7 +20,6 @@
{
fClicks.reset();
fWaitingOnInval = false;
- fColorType = kN32_SkColorType;
fMatrix.reset();
}
@@ -53,22 +52,13 @@
this->setMatrix(m);
}
-void SkWindow::setColorType(SkColorType ct) {
- this->resize(fBitmap.width(), fBitmap.height(), ct);
-}
-
-void SkWindow::resize(int width, int height, SkColorType ct) {
- if (ct == kUnknown_SkColorType)
- ct = fColorType;
-
- if (width != fBitmap.width() || height != fBitmap.height() || ct != fColorType) {
- fColorType = ct;
- fBitmap.allocPixels(SkImageInfo::Make(width, height,
- ct, kPremul_SkAlphaType));
-
- this->setSize(SkIntToScalar(width), SkIntToScalar(height));
+void SkWindow::resize(int width, int height) {
+ if (width != fBitmap.width() || height != fBitmap.height()) {
+ fBitmap.allocPixels(SkImageInfo::Make(width, height, kN32_SkColorType,
+ kPremul_SkAlphaType));
this->inval(nullptr);
}
+ this->setSize(SkIntToScalar(width), SkIntToScalar(height));
}
bool SkWindow::handleInval(const SkRect* localR) {
diff --git a/src/views/mac/SkNSView.mm b/src/views/mac/SkNSView.mm
index a8376e6..ada79f8 100644
--- a/src/views/mac/SkNSView.mm
+++ b/src/views/mac/SkNSView.mm
@@ -56,8 +56,7 @@
#if RETINA_API_AVAILABLE
size = [self convertSizeToBacking:self.frame.size];
#endif
- fWind->resize((int) size.width, (int) size.height,
- kN32_SkColorType);
+ fWind->resize((int) size.width, (int) size.height);
[[self window] setAcceptsMouseMovedEvents:YES];
}
}
diff --git a/tools/VisualBench/VisualBench.cpp b/tools/VisualBench/VisualBench.cpp
index 476ac16..6d0268a 100644
--- a/tools/VisualBench/VisualBench.cpp
+++ b/tools/VisualBench/VisualBench.cpp
@@ -86,7 +86,6 @@
}
bool VisualBench::setupBackend() {
- this->setColorType(kRGBA_8888_SkColorType);
this->setVisibleP(true);
this->setClipToBounds(false);