Skip to content

Commit

Permalink
Clean up USE_SKIA_NEXT
Browse files Browse the repository at this point in the history
b/304784019
  • Loading branch information
sherryzy committed Dec 20, 2023
1 parent c48a104 commit 8ad20db
Show file tree
Hide file tree
Showing 20 changed files with 237 additions and 490 deletions.
4 changes: 0 additions & 4 deletions cobalt/dom/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,6 @@ static_library("dom") {
"xml_serializer.h",
]

if (use_skia_next) {
defines = [ "USE_SKIA_NEXT" ]
}

public_deps = [
":media_settings",
"//cobalt/browser:generated_types",
Expand Down
4 changes: 0 additions & 4 deletions cobalt/dom/lottie_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,7 @@ std::string LottiePlayer::preserve_aspect_ratio() const {

std::string LottiePlayer::renderer() const {
// Cobalt uses a custom compiled-in renderer.
#if defined(USE_SKIA_NEXT)
return "skottie-m97";
#else
return "skottie-m79";
#endif
}

void LottiePlayer::Load(std::string src) {
Expand Down
6 changes: 0 additions & 6 deletions cobalt/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//cobalt/renderer/rasterizer/skia/skia/skia_next.gni")

source_set("renderer_headers_only") {
sources = [
"egl_and_gles.h",
Expand Down Expand Up @@ -86,10 +84,6 @@ static_library("render_tree_pixel_tester") {
configs -= [ "//starboard/build/config:size" ]
configs += [ "//starboard/build/config:speed" ]

if (use_skia_next) {
include_dirs = [ skia_include_dir ]
}

deps = [
":renderer",
"//cobalt/base",
Expand Down
10 changes: 0 additions & 10 deletions cobalt/renderer/rasterizer/egl/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//cobalt/renderer/rasterizer/skia/skia/skia_next.gni")

static_library("software_rasterizer") {
sources = [
"software_rasterizer.cc",
Expand All @@ -25,10 +23,6 @@ static_library("software_rasterizer") {
configs -= [ "//starboard/build/config:size" ]
configs += [ "//starboard/build/config:speed" ]

if (use_skia_next) {
include_dirs = [ skia_include_dir ]
}

deps = [
"//base",
"//cobalt/math",
Expand Down Expand Up @@ -93,10 +87,6 @@ static_library("hardware_rasterizer") {
configs -= [ "//starboard/build/config:size" ]
configs += [ "//starboard/build/config:speed" ]

if (use_skia_next) {
include_dirs = [ skia_include_dir ]
}

deps = [
":software_rasterizer",
"//base",
Expand Down
22 changes: 0 additions & 22 deletions cobalt/renderer/rasterizer/egl/hardware_rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkSurface.h"
#ifdef USE_SKIA_NEXT
#include "third_party/skia/include/gpu/GrDirectContext.h"
#else
#include "third_party/skia/include/gpu/GrContext.h"
#endif

namespace cobalt {
namespace renderer {
Expand Down Expand Up @@ -82,15 +78,9 @@ class HardwareRasterizer::Impl {
void ReleaseContext() { graphics_context_->ReleaseCurrentContext(); }

private:
#ifdef USE_SKIA_NEXT
GrDirectContext* GetFallbackContext() {
return fallback_rasterizer_->GetGrContext();
}
#else
GrContext* GetFallbackContext() {
return fallback_rasterizer_->GetGrContext();
}
#endif

void ResetFallbackContextDuringFrame();
void FlushFallbackOffscreenDraws();
Expand Down Expand Up @@ -239,16 +229,9 @@ void HardwareRasterizer::Impl::FlushFallbackOffscreenDraws() {
void HardwareRasterizer::Impl::ResetFallbackContextDuringFrame() {
// Perform a minimal reset of the fallback context. Only need to invalidate
// states that this rasterizer pollutes.
#ifdef USE_SKIA_NEXT
uint32_t untouched_states =
kMSAAEnable_GrGLBackendState | kStencil_GrGLBackendState |
kPixelStore_GrGLBackendState | kFixedFunction_GrGLBackendState;
#else
uint32_t untouched_states =
kMSAAEnable_GrGLBackendState | kStencil_GrGLBackendState |
kPixelStore_GrGLBackendState | kFixedFunction_GrGLBackendState |
kPathRendering_GrGLBackendState;
#endif

GetFallbackContext()->resetContext(~untouched_states & kAll_GrBackendState);
}
Expand Down Expand Up @@ -322,12 +305,7 @@ sk_sp<SkSurface> HardwareRasterizer::Impl::CreateFallbackSurface(
0, info);

uint32_t flags = 0;
#ifdef USE_SKIA_NEXT
SkSurfaceProps skia_surface_props(flags, kUnknown_SkPixelGeometry);
#else
SkSurfaceProps skia_surface_props(flags,
SkSurfaceProps::kLegacyFontHost_InitType);
#endif
return SkSurface::MakeFromBackendRenderTarget(
GetFallbackContext(), skia_render_target, kBottomLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType, nullptr, &skia_surface_props);
Expand Down
14 changes: 0 additions & 14 deletions cobalt/renderer/rasterizer/skia/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//cobalt/renderer/rasterizer/skia/skia/skia_next.gni")

static_library("common") {
visibility = [ ":*" ]

Expand Down Expand Up @@ -44,10 +42,6 @@ static_library("common") {
configs -= [ "//starboard/build/config:size" ]
configs += [ "//starboard/build/config:speed" ]

if (use_skia_next) {
include_dirs = [ skia_include_dir ]
}

public_deps = [
"//base",
"//cobalt/base",
Expand Down Expand Up @@ -84,10 +78,6 @@ static_library("hardware_rasterizer") {
configs -= [ "//starboard/build/config:size" ]
configs += [ "//starboard/build/config:speed" ]

if (use_skia_next) {
include_dirs = [ skia_include_dir ]
}

deps = [
":common",
"//cobalt/renderer:renderer_headers_only",
Expand All @@ -111,9 +101,5 @@ static_library("software_rasterizer") {
configs -= [ "//starboard/build/config:size" ]
configs += [ "//starboard/build/config:speed" ]

if (use_skia_next) {
include_dirs = [ skia_include_dir ]
}

deps = [ ":common" ]
}
15 changes: 0 additions & 15 deletions cobalt/renderer/rasterizer/skia/hardware_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,16 @@
#include "cobalt/renderer/backend/egl/texture.h"
#include "cobalt/renderer/backend/egl/texture_data.h"
#include "cobalt/renderer/rasterizer/skia/image.h"
#ifdef USE_SKIA_NEXT
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/GrTypes.h" // included for GrMipMapped
// alias
#else
#include "third_party/skia/include/gpu/GrContext.h"
#include "third_party/skia/include/gpu/GrTexture.h"
#endif

namespace cobalt {
namespace renderer {
namespace rasterizer {
namespace skia {

#ifdef USE_SKIA_NEXT
using GrContext = GrDirectContext;
#endif

// We use GL RGBA formats to indicate that a texture has 4 channels, but those
// 4 channels may not always strictly mean red, green, blue and alpha. This
Expand All @@ -57,14 +50,6 @@ typedef base::Callback<void(
const scoped_refptr<backend::RenderTarget>& render_target)>
SubmitOffscreenCallback;

#ifndef USE_SKIA_NEXT
// Wraps a Cobalt backend::TextureEGL with a Skia GrTexture, and returns the
// Skia ref-counted GrTexture object (that takes ownership of the cobalt
// texture).
GrTexture* CobaltTextureToSkiaTexture(
GrContext* gr_context, std::unique_ptr<backend::TextureEGL> cobalt_texture);
#endif

// Forwards ImageData methods on to TextureData methods.
class HardwareImageData : public render_tree::ImageData {
public:
Expand Down
18 changes: 0 additions & 18 deletions cobalt/renderer/rasterizer/skia/hardware_rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,8 @@
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#ifdef USE_SKIA_NEXT
#include "third_party/skia/include/gpu/GrDirectContext.h"
#else
#include "third_party/skia/include/gpu/GrContext.h"
#endif
#include "third_party/skia/include/gpu/GrContextOptions.h"
#ifndef USE_SKIA_NEXT
#include "third_party/skia/include/gpu/GrTexture.h"
#endif
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
#include "third_party/skia/src/gpu/GrRenderTarget.h"
#include "third_party/skia/src/gpu/GrResourceProvider.h"
Expand Down Expand Up @@ -157,11 +150,7 @@ namespace {

SkSurfaceProps GetRenderTargetSurfaceProps(bool force_deterministic_rendering) {
uint32_t flags = 0;
#ifdef USE_SKIA_NEXT
return SkSurfaceProps(flags, kUnknown_SkPixelGeometry);
#else
return SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType);
#endif
}

// Takes meta-data from a Cobalt RenderTarget object and uses it to fill out
Expand Down Expand Up @@ -524,16 +513,9 @@ void HardwareRasterizer::Impl::RenderTextureEGL(
}

// Let Skia know that we've modified GL state.
#ifdef USE_SKIA_NEXT
uint32_t untouched_states =
kMSAAEnable_GrGLBackendState | kStencil_GrGLBackendState |
kPixelStore_GrGLBackendState | kFixedFunction_GrGLBackendState;
#else
uint32_t untouched_states =
kMSAAEnable_GrGLBackendState | kStencil_GrGLBackendState |
kPixelStore_GrGLBackendState | kFixedFunction_GrGLBackendState |
kPathRendering_GrGLBackendState;
#endif
gr_context_->resetContext(~untouched_states & kAll_GrBackendState);
}

Expand Down
8 changes: 0 additions & 8 deletions cobalt/renderer/rasterizer/skia/hardware_rasterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@
#include "cobalt/renderer/backend/render_target.h"
#include "cobalt/renderer/rasterizer/rasterizer.h"

#ifdef USE_SKIA_NEXT
class GrDirectContext;
#else
class GrContext;
#endif
class SkCanvas;

namespace cobalt {
Expand Down Expand Up @@ -80,11 +76,7 @@ class HardwareRasterizer : public Rasterizer {
const scoped_refptr<backend::RenderTarget>& render_target);

render_tree::ResourceProvider* GetResourceProvider() override;
#ifdef USE_SKIA_NEXT
GrDirectContext* GetGrContext();
#else
GrContext* GetGrContext();
#endif

void MakeCurrent() override;
void ReleaseContext() override;
Expand Down
4 changes: 0 additions & 4 deletions cobalt/renderer/rasterizer/skia/hardware_resource_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
#include "cobalt/renderer/rasterizer/skia/hardware_image.h"
#include "cobalt/renderer/rasterizer/skia/text_shaper.h"
#include "third_party/skia/include/core/SkFontMgr.h"
#ifdef USE_SKIA_NEXT
#include "third_party/skia/include/gpu/GrDirectContext.h"
#else
#include "third_party/skia/include/gpu/GrContext.h"
#endif

namespace cobalt {
namespace renderer {
Expand Down
Loading

0 comments on commit 8ad20db

Please sign in to comment.